akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    ll d = 0, ans = 0;
    rep(i, n-1) {
        if(d==0) {
            if(a[i+1] > a[i]) d = 1;
            else if(a[i+1] < a[i]) d = -1;
            continue;
        }
        else if(d>0) {
            if(a[i+1] >= a[i]) continue;
            d = 0;
            ans++;
        } else {
            if(a[i+1] <= a[i]) continue;
            d = 0;
            ans++;
        }
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 4056
#include <stdio.h>

int main(void) {
	int i,p,student[30];
	for(i=0;i<30;i++){
		student[i] = 0;
	}
	for(i=0;i<28;i++){
		scanf("%d",&p);
		student[p-1] = 1;
	}
	for(i=0;i<30;i++){
		if(student[i] == 0) printf("%d\n",i+1);
	}
	return 0;
}

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

#define int long long

using namespace std;

const int MAXN = 5e5 + 100;

int A[MAXN];

vector<int> arr[MAXN];

int P[MAXN];

struct qu
{
	int id, tp, q;
};

vector<qu> querys[MAXN];

int res[MAXN];

int ABI[MAXN];

void update(int x, int v)
{
	while(x)
	{
		ABI[x] += v;
		x -= x&-x;
	}
}

int query(int x)
{
	int res = 0;
	while(x < MAXN)
	{
		res += ABI[x];
		x += x&-x;
	}
	return res;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, Q;
    cin >> N >> Q;

    for(int i = 1 ; i <= N ; i++)
    {
    	cin >> A[i];
    	arr[A[i]].push_back(i);
    }

    for(int i = 0 ; i < MAXN ; i++)arr[i].push_back(N+1);

    for(int i = 0 ; i < MAXN ; i++)
    {
    	for(int x = 0 ; x < arr[i].size()-1 ; x++)
    	{
    		P[arr[i][x]] = arr[i][x+1];
    	}
    }

    for(int i = 1 ; i <= Q ; i++)
    {
    	int a, b;
    	cin >> a >> b;

    	querys[b].push_back({i,1,b+1});
    	querys[a-1].push_back({i,-1,b+1});
    }

    for(int i = 1 ; i <= N ; i++)
    {
    	update(P[i],1);

    	for(auto x : querys[i])
    	{
    		res[x.id] += x.tp*query(x.q);
    	}
    }

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

    return 0;
}

Measured memory_bytes: 97496
a,b,c=gets.chomp.split.map(&:to_i)
remainders = {}
(1..(b-1 > 0 ? b-1 : 1)).map{|value| remainders.store(value,0)}
count = 1
loop do
  tempRemainder = (a * count - c) % b
  remainders[tempRemainder] += 1 if tempRemainder != 0
  if tempRemainder == 0
    puts "YES"
    break
  elsif remainders[tempRemainder] > 1
    puts "NO"
    break
  end
  count += 1
end

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

const int MOD = (int)(1e9 + 7);

int n;

ll dp[MAX_N][4][4][4];
ll a = 0, c = 1, g = 2, t = 3;

ll ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  dp[0][t][t][t] = 1;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) for (int l = 0; l < 4; ++l) {
      for (int m = 0; m < 4; ++m) {
        if (j == a && k == g && l == c) continue;
        if (k == a && l == g && m == c) continue;
        if (j == a && k == c && l == g) continue;
        if (k == a && l == c && m == g) continue;
        if (j == g && k == a && l == c) continue;
        if (k == g && l == a && m == c) continue;
        if (j == a && l == g && m == c) continue;
        if (j == a && k == g && m == c) continue;
        dp[i + 1][k][l][m] += dp[i][j][k][l];
        dp[i + 1][k][l][m] %= MOD;
      }
    }
  }

  for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) for (int l = 0; l < 4; ++l) {
    ans += dp[n][j][k][l];
    ans %= MOD;
  }

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

  return 0;
}


Measured memory_bytes: 256
open System

[<EntryPoint>]
let main argv =
    let X = stdin.ReadLine() |> int

    let X1 = X / 100
    if (X1 = 0) then
        printfn "0"
    else if (X1 >= 20) then
        printfn "1"
    else if (X1 * 100 <= X && X <= X1 * 105) then
        printfn "1"
    else
        printfn "0"

    0

