akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define INF 10000000
 
int matrixChainOrder(int *p, int n){
  int i, j, k, l,  m[N][N], q;
  for(i = 1; i <= n; i++){
    m[i][i] = 0;
  }
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k = i; k < j; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(m[i][j] > q) m[i][j] = q;
      }
    }
  }
  return m[i-1][j];
}

 
int main(){
  int i,j,n;
  int p[N];
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++){
    scanf("%d %d",&p[i],&p[i+1]);
  }
 
  printf("%d\n",matrixChainOrder(p,n));
 
  return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
const int maxn=100005;
int main(){
	int n;
	n=read();
	int lt=0,lx=0,ly=0,t,x,y;
	REP(i,1,n){
		t=read(),x=read(),y=read();
		if((t+x+y)&1)return puts("No"),0;
		if(abs(x-lx)+abs(y-ly)>t-lt)return puts("No"),0;
		lt=t,lx=x,ly=y;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//int ar[1005][1005]={0};
int main()
{
    int n,m,i,j;
    cin>>m>>n;
    char arr[m+1][n+1];
    long long int ar[1005][1005]={0};
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            cin>>arr[i][j];
            //ar[i][j]=0;

        }
    }

    int a,b,c,d,count=0;
    ar[1][1]=1;

    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i==1 && j>1)
            {
                if(arr[i][j]=='#'){break;}
                else{ar[i][j]=1;}
            }
            if(i>1 && j==1 && arr[i][j]=='.'){ar[i][j]=ar[i-1][j]; }//cout<<ar[i][j]<<',';}
            if(i>1 && j>1)
            {
                if(arr[i][j]=='.')
                {
                    ar[i][j]=ar[i-1][j]+ar[i][j-1];
                    ar[i][j]=ar[i][j]%(1000000000+7);
                    

                }
                
            }
            //if(j==1){cout<<ar[i][j]<<", ";}
            //if(i==2 && j==2){cout<<ar[2][2];}
            //cout<<arr[i][j];
        }
        //<<endl;
    }
    cout<<ar[m][n];

    
}


Measured memory_bytes: 9088
#include <iostream>