Measured memory_bytes: 13532
#include <iostream>
#include <cstring>

using namespace std;

int sum;

int main() {
	char ch = getchar();
	while(isdigit(ch)) {
		sum += (ch - '0');
		ch = getchar();
	}
	if(sum % 9 == 0) {
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
def read_input():
    n = int(input())

    sheets = []
    for i in range(n):
        l, r = map(int, input().split())
        sheets.append((l, r))

    return n, sheets

def submit():
    n, sheets = read_input()

    watcher = 0
    for sheet in sheets:
        watcher += sheet[1] - sheet[0] + 1

    print(watcher)


if __name__ == '__main__':
    submit()

Measured memory_bytes: 38768
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (X, A) = read!(i64, i64);

    println!("{}", if X < A { 0 } else { 10 })
}


Measured memory_bytes: 4352
<?php
$inVal = explode(" ", trim(fgets(STDIN)));
if($inVal[0] < $inVal[1]){
    echo "a < b".PHP_EOL;
} else if($inVal[0] > $inVal[1]){
    echo "a > b".PHP_EOL;
} else {
    echo "a == b".PHP_EOL;
}
?>


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// auto mod int
const ll mod = 1000000007;
struct mint{
  ll x; // typedef long long ll;
  mint(ll x=0) : x((x%mod+mod)%mod) {}  // ans.x:答えを出力する際はメンバ変数を参照する
  mint operator-() const{
    return mint(-x);
  }
  mint& operator+=(const mint a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a){
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (x *= a.x) %= mod; return *this;
  }
  mint operator+(const mint a) const{
    return mint(*this) += a;
  }
  mint operator-(const mint a) const{
    return mint(*this) -= a;}
  mint operator*(const mint a) const{
    return mint(*this) *= a;
  }
  mint pow(ll t) const{
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const{
    return pow(mod-2);
  }
  mint& operator/=(const mint a){
    return *this *= a.inv();
  }
  mint operator/(const mint a) const{
    return mint(*this) /= a;
  }
};

istream& operator>>(istream& is, const mint& a){
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a){
  return os << a.x;
}

struct combination{
  vector<mint> fact, ifact;  // 階乗と階乗の逆元を前計算する
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for(ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for(ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(1e7+5);

mint g(ll r, ll c){
  return comb(r+c+2, r+1) - 1;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
  r1--; c1--;
  mint ans = 0;
  ans += g(r2, c2);
  ans -= g(r1, c2);
  ans -= g(r2, c1);
  ans += g(r1, c1);
  cout << ans.x << endl;
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;



int main(void) {
  ll a,b,c, d;
  cin >> a >> b >> c >> d;
  ll p = c/__gcd(c,d)*d;
  
  ll ans = b-(b/c+b/d-b/p)-(a-1-((a-1)/c+(a-1)/d-(a-1)/p));
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main(){
	string s[3];
	REP(i,3)cin >> s[i];
	string ans = "";
	REP(i,3){
		ans += toupper(s[i][0]);
	}
	out(ans);
}

Measured memory_bytes: 3648
N = int(input())

d = {}
w1 = []
f = False
for i in range(N):
    w = input()

    if d.get(w) is None:
        d[w] = 1
    else:
        f = True

    w1.append(w)

for i in range(1, N):
    if w1[i-1][-1] == w1[i][0]:
        continue
    else:
        f = True

print('Yes' if f is False else 'No')

Measured memory_bytes: 3064
class UnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数
 
    def root(self, x): #root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
            return self.parent[x]
 
    def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]
    
n,m = map(int, input().split())
bridge = []
for i in range(m):
    a, b= map(int, input().split())
    bridge.append((a,b))

non_route = []
total = int(n*(n-1)/2)
non_route.append(total)

uft = UnionFind(n)

tmp = total

for i in range(m-1,0,-1):
    a = bridge[i][0] -1
    b = bridge[i][1] -1

    if uft.issame(a, b):
        non_route.append(non_route[-1])
        continue
    ra = uft.size(a)
    rb = uft.size(b)
    non_route.append(non_route[-1] - ra * rb)
    uft.merge(a, b)

final = sorted(non_route)
for i in range(len(final)):
    print(final[i])

Measured memory_bytes: 24528
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
//int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
//while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}

int32_t main(void){
	IOS;
	in2(x, y);
	if(x*4 >= y && x*2 <= y && y%2 == 0) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
	int id[10010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		g.e[i].s=x;
		g.e[i].g=y;
	}
	g.vcnt=n;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

int flag[10010],toposo[10010],cnt;
void dfs(int v){
	if(flag[v]++)return;
	rep(i,g.id[v],g.id[v+1])dfs(g.e[i].g);
	toposo[cnt++]=v;
}

int main(){
	readgraph();
	rep(i,0,g.vcnt)dfs(i);
	for(int i=cnt-1;i>=0;i--)printf("%d\n",toposo[i]);
}


Measured memory_bytes: 2816
/*
h s, d't skp th si tll i's svedclTabCtrl
 * ABC141 E
 * ABC145 D
 * ABC147 F
 * ABC174 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int a[5];
for(int i=0;i<5;i++)
{
cin>>a[i];
}
for(int i=0;i<5;i++)
{
if(a[i]==0)
{
cout<<i+1;
}
}
}
/*
 *||||

 */

Measured memory_bytes: 3596
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    deque<ll> Q;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if((i&1)^(n&1)){Q.push_front(a);}
        else{Q.push_back(a);}
    }
    for(int i=0;i+1<n;i++){cout<<Q[i]<<" ";}
    cout<<Q.back()<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define BLACK 1
#define WHITE 2

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

bool visit[55][55];
char island[55][55];
int w, h;
int curr;

void dfs (int cx, int cy )
{
	visit[cy][cx] = true;

	rep (k, 4 ){
		int ny = cy + dy[k];
		int nx = cx + dx[k];
		if (ny < 0 || nx < 0 || ny >= h || nx >= w || visit[ny][nx] ) continue;
		if (island[ny][nx] == 'B' ){
			curr |= BLACK;
			continue;
		} // end if
		if (island[ny][nx] == 'W' ){
			curr |= WHITE;
			continue;
		} // end if
		dfs (nx, ny );
 	} // end rep
}

void dfs2 (int cx, int cy, char c )
{
	island[cy][cx] = c;
	rep (k, 4 ){
		int nx = cx + dx[k];
		int ny = cy + dy[k];
		if (nx < 0 || nx >= w || ny < 0 || ny >= h || island[ny][nx] != '.' ) continue;
		dfs2 (nx, ny, c );
	} // end rep	
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.Surrounding_Area", "r", stdin );
	while (scanf ("%d %d", &w, &h ) && w && h ){
		memset (visit, false, sizeof (visit ) );
		memset (island, 0, sizeof (island ) );
		rep (i, h ){
			rep (j, w ){
				scanf ( " %c", &island[i][j] );
			} // end rep
		} // end rep
		rep (y, h ){
			rep (x, w ){
				if (!visit[y][x] && island[y][x] == '.' ){
					curr = 0;
					dfs (x, y );
					if (curr == BLACK ){
						dfs2 (x, y, 'b' );
					}else
					if (curr == WHITE ){
						dfs2 (x, y, 'w' );
					}else
					if (curr == (BLACK & WHITE ) ){
						dfs2 (x, y, 'f' );
					} // end if
				} // end if
			} // end rep
		} // end rep

		int W = 0, B = 0;
		rep (y, h ){
			rep (x, w ){
				if (island[y][x] == 'w' ) W++;
				else
				if (island[y][x] == 'b' ) B++;
//				cout << island[y][x];
			} // end rep
//			cout << endl;
		} // end rep
		printf ("%d %d\n", B, W );
	} // end loop

//	printf ("%d\n", res );
		
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	int n, ans=1000;
	cin >> n;
	for(int i=1; i<n; i++){
		int a=0, b=0;
		int s=i, t=n-i;
		for(int j=0; j<7; j++){
			a+=(t%10);
			t/=10;
			b+=(s%10);
			s/=10;
		}
		ans=min(ans, a+b);
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main() {
 int n ;cin>>n;
 string s;cin>>s;
 int l = s.length();
 string res = "";
 if(l > n)
 {
     res = s.substr(0,n);
     res+="...";
     cout<<res<<endl;
 }
 else
    {
        cout<<s<<endl;
    }
return 0;
}

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

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

int main(){
    int X;
    cin >> X;
    int ans = 0;
    //500円にできるだけ両替
    ans += 1000 * (X / 500);
    X %= 500;
    //5円にできるだけ両替
    ans += 5 * (X / 5);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>

using namespace std;

int main(){
  	int N;
  	double D;
  	cin >> N >> D;
  	int counter = 0;
  	for(int i=0;i<N;i++){
      	double x, y;
     	cin >> x >> y;
      	if(x*x+y*y <= D*D){
          	counter++;
        }
    }
  	cout << counter << endl;
}

Measured memory_bytes: 3768
#include <iostream>
using namespace std;
int main(){
	int n,g,ans=0;
	while(cin>>n){
	for(int a=0;a<=9;a++){
		for(int b=0;b<=9;b++){
			for(int c=0;c<=9;c++){
				for(int d=0;d<=9;d++){
					g=a+b+c+d;
					if(g==n)ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	ans=0;
	}
	return 0;
}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            char[] X = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

            int l = S.Length;

            string ans = "";

            for (int i = 0; i < l; i++) {
                int index = Array.IndexOf(X, S[i]);
                //Console.WriteLine(index + N);
                ans += X[(index + N) % 26];
            }

            Console.WriteLine(ans);
        }
    }
}


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

int main() {
  int n;
  double ans = 0.0;
  cin >> n;
  
  rep(i, n) {
    int a;
    cin >> a;
    ans += 1.0/a;
  }
  ans = 1.0/ans;
  printf("%.16f\n", ans);
}

Measured memory_bytes: 3680
import java.util.Scanner;

public class Main {

	/** 100 */
	private static final int HUNDRED = 100;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int d = scanner.nextInt(), n = scanner.nextInt();
			int pow = 1;
			for (int i = 0; i < d; i++) {
				pow *= HUNDRED;
			}
			// 解説どおりの式で計算
			System.out.println((n + (n - 1) / (HUNDRED - 1)) * pow);
		}
	}
}


Measured memory_bytes: 35608
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define READ freopen("in.txt", "r", stdin)
#define ROUT freopen("out.txt", "w", stdout)
#define pb push_back
#define endl '\n'

#define REP(i,a,b) for(int i=a; i<=b; i++)
#define arrL(i,a,b) for(int i=a; i<b; i++)

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    ROUT;
}

void solve()
{
    int i, j, count, c;

    bool flag=true;

    string w;

    cin>>w;

    c=w.size();

    if(c%2!=0){
        flag=false;
    }
    else{

        for(i=0; i<w.size()-1; i++){

            count=1 ;

            if(w[i]=='0')
                continue;

            for(j=i+1; j<w.size(); j++){
                if(w[j]==w[i]){
                    w[j]='0';
                    count++;
                }
            }

            if(count%2!=0){
                flag=false;
                break;
            }
        }
    }

    if(flag==true)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

int main()

{
    ///fileIO();
    fasterIO();

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<math.h>
   
using namespace std;
   
void calc(int a[],int h,int n){
   
 for(int i=0;i<n;i++){
  
    h = h - a[i];
  
    if(h <= 0){
      cout << "Yes" << endl;
      return;
    }
  }
  
  cout << "No" << endl;
}
  
int main(){
  int h,n;
  cin >> h >> n;
  int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  
  calc(a,h,n);
  
  return 0;
  
}

Measured memory_bytes: 888
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

//逆元を求める関数
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;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

//nの階乗をpで割り切れる個数を求める
int64 g1(int64 n, int64 p) {
	if (n == 0) return 0;
	return n/p + g1(n/p, p);
}

//nの2重階乗をpで割り切れる個数を求める
//nが偶数の場合は
//n!! = {n / 2で割り切れる個数} + n/2 -> n = 0まで再起的に求める
//nが奇数の場合は
//n!! = n! / (n - 1)!!
int64 g2(int64 n, int64 p) {
	if (n % 2 == 1) {
		return g1(n, p) - g2(n - 1, p);
	}
	int64 res = g1(n / 2, p);
	if (p == 2) res += n / 2;
	return res;
}

void solve() {
		int64 n;
		cin >> n;
		int64 ans  = min(g2(n, 2), g2(n, 5));
		cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



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

int main() {
	char symbol[4]; int a = 0;
	for (int i = 0; i < 4; i++) {
		cin >> symbol[i];
	}
	for (int i = 0; i < 4; i++) {
		if (symbol[i] == '+') a += 1;
		else a -= 1;
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

struct Point {
    int first, second;
    size_t index;
    Point(int f=0, int s=0, size_t i=0): first(f), second(s), index(i) {}
    bool operator<(const Point &rhs) const {
        if (first != rhs.first) {
            return first < rhs.first;
        } else {
            return second < rhs.second;
        }
    }
};

int main() {
    size_t n;
    scanf("%zu", &n);

    vector<Point> S(n), T(n);
    for (size_t i=0; i<n; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);

        S[i].first = T[i].second = x;
        S[i].second = T[i].first = y;
        S[i].index = T[i].index = i;
    }

    sort(S.begin(), S.end());
    sort(T.begin(), T.end());

    size_t q;
    scanf("%zu", &q);

    for (size_t i=0; i<q; ++i) {
        int sx, tx, sy, ty;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);

        lp_queue<size_t> q;
        size_t x_lb=lower_bound(S.begin(), S.end(), Point(sx, sy))-S.begin();
        size_t x_ub=upper_bound(S.begin(), S.end(), Point(tx, ty))-S.begin();
        size_t y_lb=lower_bound(T.begin(), T.end(), Point(sy, sx))-T.begin();
        size_t y_ub=upper_bound(T.begin(), T.end(), Point(ty, tx))-T.begin();

        ptrdiff_t x_diff=x_ub-x_lb, y_diff=y_ub-y_lb;
        if (x_diff < y_diff) {
            for (size_t i=x_lb; i<x_ub; ++i) {
                int y=S[i].second;
                if (sy<=y && y<=ty)
                    q.push(S[i].index);
            }
        } else {
            for (size_t i=y_lb; i<y_ub; ++i) {
                int x=T[i].second;
                if (sx<=x && x<=tx)
                    q.push(T[i].index);
            }
        }

        while (!q.empty()) {
            printf("%zd\n", q.top());
            q.pop();
        }
        printf("\n");
    }

    return 0;
}

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

int main(){
    int n; cin >> n;
    map<int,int> mp;

    rep(i,n){
        int tmp; cin >> tmp;
        mp[tmp]++;
    }

    for(auto m:mp){
        if(m.second > 1){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, LL> P;
LL x[100000];
LL v[100000];
int main() {
	int N;
	LL C;
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> v[i];
	}
	vector<P> vs;
	LL prev = C;
	LL now = 0;
	for (int i = 0; i < N; i++) {
		now -= (prev - x[N - i - 1]);
		prev = x[N - i - 1];
		now += v[N - i - 1];
		vs.emplace_back(i, now);
	}
	sort(vs.begin(), vs.end());
	vector<P> us;
	us.push_back(vs[0]);
	for (int i = 1; i < N; i++) {
		if (us.back().second < vs[i].second) us.push_back(vs[i]);
	}
	prev = 0;
	now = 0;
	LL d = 0;
	LL ans = 0;
	for (int i = 0; i < N; i++) {
		d += (x[i] - prev);
		now -= (x[i] - prev);
		prev = x[i];
		now += v[i];
		int k = lower_bound(us.begin(), us.end(), P(N - 1 - i, 0)) - us.begin();
		ans = max(ans, now);
		if (k > 0) ans = max(ans, now + us[k - 1].second - d);
	}
	vs.clear();
	prev = 0;
	now = 0;
	for (int i = 0; i < N; i++) {
		now -= (x[i]-prev);
		prev = x[i];
		now += v[i];
		vs.emplace_back(i, now);
	}
	sort(vs.begin(), vs.end());
	us.clear();
	us.push_back(vs[0]);
	for (int i = 1; i < N; i++) {
		if (us.back().second < vs[i].second) us.push_back(vs[i]);
	}
	prev = C;
	now = 0;
	d = 0;
	for (int i = 0; i < N; i++) {
		d += (prev-x[N-1-i]);
		now -= (prev-x[N-1-i]);
		prev = x[N-1-i];
		now += v[N-1-i];
		int k = lower_bound(us.begin(), us.end(), P(N - 1 - i, 0)) - us.begin();
		ans = max(ans, now);
		if (k > 0) ans = max(ans, now + us[k - 1].second - d);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node{
  int key;
  int parent;
  int left;
  int right;
}node;
int main(){
  int i, n;
  node *N;
  scanf("%d",&n);
  N = malloc(sizeof(struct node)*(n+1));
  for(i = 1; i <= n; i++)
    scanf("%d",&N[i].key);
  for(i = 1; i <= n; i++){
    N[i].parent = N[i/2].key;
    N[i].left = N[2*i].key;
    N[i].right = N[2*i+1].key;
  }

  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ",i, N[i].key);
  if(i != 1) printf("parent key = %d, ",N[i].parent);
  if(2*i <= n)  printf("left key = %d, ",N[i].left);
  if(2*i+1 <= n) printf("right key = %d, ", N[i].right);
  printf("\n");
  }
  free(N);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll dp[MAX];
VV g;

ll calc(ll x){
    if(dp[x]!=-1) return dp[x];
    ll res = 0;
    Each(nxt,g[x]){
        chmax(res,calc(nxt)+1);
    }
    return dp[x] = res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;
    g.resize(n);
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        g[x].pb(y);
    }

    rep(i,n){
        dp[i] = -1;
    }

    ll ans=0;
    rep(i,n){
        chmax(ans,calc(i));
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 8576
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
bool iscard[1000001];
int dp[2][1000001];
int main(){
        int n,m;
        while(scanf("%d%d",&n,&m),(n|m)){
                memset(dp,0,sizeof(dp));
                memset(iscard,0,sizeof(iscard));
                for(int i = 0; i < m; i++){
                        int tmp;
                        scanf("%d",&tmp);
                        iscard[tmp] = true;
                }
                bool zero = iscard[0];
                int ans = -10000;
                for(int i = 1; i < n+1; i++){
                        if(iscard[i]){
                                dp[0][i] = dp[0][i-1] + 1;
                                dp[1][i] = dp[1][i-1] + 1;
                        }
                        else if(zero){
                                dp[1][i] = dp[0][i-1] + 1;
                        }
                        ans = max(ans,max(dp[0][i],dp[1][i]));
                }
                printf("%d\n",ans);
        }
        return 0;
}

Measured memory_bytes: 9824
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#V, E, r = map(int, input().split())
#INF = V * 10001

N, M = map(int, input().split())
ans = 0

if(N>1):
  ans += combinations_count(N, 2)
if(M>1):
  ans += combinations_count(M, 2)


print(int(ans))


Measured memory_bytes: 38636
#include <iostream>
#include <string.h>
#define M 1000003
#define L 13
using namespace std;
 
void insert(char* val);
bool find(char* val);
int h(int, int);
int getNumber(char);

char hashTable[M][L];
bool hashIsUsed[M];
int codes[4][L];
 
int main(){

int n;
char com[7];
char val[L];
int p[L];
p[0] = 1;
for(int i=1; i<L; i++){
p[i] = p[i-1] * 4;
}
	
for(int i=0; i<4; i++){
for(int j=0; j<L; j++){
    codes[i][j] = i * p[j]; 
}
}
 
cin >> n;
 
while(n--){
cin >> com;
cin >> val;
if(com[0] == 'i'){
insert(val);
}else if(com[0] == 'f'){
if(find(val) == true){
cout << "yes\n";
}else{
cout << "no\n";
}
}
}
 
return 0;
 
}
 
void insert(char* val){
 
int code = 0;
int p = 1;
	int len;
	int i;
	
for(i=0, len=strlen(val); i<len; i++){
code += codes[getNumber(*(val+i))][i];
}
 
int key;
for(int i=0; ;i++){
key = h(code,i);
if(hashIsUsed[key] != true){
    memcpy(hashTable[key],val,len);
    hashIsUsed[key] = true;
break;
}
}
 
}
 
bool find(char* val){
 
int code = 0;
int p = 1;
	int len;
	int i;
for(i=0, len=strlen(val); i<len; i++){
code += codes[getNumber(*(val+i))][i];
}
 
int key;
for(int i=0; ;i++){
key = h(code,i);
if(hashIsUsed[key] != true){
return false;
}else if(!strcmp(hashTable[key],val)){
return true;
}
}
 
return false;
 
}
 
int h(int code, int i){
return ((code % M) + i * (1 + (code % (M-1)))) % M;
}
 
int getNumber(char val){
  
return (val == 'A') ? 0 :
       (val == 'C') ? 1 :
       (val == 'G') ? 2 :
       (val == 'T') ? 3 : -1;
  
}

Measured memory_bytes: 14816
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
      	double n[] = new double[a];
      	double nam = 0;
      
      for(int i = 0;i < a;i++){
      	n[i] = in.nextInt();
      }
      Arrays.sort(n);
      
      for(int i = 0;i<a;i++){
       if(i==0){nam = (n[i]+n[i+1])/2;}
      else if(i>1){nam = (nam+n[i])/2;}
      }
      System.out.print(nam);
      
	}
}

Measured memory_bytes: 23636
// 2011/09/08 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int W[10];
	for(int i=0; i<10; i++)
		cin >> W[i];

	int K[10];
	for(int i=0; i<10; i++)
		cin >> K[i];

	for(int i=0; i<9; i++)
		for(int j=i+1; j<10; j++)
			if(W[i]<W[j]){
				int tmp = W[i];
				W[i] = W[j];
				W[j] = tmp;
			}

	for(int i=0; i<9; i++)
		for(int j=i+1; j<10; j++)
			if(K[i]<K[j]){
				int tmp = K[i];
				K[i] = K[j];
				K[j] = tmp;
			}

	cout << W[0]+W[1]+W[2] << ' ' << K[0]+K[1]+K[2] << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_B&lang=jp

#define MAX 500
#define NIL -1

struct Node {
    int l, r, p;
};

Node T[MAX];
int D[MAX];
int H[MAX];

static int getSib(int u) {
    if (T[u].p==NIL) return NIL;
    if (T[T[u].p].l != NIL && T[T[u].p].l != u)
        return T[T[u].p].l;
    if (T[T[u].p].r != NIL && T[T[u].p].r != u)
        return T[T[u].p].r;
    return NIL;
}

static void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].p);
    printf("sibling = %d, ", getSib(u));
    printf("degree = %d, ", (T[u].l!=NIL)+(T[u].r!=NIL));
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
    if (T[u].p == NIL) cout << "root" << "\n";
    else if (T[u].l==NIL && T[u].r==NIL)cout << "leaf" << "\n";
    else cout << "internal node" << "\n";
}


static void setDepth(int u, int d) {
    if (u==NIL) return;
    D[u] = d;
    setDepth(T[u].l, d+1);
    setDepth(T[u].r, d+1);
}

static int setHeight(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].l != NIL)
        h1 = setHeight(T[u].l) + 1;
    if (T[u].r != NIL)
        h2 = setHeight(T[u].r) + 1;
    return H[u] = max(h1, h2);
}

int main() {
    int n; cin >> n;
    REP(i, n) T[i].l = T[i].r = T[i].p = NIL;
    REP(i, n) {
        int id, l, r; cin >> id >> l >> r;
        T[id].l = l;
        T[id].r = r;
        if (l!=NIL) T[l].p = id;
        if (r!=NIL) T[r].p = id;
    }

    int root = 0;
    REP(i, n) if (T[i].p==NIL)root = i;
    setDepth(root, 0);
    setHeight(root);
    REP(i, n) print(i);

    return 0;
}


Measured memory_bytes: 3220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long k = sc.nextLong();
		int n = sc.nextInt();
		long[] list = new long[n];
		long b = sc.nextLong();
		long f = b;
		for(int i = 0; i < n-1; i++) {
			long now = sc.nextLong();
			list[i] = now - b;
			b = now;
		}
		list[n-1] = k - b + f;
		Arrays.sort(list);
		System.out.println(k - list[n-1]);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

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

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

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

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

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

}


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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(C<=A){
        cout << C+ B << endl;
    }
    else{
        if(A+B>=C) cout << B+C << endl;
        else{
            cout << A+B+B+1 << endl;
        }
    }


    return 0;
}


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

const int max_n=7368792;
bool is_prime[max_n];
int sieve(int m,int n){
    int cnt=0;
    FOR(i,m,max_n+1){
        if(!is_prime[i]){
            ++cnt;
            for(int j=i;j<=max_n;j+=i) is_prime[j]=true;
        }
        if(cnt==n) break;
    }
    FOR(i,m,max_n+1)if(!is_prime[i]) return i;
}
int main(){
    int m,n;
    while(cin>>m>>n,m){
        memset(is_prime,0,sizeof(is_prime));
        cout<<sieve(m,n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 10308
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int (i)=int (a);i<=int (b);i++)
#define int long long
int a,b;
int finxor(int n){
	int m=n%4;
	if(m==0){
		return n;
	}
	else if(m==1){
		return 1;
	}
	else if(m==2){
		return n+1;
	}
	else return 0;
}
int findxor(int a,int b){
	return finxor(a-1)^finxor(b);
}
signed main(){
	cin>>a>>b;
	if(a==b){
		cout<<a;
		return 0;
	}
	a=max(a,(int)1);
	cout<<findxor(a,b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000000
#define P1 31
#define P2 37
#define M  1000000007
#define M2 1000000009
#define pii pair<ll,ll>
typedef long long ll;
using namespace std;
const int N = 255001;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
const long double TAU = 2*PI;

int h,w,cc;
char g[22][22];

bool gn(int ctr,int x, int y){
    if(g[x][y]=='#')ctr--;
    if(ctr==0)return 1;
    if(x<h-1)if(gn(ctr,x+1,y))return 1;
    if(y<w-1)if(gn(ctr,x,y+1))return 1;
    return 0;
}

signed main(){
    cin >> h >> w;
    for(int i = 0 ; i < h ; i++){
        scanf(" %s", g[i]);
        for(int j = 0 ; j < w ; j++){
            cc+=(g[i][j]=='#');
        }
    }
    if(gn(cc,0,0))return puts("Possible"),0;
    puts("Impossible");




}


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

int main(){

int x, n;
cin >> x >> n;
vector<int> p(110);
rep(i,n) cin >> p[i+1];

if(n==0){
    cout << x << endl;
    return 0;
}

for(int i=0; i<=110; i++){
    bool aru=false;
    for(int j=1; j<=n; j++) {
        if(x-i == p[j]) {
        aru=true;
        }
    }
    if(!aru) {
        cout << x-i << endl;
        return 0;
    }
    aru=false;
    for(int j=1; j<=n; j++) {
        if(x+i == p[j]) {
        aru=true;
        }
    }
    if(!aru) {
        cout << x+i << endl;
        return 0;
    }
}

}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main(){
	char s[200],scp[100],p[100];

	scanf("%s",&s);
	scanf("%s",&p);
	strcpy(scp, s);
	strcat(s,scp);

	if(strstr(s,p) == NULL)
	{printf("No\n");
	}else{
		printf("Yes\n");
	}
 return 0;
} 


Measured memory_bytes: 2692
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, M, K, A;
  cin >> N >> M;
  int ans = 0;

  vector<pair<int, int>> p(M);
  for (int i = 0; i < M; i++) {
    p[i] = make_pair(i, 0);
  }

  for (int i = 0; i < N; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> A;
      p[A-1].second += 1;
    }
  }

  for (int i = 0; i < M; i++) {
    if(p[i].second == N)ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596