using namespace std;

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

  int result = 0;
  for (int i= 0; i < 2; i++) {
    if (a > b) {
      result += a;
      a--;
    } else {
      result += b;
      b--;
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int i,n,a[50],dem=0;
  scanf("%d", &n);
  for (i=0; i<n; i++)
    {
      scanf("%d", &a[i]);
      if (a[i]!=i+1) dem++;
    }
  if (dem>2) printf("NO");
   else printf("YES");
  return 0;
}

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


def solve(N: int):
    print(N ** 3)


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>
#include <cmath>

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int tmp = 0;
    int count = 0;
    rep(i, n){
        if(tmp == a[i]){
            count--;
            tmp = 0;
        }else{
            count++;
            tmp = a[i];
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

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

int dp[1<<10][331];

int main(){
  int n,s;
  while(~scanf("%d%d",&n,&s)){
    memset(dp,0,sizeof(dp));
    if( s>330 ){
      puts("0");
      continue;
    }
    rep(k,10)dp[1<<k][k] = 1;

    REP(i,1,n){
      int comb = (1<<i)-1;
      while( comb < 1<<10 ){
	rep(j,s+1)if( dp[comb][j] ){
	  rep(k,10)if( !(comb&(1<<k)) ){
	    if( j+(i+1)*k<=s ){
	      dp[comb|(1<<k)][j+(i+1)*k] += dp[comb][j];
	    }
#if DEB
	    printf("__comb:%d|(1<<%d)][%d]\n",comb,k,j+(i+1)*k);
#endif
	  }
	}
	int x = comb & -comb;
	int y = comb + x;
	comb = ((comb&~y)/x>>1)|y;
#if DEB
	printf("comb:%d i:%d\n",comb,i+1);
#endif
      }
    }

    int ans = 0;
    int comb = (1<<n)-1;
    while( comb < 1<<10 ){
      ans += dp[comb][s];
      int x = comb & -comb;
      int y = comb + x;
      comb = ((comb & ~y)/x>>1)|y;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn comb2(n: usize) -> Vec<(usize, usize)> {
    let mut v = Vec::new();
    for i in 0..(n - 1) {
        for j in (i + 1)..n {
            v.push((i, j));
        }
    }
    v
}

trait BinarySearch<T> {
    fn front_position(&self, x: T) -> usize;
    fn back_position(&self, x: T) -> usize;
    fn bs_position(v: &[T], x: T, is_back: bool) -> usize;
}

impl<T> BinarySearch<T> for Vec<T>
where
    T: Ord,
{
    fn front_position(&self, x: T) -> usize {
        Self::bs_position(self, x, true)
    }

    fn back_position(&self, x: T) -> usize {
        Self::bs_position(self, x, false)
    }

    fn bs_position(v: &[T], x: T, is_front: bool) -> usize {
        let len = v.len();
        if len == 1 {
            return if x < v[0] || (is_front && x == v[0]) {
                0
            } else {
                1
            };
        }
        let i = len / 2;
        if x < v[i] || (is_front && x == v[i]) {
            Self::bs_position(&v[..i], x, is_front)
        } else {
            Self::bs_position(&v[i..], x, is_front) + i
        }
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.to();
    let mut v: Vec<i32> = (0..n).map(|_| iter.to()).collect();
    v.sort();
    let mut count = 0;
    for (i, j) in comb2(n) {
        let a = v[i];
        let b = v[j];
        let mut vv = v.clone();
        let rem_a = vv.front_position(a);
        vv.remove(rem_a);
        let rem_b = vv.front_position(b);
        vv.remove(rem_b);
        // a - b < c
        // b - a < c
        // c < a + b
        let max = std::cmp::max(a - b, b - a);
        let start = vv.back_position(max);
        let end = vv.front_position(a + b);
        count += end - start;
    }
    println!("{}", count / 3);
}

Measured memory_bytes: 36088
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = n/(a+b)*a + min(n%(a+b), a);

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


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k; cin >> n >> k;
  if (k==1) {
    cout << 0 << endl;
    return 0;
  }
  cout << n-k << endl;
}

Measured memory_bytes: 256
# a<=bとみなせるので探索回数は√nでよい
import math
n = int(input())
r_n = int(math.sqrt(n))+1
m = 10 ** 12
for i in range(1,r_n):
  if n % i == 0 and m > i + n / i - 2:
    m = i + n / i - 2
 
print(int(m))

Measured memory_bytes: 3060
use std::io;

fn main() {
  let mut line = String::new();
  io::stdin().read_line(&mut line).unwrap();
  let a : i32 = line.trim().parse().unwrap();

  let mut s = String::new();
  io::stdin().read_line(&mut s).unwrap();

  print!("{}\n", if a >= 3200 { s } else { "red".to_string() });
}


Measured memory_bytes: 4352
data = []
while len(data) < 2:
    val = input()
    data = data + val.split(" ")
    #print(data)

for i,val in enumerate(data):
    data[i] = int(val)

s,w = data[0],data[1]

if s <= w:
    print("unsafe")

else:
    print("safe")


Measured memory_bytes: 9140
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b;
    string s;
    cin >> s; 
    cout << "ABC" << s << endl;
    return 0;
}

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

using namespace std;

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

    int cc = 0;
    for (int i = 0; i < 3; ++i)
        cc += (a[i] == b[i]);

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();
    
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	
	cout << (H - h) * (W - w);
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N,count=0;
	int i;
	
	scanf("%d", &N);
	
	if(N%4==0)
		{
			printf("Yes \n");
			count +=1;
		}
	
	for(i=1 ; i<= N/7 ;i++)
	{
		if( (N - 7*i)%4 ==0 && count==0)
		{
			printf("Yes \n");
			count +=1;
		}
	}
	
	if(count ==0)
	{
		printf("No \n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2)cout << "Borys";
    else cout << "Alice";
}

/*
*/


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, L, w[110], c1, c2, R[110], RC, s;
int main(){
    int i;
    scanf("%d%d",&L,&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
        if(w[i]%2){
            if(!c1)c1=i;
            else if(!c2)c2=i;
            else{
                printf("Impossible\n");
                return 0;
            }
        }
    }
    if(c1)swap(w[1],w[c1]);
    if(c2)swap(w[n],w[c2]);
    for(i=1;i<=n;i++)printf("%d ",w[i]);
    printf("\n");
    for(i=1;i<=n;i++){
        R[++RC] = w[i];
        if(i==1){
            if(w[i] == 1)R[RC]++;
            else R[RC]--;
        }
        s += R[RC];
        if(s > L){
            R[RC] -= (s-L);
            s=L;
        }
        if(s==L)break;
    }
    if(s<L){
        if(n>=2 && w[n]%2==1)R[RC] += (L-s);
        else R[++RC] = 1;
    }
    printf("%d\n",RC);
    for(i=1;i<=RC;i++)printf("%d ",R[i]);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
	string s;
	ll N,W=0,E=0,num=0,min=1000000;
	cin >> N >> s;
	for (ll i = 0;i < N;i++) {
		if (s[i] == 'E')E++;
	}
	for (ll i = 0;i < N;i++) {
		if (s[i] == 'W') {
			num = E + W;
			W++;
			if (min >= num)min = num;
		}
		else {
			if (s[i] == 'E') {
				E--;
				num = E + W;
				if (min >= num)min = num;
			}
		}
		
	}
	cout << min << endl;
	return 0;

}

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


int main() {
    int a,b;
    cin >> a >> b;
    if(a <= b){
        cout << a << endl;
    }else{
        cout << a-1 << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;

int main(){
  int n;
  cin>>n;
  vector<long long int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
    
  long long sum=0;
  for(int i=0;i<60;i++){
    long long s1=0;
    long long int one=0,zero=0;
    for(int j=0;j<n;j++){
      if(v[j]%2)
        one+=1;
      else
        zero+=1;
        
      v[j]=v[j]/2;  
    }
    long long k=((long long)1<<i)%mod;
    s1=((one%mod*zero%mod)%mod*k%mod)%mod;
    sum=(sum%mod+s1%mod)%mod;
  }
  cout<<sum%mod;
}


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


using namespace std;

int main()
{
  int i = 0;
  string S,T; 
  cin >> S >> T;



    for(i = 0; i <= S.length()-1; i++){
      if(S[i] == T[i])
      {
        continue;
      }

      else
      {
        cout << "No";
        exit(0);
      }
    }

    cout << "Yes";
}
    
  

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

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

  int sum = 0;

  int m = n;
  while (m > 0) {
    sum += m % 10;
    m /= 10;
  }

  if (n % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 500;
int ans[N*N], us[N*N];
signed main()
{
#ifdef home
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#else
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    vector<pair<int, int> > in;
    for(int i=0;i<n;i++){
        int v;
        cin>>v;
        in.push_back({v-1, i+1});
    }
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)if(in[i].first==in[j].first){
        cout<<"No";
        return 0;
    }
    sort(in.begin(), in.end());
    int l=0;
    for(auto i:in){
        int cnt=i.second-1;
        while(cnt--){
            while(us[l])l++;
            if(l>=i.first){
                cout<<"No";
                return 0;
            }
            ans[l]=i.second;
            us[l]=1;
            l++;
        }
        ans[i.first]=i.second;
        us[i.first]=1;
    }
    sort(in.rbegin(), in.rend());
    l=n*n-1;
    for(auto i:in){
        int cnt=n-i.second;
        while(cnt--){
            while(us[l])l--;
            if(l<=i.first){
                cout<<"No";
                return 0;
            }
            ans[l]=i.second;
            us[l]=1;
            l--;
        }
        ans[i.first]=i.second;
        us[i.first]=1;
    }
    for(int i=0;i<n*n;i++){
        if(!us[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes\n";
    for(int i=0;i<n*n;i++)cout<<ans[i]<<' ';
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  string S{}; cin >> S;
  auto inf = S.size();
  int min = std::numeric_limits<int>::max();
  for(ui a = 0; a < inf - 2; ++a)
  {
    string s{S.substr(a, 3)};
    min = std::min(min, std::abs(std::stoi(s, nullptr, 10) - 753));
  }
  cout << min << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
def main():
    # 町の数N, 町iの転送先はindexがAi-1の町
    N,K = map(int, input().split())
    A = list(map(int, input().split()))

    # K回移動した時の町番号を出力
    # もし一度出てきた番号が出てきたら記憶している道順リストを使う
    # 最初は道を覚えさせる作業が必要
    now = 0
    history = [0]
    isVisited = [False for i in range(N)]
    i = 0
    while i<K:
        # まず進む
        now = A[now]-1
        # 道順登録
        #if now not in history:
        if isVisited[now] == False:
            history.append(now)
            isVisited[now] = True
            i+=1
        # 以前出てきてる町ならそこから末尾までを自動で進めてiのカウントも進める
        else:
            start = history.index(now)
            r = start + (K-1-i)%(len(history)-start)
            now = history[r]
            break

    print(now+1)

main()


Measured memory_bytes: 31988
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-6
#define endl '\n'
long long mod = 1e9 + 7;
const int N = 1e5 + 5;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
ll xx1 , yy1 , xx2 , yy2 , diffx , diffy;
int main()
{
    em3
    cin >> xx1 >> yy1 >> xx2 >> yy2;
    diffx = xx2 - xx1;
    diffy = yy2 - yy1;
    cout << xx2 - diffy << ' ' << yy2 + diffx << ' ' << xx1 - diffy << ' ' << yy1 + diffx << endl;
    return 0;
}


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


int main() {
    int n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    ll sum1 = 0;
    rep(i, n + 1) {
        cin >> a[i];
        sum1 += a[i];
    }
    rep(i, n) cin >> b[i];

    rep(i, n){
        if (b[i] <= a[i]) a[i] -= b[i]; 
        else  if (b[i] <= a[i] + a[i + 1]) {
            a[i + 1] -= b[i] - a[i];
            a[i] = 0;
        }
        else {
            a[i] = 0;
            a[i + 1] = 0;
        }
    }

    ll sum2 = 0;
    rep(i, n + 1) sum2 += a[i];
    cout << sum1 - sum2;


}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n, m;
	cin >> n >> m;
	int i;
	map<ll, ll, greater<ll>> mp;
	for (i = 0; i < n; i++) {
		int a;
		cin >> a;
		mp[a]++;
	}
	for (i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		mp[b] += a;
	}
	ll ans = 0;
	ll least = n;
	for (auto c : mp) {
		if (least == 0) break;
		ll find = min(least, c.second);
		ans += c.first * find;
		least -= find;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
#include <math.h>

int main() {
  int x, h;
  double square, tri;

  while (scanf("%d %d", &x, &h) != EOF) {
    if (x == 0 && h == 0) {
      break;
    } else {
      square = pow(x, 2);
      tri = 0.5 * x * sqrt(pow(h, 2) + (square / 4));
      printf("%f\n", square + 4 * tri);
    }
  }

  return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
int A[111111]; // 0
int B[111111]; // +
int C[111111]; // -

int main() {
   cin >> N;
   map<int, int> mp;
   rep (i, N) {
      cin >> A[i];
      B[i] = A[i]-1;
      C[i] = A[i]+1;
      mp[A[i]]++;
      mp[B[i]]++;
      mp[C[i]]++;
   }

   int ans = 0;
   for (auto x : mp) {
      ans = max(ans, x.second);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

int clr_int(string str)
{
	int v = 0;
	int r = 1;
	for(int i = 0;i < str.size();i++)
	{
		switch(str[i])
		{
			case 'g':
			v += r;
			break;
			case 'b':
			v += r*2;
			break;
		}
		r *= 3;
	}
	return v;
}
string int_clr(int v,int l)
{
	string str;
	for(int i = 0;i < l;i++)
	{
		int r = v % 3;
		switch(r)
		{
			case 0:
			str += "r";
			break;
			case 1:
			str += "g";
			break;
			case 2:
			str += "b";
			break;
		}
		v /= 3;
	}
	return str;
}

vector<vector<int>> makeG(int l)
{
	auto grh = vector<vector<int>>();
	int r = 1;
	for(int i = 0;i < l;i++)
	{
		r *= 3;
	}
	for(int i = 0;i < r;i++)
	{
		auto str = int_clr(i,l);
		auto ary = vector<int>();
		for(int j = 0;j < (l-1);j++)
		{
			if(str[j] != str[j+1])
			{
				auto scp = string(str);
				switch(str[j])
				{
					case 'r':
					scp[j] = scp[j+1] = (str[j+1] == 'g')?'b':'g';
					ary.push_back(clr_int(scp));
					break;
					case 'g':
					scp[j] = scp[j+1] = (str[j+1] == 'b')?'r':'b';
					ary.push_back(clr_int(scp));
					break;
					case 'b':
					scp[j] = scp[j+1] = (str[j+1] == 'r')?'g':'r';
					ary.push_back(clr_int(scp));
					break;
				}
			}
		}
		grh.push_back(ary);
	}
	return grh;
}

int main()
{
	string str;
	cin >> str;
	while(str.size() > 1)
	{
		auto graph = makeG(str.size());
		//cout << "l:" << str.size() << "r:" << graph.size() << endl;
		queue<pair<int,int>> q;
		q.push(pair<int,int>(clr_int(str),0));
		auto table = vector<int>(graph.size(),0);
		int c = 0;
		while(q.size() > 0)
		{
			auto n = q.front();
			if(graph[n.first].size() == 0)
			{
				cout << n.second << endl;
				break;
			}
			else if(c == graph.size())
			{
				cout << "NA" << endl;
				break;
			}
			else
			{
				const int l = graph[n.first].size();
				for(int i = 0;i < l;i++)
				{
					if(table[graph[n.first][i]] == 0)
					{
						table[graph[n.first][i]] = 1;
						c++;
						q.push(pair<int,int>(graph[n.first][i],n.second+1));
					}
				}
			}
			q.pop();
		}
		if(q.size() == 0)
		{
			cout << "NA" << endl;
		}
		cin >> str;
	}
	return 0;
}

Measured memory_bytes: 5032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
	string s;
	cin>>s;
	int cnt = 0;
	bool flag=false;
	reverse(s.begin(),s.end());
	
	while(true){
		if(cnt==s.size()){
			cout<<"YES"<<endl;
			return 0;
		}
		if(s.substr(cnt,5)=="maerd"){
			cnt+=5;
		}
		else if(s.substr(cnt,5)=="esare"){
			cnt+=5;
		}
		else if(s.substr(cnt,7)=="remaerd"){
			cnt+=7;
		}
		else if(s.substr(cnt,6)=="resare"){
			cnt+=6;
		}
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    
    while(1) {
        
        int n;
        
        double sum = 0;
        double s,m;
        double sum1 = 0;
        
        cin >> n;
        
        if (n == 0) break;
        
        int num[n];
        
        for (int i = 0 ; i < n; i ++) {
            
            cin >> s;
            
            sum += s;
            
            num[i] = s;
            
        }
        
        m = sum / n;
        
        for (int i = 0 ; i < n; i ++) {
            
            sum1 += pow(num[i] - m,2);
            
        }
        
        double B = sqrt(sum1 / n);
        
        printf("%.5f\n", B);
    
    }
    
    
    return 0;
    
}


Measured memory_bytes: 3196
#include<stdio.h>
#include<string.h>
int main(){
char A[11],B[11],C[11];
int p,q,r;
scanf("%s",A);
scanf("%s",B);
scanf("%s",C);
p=strlen(A)-1;
q=strlen(B)-1;
r=strlen(C)-1;
if((A[0] >= 'a' && A[p] <= 'z') && (B[0] >= 'a' && B[q] <= 'z') && (C[0] >= 'a'&& C[r] <= 'z')){
    if((A[p]==B[0])&&(B[q]==C[0])){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}
return 0;
}




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

int main() {
  int N;
  int A=0, B=0;

  cin >> N;
  
  vector<int>a(N);

  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());

	for(int i=0;i<N;i++) {
    if(i%2 == 0){
      A += a.at(i);
    }
    else{
      B += a.at(i);
    }
  }

	cout << abs(A-B) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
    int n,m,k[50],a[50][50];
    int mm[100];
    int yes=0;
    scanf("%d %d",&n,&m);
    //初期化
    for(int kk=0;kk<m;kk++){
        mm[kk]=0;
    }
    //好きな食べ物の取得
    for(int i=0;i<n;i++){
        scanf("%d",&k[i]);
        for(int j=0;j<k[i];j++){
            scanf("%d",&a[i][j]);
            mm[a[i][j]]++;
        }
    }
    //好きな人がn人全員である食べ物チェック
    for(int i=0;i<=m;i++){
        if(mm[i]==n){yes++;}
    }
    printf("%d\n",yes);
}


Measured memory_bytes: 128
n,a,b=map(int,input().split())
m=10**9+7
ALL=pow(2,n,m)-1
x=y=1
for i in range(b):
    x=x*(i+1)%m
    y=y*(n-i)%m
    if i+1==a:
        a=b
        ALL-=y*pow(x,m-2,m)
print(ALL%m)

Measured memory_bytes: 3064
#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>;
 
 
int main() {
    int x,y;
    cin >> x >> y;
    vector<int> a={0,1,3,1,2,1,2,1,1,2,1,2,1};
    if(a.at(x)==a.at(y))cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
double count=0,f;
int i,N;
scanf("%d",&N);
for(i=0;i<=N;i++)
{
if(i%2!=0)
count=count+1;
}
f=count/N;
printf("%.10lf\n",f);
return 0;
}

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

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

  vector<int> a(N);
  vector<int> b(N);
  for (int i=0;i<N;i++) cin >> b.at(i);

  for(int i=0;i<N;i++){
    if((i+1)>=b.at(i)){
      a.insert(a.begin()+(b.at(i)-1),b.at(i));
    }
    else{
      cout << "-1" << endl;
      return 0;
    }
  }

  for(int i=0;i<N;i++){
    cout << a.at(i) << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int MCO(int* p, int n){
  int m[n+1][n+1];
  int i,j,k,l,q;
  for(i=1;i<=n;i++) m[i][i]=0;

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=1000000000;
      for(k=i;k<=j-1;k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(m[i][j] > q) m[i][j]=q;
      }
    }
  }

  return m[1][n-1];
}

int main(){
  int i,n,p[100],M[100][2];
   scanf("%d",&n);
  for(i=1;i<n+1;i++){
      scanf("%d %d",&M[i][0],&M[i][1]);
      if(i==1) p[0]=M[i][0];
      p[i]=M[i][1];
    }
  
  printf("%d\n",MCO(p,n+1));
  
  return 0;
}
    



Measured memory_bytes: 2108
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; }
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
#[warn(dead_code)]
fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n + 1];
    let mut is_prime = vec![true; n + 1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {
            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}
use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[warn(unused_mut)]
#[warn(unused_imports)]
use std::collections::BTreeSet;
fn main() {
    input! {
        a: u32,
        b: u32,
    }

    println!("{}", 6-a-b);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
lli nCr(lli n, lli r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
}
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  M=N-K+1;
  COMinit();
  rep(i,0,K){
    L=nCr(N-K+1,i+1);
    R=nCr(K-1,i);
    Out(L*R%mod);
  }
}

Measured memory_bytes: 119808
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

ll TwoCount(ll x){
    ll ret=0;
    rep(i,100000){
        if(x%2) return i;
        x/=2;
    }
    return 100000;
}

ll Gcd(ll a, ll b){
    if(a<b) return Gcd(b,a);
    return a%b ? Gcd(b,a%b) : b;
}

ll Solve(){
    ll N,M; cin>>N>>M;
    vec d(N);
    rep(i,N) cin>>d[i];
    ll Count=TwoCount(d[0]);
    REP(i,1,N) if(TwoCount(d[i])!=Count) return 0;
    rep(i,N) d[i]/=2;
    ll LCM=1;
    rep(i,N){
        LCM*=(d[i]/Gcd(LCM,d[i]));
        if(LCM>M) return 0;
    }
    M/=LCM;
    return (M+1)/2;

}


int main(){
    cout<<Solve()<<endl;
}

Measured memory_bytes: 4060
// review
#include <iostream>

using namespace std;

string s;

bool check(int i) {
  if (s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]) {
    cout << (i + 1) << " " << (i + 3) << endl;
    return true;
  }
  return false;
}

void solve() {
  if (s.size() > 2) {
    for (int i=0;i<s.size()-2;i++) {
      if (check(i)) {
        return;
      }
    }
  } else if (s[0] == s[1]) {
    cout << "1 2" << endl;
    return;
  }
  cout << -1 << " " << -1 << endl;
}

int main() {
  cin >> s;
  solve();
}


Measured memory_bytes: 512
using System;
using System.Linq;
public class Test {
	public static int gcd(int x, int y) {
		if(y == 0) return x;
		return gcd(y, x % y);
	}
	public static int lcm(int x, int y) {
		return x / gcd(x, y) * y;
	}
	public static void Main() {
		string buf;
		while(!string.IsNullOrEmpty(buf = Console.ReadLine())) {
			string[] sc = buf.Split();
			int a = int.Parse(sc[0]), b = int.Parse(sc[1]);
			Console.WriteLine(gcd(a, b) + " " + lcm(a, b));
		}
	}
}

Measured memory_bytes: 9012
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


using namespace std;

vector<int> d;
vector<int> v;

int main(){
    ll A, B;
    cin >> A >> B;

    ll x[2];
    if(A-1>0) x[0] = A-1;
    else x[0] = 0;

    if(B>0) x[1] = B;
    else x[1] = 0;

    ll f0[2];

    rep(i, 2){
        if(x[i] >= 3){
            if((x[i]-2)%4 == 1) f0[i] = 0;
            else if((x[i]-2)%4==2) f0[i] = x[i];
            else if((x[i]-2)%4==3) f0[i] = 1;
            else if((x[i]-2)%4==0) f0[i] = x[i]+1;
        }else{
            if(x[i]==0) f0[i] = 0;
            if(x[i]==1) f0[i] = 1;
            if(x[i]==2) f0[i] = 2;
        }
    }

    ll por =  f0[0] ^ f0[1];
    cout << por;

}

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

typedef long long lld;

const lld mod = 1000000007;
int N, M;
lld D[100005];
bool b[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> M;
	for (int i=0; i<M; i++){
		int t;
		cin >> t;
		b[t] = true;
	}
	D[0] = 1;
	for (int i=1; i<=N; i++){
		if (b[i]) continue;
		D[i] = D[i-1];
		if (i > 1) D[i] += D[i-2];
		D[i] %= mod;
	}
	cout << D[N] << endl;
}



Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll N,K;
ll d;
ll input;

cin >> N >> K;

vector<ll> A(N+1);

for(ll i = 1;i < A.size();++i) A[i] = 0;

for(ll i = 0;i < K;++i){

    cin >> d;

    for(ll j = 0; j < d;++j){

        cin >> input;
        A[input]++;

    }

}

ll ans = 0;

for(ll i = 1;i < A.size();++i){
    
    if(A[i] == 0) ans++;

}

cout << ans << endl;

return 0;

}

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


typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define forz(i,n) for( int i=0;i<n;i++)
#define forl(i, n) for(int i = 1; i<= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

using namespace std;

void cpc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w" , stdout);
#endif
}

int main()
{
	// cpc();
	lli n, k, sum = 0, sum1 = 0;
	cin >> n >> k ;
	// std::vector<lli> v(n - 1);
	// std::vector<lli> w(n, 0);
	for (lli i = k; i <= n + 1   ; i++)
	{
		sum1 = (sum1 + (((n * (n + 1)) / 2) - (((n  - i) * (n - i + 1)) / 2) - ((i * (i - 1)) / 2) + 1)) % mod;
		// cout << sum1 << " ";
	}
	sum =  sum1;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0){
		cout<<1;
	}
	else if(b==0){
		cout<<2;
	}
	else if(c==0){cout<<3;}
	else if(d==0){cout<<4;}
	else{cout<<5;}
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}




Measured memory_bytes: 3568
#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&b==c) printf("%d\n",a);
	if(a==b&&a!=c) printf("%d\n",c);
	if(a!=b&&b==c) printf("%d\n",a);
	if(a==c&&b!=c) printf("%d\n",b);
}

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

int N;
int ans = 0;

void dfs(string s){
  if(s!= "" && stol(s) > N){
    return;
  } else {

    if(s.find("3") != string::npos
    && s.find("5") != string::npos
    && s.find("7") != string::npos){
      ans += 1;
    }
      dfs(s+"3");
      dfs(s+"5");
      dfs(s+"7");
  }
}

int main(){
  cin >> N;
  dfs("");
  cout << ans << endl;;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, const char * argv[])
{
 int a,b;
 scanf("%d %d",&a,&b);
 if(a<b){
  printf("a < b\n");
 }else if(a==b){
  printf("a == b\n");
 }else{
  printf("a > b\n");
 }
 return 0;
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x) cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x) cout << ((x) ? "YES" : "NO") << endl
#define absi(a) (((a) >= 0) ? (a) : (-(a))) 

int main(int argc, const char* argv[]) {
	ll n, t, a;
	cin >> n >> t >> a;
	t *= 1000;
	a *= 1000;

	ll ret  = 0xFFFFFFFF;
	ll reti = 0;

	ll h[n];
	rep(i, n) {
		ll h;
		cin >> h;
		ll tmp = t - h * 6;
		if(absi(a - tmp) < ret) {
			ret = absi(a - tmp);
			reti = i;
		}
	}

	cout << reti + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 

int main (void){
	int n;
	scanf("%d",&n);
	int R[n];
	
	for(int i=0;i<n;i++){
		scanf("%d",&R[i]);
	}
	
	int maxv= R[1]-R[0];
	int minv=R[0];
	
	for(int j=1;j<n; j++){
		if(maxv < R[j]-minv){
			maxv=R[j]-minv;
		}
		
		if(minv>R[j]){
			minv=R[j];
		}
	}
	
	printf("%d\n",maxv);
	return 0;
}


Measured memory_bytes: 2564
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

string s;

int main(void){
    cin >> s;
    int ans = 100005;
    int sz = s.size();
    for (int i = 0; i < sz - 1; i++){
        if (s[i] != s[i + 1]){
            int mx = max(i + 1, sz - i - 1);
            ans = min(ans, mx);
        }
    }

    if (ans == 100005) cout << sz << endl;
    else cout << ans << endl;
    
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  int a,b;
  cin>>a>>b;
  if(a>b)swap(a,b);
  while(b--)cout<<a;
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import qualified Data.IntSet as S
import Control.Monad.Trans.State
 
main = do
  n <- readLn
  as <- map read <$> replicateM n getLine
  print $ evalState (solve as) S.empty

solve [] = S.size <$> get
solve (a:as) = do
  s <- get
  put $ if a `S.member` s
    then S.delete a s
    else S.insert a s
  solve as

Measured memory_bytes: 70012