akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int n;
int a[110000];
int f[110000];

int LIS(int n)
{
    int res = 0;
    int max1 = 0;
    for(int i = 1; i < n; ++i)
    {
        if(a[i] <= a[i - 1]) {
        	res++;
			max1 = max(max1,res);
		}else{
			
			res = 0;
		}
    }
    return max1;
}


int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%d",&a[i]);
	int ans = LIS(n);
	cout << ans << endl;
    return 0;
}



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

int ctoi(char c) {return c-'0';}
int stoi3dig(const char*str){
  if(!str[1] || !str[2]) return 0;

  int d1 = ctoi(str[0]) * 100;
  int d2 = ctoi(str[1]) * 10;
  int d3 = ctoi(str[2]);

  return d1 + d2 + d3;
}

int main(void) {
  char S[11];
  scanf("%s", S);

  int n = strlen(S);
  int diff = 1000;
  for(int i=0;i<n - 2;i++) {
    int found = stoi3dig(&S[i]);
    if( abs(found - 753) < diff ) {
      diff = abs(found - 753);
    }
  }
  printf("%d\n", diff);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int n, i, ans=1;
  string str;
  cin>>n>>str;

  for(i=1; i<str.length(); i++)
    if(str[i]!=str[i-1])
      ans++;

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


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		if(n < 105) {
			System.out.println(0);
		}else if(n < 135) {
			System.out.println(1);
		}else if(n < 165) {
			System.out.println(2);
		}else if(n < 189){
			System.out.println(3);
		}else if(n < 195){
			System.out.println(4);
		}else {
			System.out.println(5);
		}
		in.close();

	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  string t, s, r;
  cin >> t >> s >> r;
  
  
  cout << "A" << s[0] << "C" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> vs(h, "");
    for (int i = 0; i < h; i++) {
        cin >> vs[i];
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (vs[i][j] == '.') continue;
            int flag = 0;
            if (i > 0 && vs[i - 1][j] == '#') flag = 1;
            if (j > 0 && vs[i][j - 1] == '#') flag = 1;
            if (i + 1 < h && vs[i + 1][j] == '#') flag = 1;
            if (j + 1 < w && vs[i][j + 1] == '#') flag = 1;
            if (flag == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3580
#include<stdio.h>
int main()
{
	int p[5],t,i;
	for(i=0;i<5;i++)
		scanf("%d",&p[i]);
	t=p[0]<p[1]?p[0]<p[2]?p[0]:p[2]:p[1]<p[2]?p[1]:p[2];
	t+=p[3]<p[4]?p[3]:p[4];
	printf("%d\n",t-50);
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int n;
int a[200001],dp[200001];
vvl g(200001);
vl ans(200001);
void dfs(int node, int pre_node){
    ans[node] = lower_bound(dp, dp+n, INF) - dp;
    for(auto nv:g[node]){
        if(nv == pre_node)continue;
        //LIS
        auto itr = lower_bound(dp, dp+n, a[nv]);
        int pre_num = *itr;
        *itr = a[nv];
        dfs(nv, node);
        *itr = pre_num;
    }
}
signed main()
{   
    cin >> n;
    rep(i,n)cin>>a[i];
    rep(i,n)dp[i] = INF;

    rep(i,n-1){
        int u,v; cin >> u >> v;
        u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dp[0] = a[0];
    dfs(0, -1);
    
    rep(i,n)out(ans[i]);

    return 0;
}

Measured memory_bytes: 28776
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string a,b;
ll n,ans,k;
ll ds(int uke){
	int now=0;
	for (int s=uke; s<n; s++){
		if (a[s]!=b[now]) break;
		now++;
	}
	return now;
}
int main(){
    scanf("%lld",&n);
    cin>>a>>b;
    ans=n*2;
    for (int s=0; s<n; s++){
    	k=ds(s);
		ans=min(ans,n*2-k);
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	s += s;
	int n = s.size();
	vector<set<int>> is(26);
	rep(i, n) {
		is[s[i] - 'a'].insert(i);
	}
	bool ok = true;
	int k = t.size();
	int pos = 0;
	ll ans = 0;
	rep(i, k) {
		int c = t[i] - 'a';
		if (is[c].size() == 0) {
			ok = false;
			break;
		}
		auto itr = is[c].lower_bound(pos);
		if (itr == is[c].end()) {
			ans += n - pos + *is[c].begin() + 1;
			pos = *is[c].begin() + 1;
		}
		else {
			ans += *itr - pos + 1;
			pos = *itr + 1;
		}
	}
	if (ok) cout << ans << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 9964
#include<iostream>
#include<algorithm>
#include <math.h>
#include <cmath>
using namespace std;
#define ll long long

int H, W;
char s[60][60];
int dx[4] = { 1, -1, 0 ,0 };
int dy[4] = { 0, 0,  1 ,-1 };

int main()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++) {
			cin >> s[i][j];
		}
	}

	bool ans = true;
	
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (s[i][j] == '#') {
				bool found = false;
				for (int k = 0; k < 4; k++)
				{
					int i2 = i + dx[k];
					int j2 = j + dy[k];

					if (i2 >= 0 && i2 < H && j2 >= 0 && j2 < W && s[i2][j2] == '#') {
						found = true;
					}
				}
				if (!found) {
					ans = false;
				}
			}
			
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;

	}
	
}


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

int main(){
	char y[10];
	for(int i=0; i<10; i++) cin >> y[i];
	int a = (y[5] - '0') * 10 + (y[6] - '0');
	cout << (a<=4?"Heisei":"TBD") << endl;
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  set<string> st;
  string prev = "!";
  vector<string> s(N);
  rep(i, N) {
    cin >> s[i];
  }
  rep(i, N) {
    if (st.count(s[i])) {
      cout << "No\n";
      return 0;
    }
    if (prev.back() != '!' && prev.back() != s[i][0]) {
      cout << "No\n";
      return 0;
    }
    prev = s[i];
    st.insert(s[i]);
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include<iostream>
#include<vector>
using namespace std;
int main() {
    int h,w;
    cin>>h>>w;
    vector<vector<string> >vec;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            string s;
            cin>>s;
            if(s=="snuke"){
                cout<<char('A'+j)<<i+1<<endl;
                
            }
        }
    }
    return 0; 
}


Measured memory_bytes: 256
import sys
from itertools import combinations, permutations

def solve():
    input = sys.stdin.readline
    X = int(input())
    all100 = X // 100
    if X - all100 * 100 > 5 * all100: print(0)
    else: print(1)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int stoi (string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}


// 配列の総和
// greater


ll H[101010];
ll dp[101010];

int main(){	
	// ll A;
    // cin >> A;
	// cout << "hello" << endl;
	// cout << stoi("14") << endl;
	// cout << max({1,3}) << endl;
	ll N;
	cin >> N;
	rep(i, N)cin >> H[i];
	dp[0] = 0;
	dp[1] = abs(H[1] - H[0]);
	rep(i, N-2)dp[2+i] = min(
		dp[i]+abs(H[i+2]-H[i]), 
		dp[i+1]+abs(H[i+2]-H[i+1])
	);
	cout << dp[N-1] << endl;

}








Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>

int main()
{
    long long n{}, k{};
    std::cin >> n >> k;
    const auto a1 = n % k;
    const auto a2 = std::abs(a1 - k);
    std::cout << std::min(a1, a2) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    ll X,Y;
    cin >> X >> Y;

    ll x = X;
    ll num = 1;
    while(x*2 <= Y){
        num++;
        x = x*2;
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author __shangu__
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CStreamline solver = new CStreamline();
        solver.solve(1, in, out);
        out.close();
    }

    static class CStreamline {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt(), a[] = new int[m], diff[] = new int[m];
            if (n >= m) {
                out.println(0);
                return;
            }
            --n;
            for (int i = 0; i < m; ++i) a[i] = in.nextInt();
            Arrays.sort(a);
            for (int i = 1; i < m; ++i) diff[i] = a[i] - a[i - 1];
            Arrays.sort(diff);
            int ans = 0;
            for (int i = 0; i < n; ++i) ans += diff[m - 1 - i];
            out.println(a[m - 1] - a[0] - ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

#define ll long long int
#define vi vector<int>

int main() {

    ll N, M;

    cin >> N >> M;

    ll A;
    ll sum = 0;
    for (int i = 0; i < M; ++i) {
        cin >> A;
        sum += A;
    }

    if (sum <= N) {
        cout << N - sum << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    char[] words = line.toCharArray();
    for (int i = 0; i < line.length(); i++) {
      if (i % 2 == 0) {
        System.out.print(words[i]);
      }
    }

  }
}

Measured memory_bytes: 30640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


struct BIT {
    ll N;
    vector<ll> bit;
    BIT(ll N):N(N) {
        /* BITは[1..N]で扱う */
        bit.resize(N + 1, 0);
    }
    
    void add(int x, ll val){
        while (x <= N) {
            bit[x] += val;
            x += x & -x;
        }
    }
    
    ll sum(int x){
        ll ret = 0;
        if(x == 0) return ret;
        while (x) {
            ret += bit[x];
            x &= (x - 1);
        }
        return (ret);
    }
    // [l,r]
    ll sum(int l,int r){
        return sum(r) - sum(l-1);
    }
};
template<class Type>
Type solve(Type res = Type()){
    int N,Q; cin >> N >> Q;
    BIT bit(N);
    for(int i = 1; i <= N;i++){
        ll a; cin >> a;
        bit.add(i,a);
    }
    while(Q--){
        int com; cin >> com;
        if(com == 0){
            int p; ll x; cin >> p >> x;
            bit.add(p+1,x);
        }else{
            int l,r; cin >> l >> r;
            cout << bit.sum(l+1,r) << endl;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    solve<ll>(0);
    // cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

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

using namespace std;

class DisjointSet{
	public:
		vector<int> rank, p;

		DisjointSet(){}
		DisjointSet(int size){
			rank.resize(size,0);
			p.resize(size,0);
			for(int i=0;i<size;i++) makeSet(i);
		}

		void makeSet(int x){
			p[x] = x;
			rank[x] = 0;
		}

		bool same(int x, int y){
			return findSet(x) == findSet(y);
		}
		void unite(int x, int y){
			link(findSet(x), findSet(y));
		}

		void link(int x, int y){
			if(rank[x] > rank[y]){
				p[y] = x;
			}else{
				p[x] = y;
				if(rank[x] == rank[y]){
					rank[y]++;
				}
			}
		}

		int findSet(int x){
			if(x != p[x]){
				p[x] = findSet(p[x]);
			}
			return p[x];
		}
};

int main(){
	int n, a, b, q;
	int t;

	cin >> n >> q;
	DisjointSet ds = DisjointSet(n);

	for(int i=0;i<q;i++){
		cin >> t >> a >> b;
		if(t == 0) ds.unite(a,b);
		else if(t==1){
			if(ds.same(a,b)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
	return 0;
}

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

int main(void)
{
    int height[10];
    for(int i = 0; i < 10; i++)
    {
        scanf("%d", &height[i]);
    }
    for(int i = 0; i < 9; i++)
    {
        for(int j = i + 1; j < 10; j++)
        {
            if(height[i] < height[j])
            {
                int tmp = height[i];
                height[i] = height[j];
                height[j] = tmp;
            }
        }
    }
    
    for(int i = 0; i < 3; i++)
    {
        printf("%d\n", height[i]);
    }
}



Measured memory_bytes: 2124
N = int(input())
table = []

for i in range(N):
    A = int(input())
    dic = {}
    for j in range(A):
        x,y = map(int, input().split())
        dic[x-1] = y
    table.append(dic)       

res = 0
for i in range(2**N):
    bi = [j for j in range(N) if (i >> j &1)]
    dic = {}
    for b in bi:
        dic[b] = 1
    
    endfor = False
    for b1 in bi:
        if endfor:
            break
        said = table[b1]
        for k in said.keys():
            if k not in dic.keys():
                if said[k]:
                    endfor = True
                    break
                dic[k] = said[k]
            elif dic[k] == said[k]:
                continue
            else:
                endfor = True
                break
    if not endfor:
        res = max(res, len(bi))

print(res)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 10;
int a[NMAX];
vector<int>edge[NMAX];
int cal(int i)
{
	for(register int j = 0;j < edge[i].size();j++)
		if(a[i] <= a[edge[i][j]])
			return 0;
	return 1;
}
int main(int argc, char const *argv[])
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(register int i = 1;i <= n;i++)	scanf("%d",a+i);
	while(m--)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	int ans = 0;
	for(register int i = 1;i <= n;i++)
		ans += cal(i);
	printf("%d\n",ans );
	return 0;
}


Measured memory_bytes: 9236
A,B,K = map(int,input().split())

s=set()

for i in range(K):
  if A+i<=B:
    s.add(A+i)
  if B-i>=A:
    s.add(B-i)
#print(s)

lis=sorted(s)
for item in lis:
  print(item)

Measured memory_bytes: 3060
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
l=[]
l.append(['*']*(w+1))
for i in range(h):
    l1=s[i]
    l1.insert(0,'*')
    l1.append('*')
    l.append(l1)
l.append(['*']*(w+1))

for i in range(1,h+1):
    for j in range(1,w+1):
        c=0
        if l[i][j]=='.':
            c+=l[i-1][j-1:j+2].count('#')
            c+=l[i][j-1:j+2].count('#')
            c+=l[i+1][j-1:j+2].count('#')
            l[i].pop(j)
            l[i].insert(j,str(c))
            
for i in range(1,h+1):
    print(''.join(l[i][1:w+1]))

Measured memory_bytes: 3188
package main

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

func solve() {
	n, m := getInt(), getInt()

	ans := "No"
	if n <= m {
		ans = "Yes"
	}

	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
struct data{
  int val;
  int id;	
}a[100010];
int num[31];
bool cmp(data x,data y)
{
	return x.val<y.val;
}
bool cmp1(data x,data y)
{
	return x.id<y.id;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	  {
	  	scanf("%d",&a[i].val);
	  	a[i].id=i;
	  }
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
	  {
	  	a[i].val=i;
	  }
	sort(a+1,a+1+n,cmp1);
	for(int i=1;i<=n;i++)
	  {
	  	if(a[i].val%2!=i%2)
	  	  num[a[i].val%2]++;
	  }
	cout<<num[1];
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 200005;

int N;
struct Number {
	int val, idx;
	int ans;
}A[MaxN + 5];

bool cmp_val(Number X, Number Y ) {
	return X.val < Y.val;
}

bool cmp_idx(Number X, Number Y ) {
	return X.idx < Y.idx;
}

int main()
{
	while(scanf("%d", &N) != EOF)
	{
		for(int i = 1; i <= N; i++) {
			scanf("%d", &A[i].val);
			A[i].idx = i;
		}
		sort(A + 1, A + N + 1, cmp_val);
		for(int i = 1; i <= N; i++) {
			if(i <= N / 2) {
				A[i].ans = A[N / 2 + 1].val;
			}
			else {
				A[i].ans = A[N / 2].val;
			}
		}
		sort(A + 1, A + N + 1, cmp_idx);
		for(int i = 1; i <= N; i++)
			printf("%d\n", A[i].ans);
	}
	return 0;
}

Measured memory_bytes: 4480
#include <stdio.h>

int main(void) {
    int a, b, result;
    scanf("%d %d", &a, &b);
    
    if(a > b){
        result = a + (a-1);
    }else if(a == b){
        result = a + b;
    }else{
        result = b + (b-1);
    }
    printf("%d", result);
    return 0;
}


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

using namespace std;

int main(void){
    string s;

    cin >> s;

    if(s[0]==s[1]&&s[1]==s[2])cout << "Yes" << endl;
    else if(s[1]==s[2]&&s[2]==s[3])cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as P
M=10**9+7
n,k=map(int,input().split())
a=P.matrix([list(map(int,input().split()))for i in[0]*n],dtype='O')
b=P.eye(n,dtype='O')
while k:b=[b,b*a%M][k&1];a=a*a%M;k>>=1
print(b.sum()%M)

Measured memory_bytes: 14460
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9){
        cout<<"hon"<<endl;
    }
    else if(n%10==0||n%10==1||n%10==6||n%10==8){
        cout<<"pon"<<endl;
    }
    else cout<<"bon"<<endl;
}


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

using namespace std;

int n,i,j,t,m,c,a,b;
string s;

int main(){
    scanf("%d %d", &a, &b);
    cin>>s;
	if(s[a]=='-'){
		for(i=0;i<a;i++)
			if(s[i]=='-'){
				puts("No");
				return 0;
			}
		for(i=a+1;i<=a+b;i++){
			if(s[i]=='-'){
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
	else 
		puts("No");
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int a = 0;
	

	if (s[0] == '1') { a++; }
	if (s[1] == '1') { a++; }
	if (s[2] == '1') { a++; }
	cout << a<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 250

int main(){
  int h,i;
  int a[MAX+1];

  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&a[i]);
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(i/2 >= 1) printf("parent key = %d, ",a[i/2]);
    if(i*2 <= h) printf("left key = %d, ",a[i*2]);
    if(i*2+1 <= h) printf("right key = %d, ",a[i*2+1]);
    printf("\n");
  }
  return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

ll a,b,n;

main()
{
    cin>>n>>a>>b;

    if(abs(a-b)%2==0)
    {
        cout<<abs(a-b)/2<<endl;
        return 0;
    }

    ll ans=1;
    if(a>b)swap(a,b);

    ans+=min(a-1,n-b);
    ans+=(abs(a-b)-1)/2;
    cout<<ans<<endl;

}

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

int main(){
  int N;
  cin>>N;
  
  if(N==1){
    cout<<"Hello World"<<endl;
  }
  else if(N==2){
    int A,B;
    cin>>A>>B;
    
    cout<<A+B<<endl;
  }
}
          


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();

		int[] a = new int[N];
		for (int i = 0; i < M; i++) {
			int K;
			K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int S;
				S = sc.nextInt();
				S--;
				a[S] |= 1 << i;		//1を左にiビットシフト
			}
		}

		int p = 0;
		for (int i = 0; i < M; i++) {
			int x;
			x = sc.nextInt();
			p |= x << i;
		}

		int t = 0;
		int ans = 0;
		for (int s = 0; s < (1 << N); s++) {	//s < (1 << N); ... 1 << N(N = 3だとすると) 000から111まで回す。
			t = 0;
			for (int i = 0; i < N; i++) {
				if ((s >> i & 1) == 1) {	//iビット目が立っているかを判定
					t ^= a[i];
				}
			}
			if (t == p) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main() {
	int N;
	int L[2000];
	int i, j, t;
	int a, b, c;
	int A, B, C;
	int cnt = 0;
	scanf("%d", &N);

	for(i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}

	for(i = 0; i < N - 1; i++) {
		for(j = i + 1; j < N; j++) {
			if(L[i] > L[j]) {
				t = L[i];
				L[i] = L[j];
				L[j] = t;
			}
		}
	}
	

	for(a = 0; a < N; a++) {
		A = L[a];
		for(b = a+1; b < N; b++) {
			B = L[b];
			for(c = b+1; c < N; c++) {
				C = L[c];
				if(C >= A + B) {
					break;
				}
				cnt++;
			}
		}
	}

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

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

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

ll a[100010][3], dp[100010][3];

int main() {
  int N;
  cin >> N;
  rep(i, N) rep(j, 3) cin >> a[i][j];

  rep(i, N) rep(j, 3) rep(k, 3) {
    if (j == k) continue;
    chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
  }

  cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
//#include <iostream>
//#include <vector>
//#include <string>
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;

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

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




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

	lint n, y; cin >> n >> y;
	rep_(i, n) {//\10000*i 
		rep_(j, n - i) {
			if (n-i-j>=0&&10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
				cout << i << sp << j << sp << n - i - j << el;
				gc();
				return 0;
			}
		}
	}
	co("-1 -1 -1");
	gc();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int K = 3;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> e[K*n];
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        for (int j = 0; j < K; j++) {
            e[j*n+u].push_back((j+1)%K*n+v);
        }
    }
    int s, t;
    cin >> s >> t;
    s--, t--;

    int d[3*n];
    for (int i = 0; i < 3 * n; i++) {
        d[i] = -3;
    }
    d[s] = 0;

    queue<int> q;
    q.push(s);

    while (!q.empty()) {
        int x = q.front();
        q.pop();

        for (int y : e[x]) {
            if (d[y] == -3) {
                d[y] = d[x] + 1;
                q.push(y);
            }
        }
    }

    cout << d[t] / 3 << endl;

    return 0;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

int t=0;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    int x, n;
    cin>>x>>n;
    int x1=0,y1=101;
    int xx;
    vi v(103,0);
    rep(i,n)
    {
        cin>>xx;
        v[xx]=1;
    }
    if(v[x]==0)
    {
        cout<<x<<endl;
        return;
    }
    repd(i,x-1,0)
    {
        if(v[i]==0)
        {
            x1=i;
            break;
        }
    }
    repu(i,x+1,101)
    {
        if(v[i]==0)
        {
            y1=i;
            break;
        }
    }
    if(x-x1<=y1-x)
    {
        cout<<x1<<endl;
    }
    else
        cout<<y1<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("ggg.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3844
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    sc.close();

    int[][] dp = new int[s.length() + 1][t.length() + 1];
    for (int si = 1; si < s.length() + 1; si++)
      for (int ti = 1; ti < t.length() + 1; ti++)
        dp[si][ti] = s.charAt(si - 1) == t.charAt(ti - 1)
            ? dp[si - 1][ti - 1] + 1
            : Math.max(dp[si - 1][ti], dp[si][ti - 1]);

    char[] buf = new char[dp[s.length()][t.length()]];
    int bi = buf.length - 1;
    int tail = t.length();
    for (int si = s.length(); 0 < si; si--)
      for (int ti = tail; 0 < ti; ti--)
        if (dp[si][ti - 1] < dp[si][ti]) {
          if (s.charAt(si - 1) == t.charAt(ti - 1)) {
            buf[bi] = t.charAt(ti - 1);
            bi--;
            tail = ti - 1;
          }
          break;
        }

    System.out.println(new String(buf));
  }
}

Measured memory_bytes: 81412
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=[]
    for i in range(3):
        A.append(input())
        
    ans=0
    for i in range(N):
        t=set([])
        for j in range(3):
            t.add(A[j][i])
        ans+=len(t)-1
        
    print(ans)
        

main()


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

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

const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  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;
  }
 
  // for prime mod
  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; }

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

    int zero = 0;
    map<pair<ll,ll>,P> m;

    for (int i=0; i<n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) {
            zero++;
            continue;
        }
        ll g = __gcd(x, y);
        x /= g;
        y /= g;
        if (y < 0 || (y == 0 && x < 0)) {
            x = -x;
            y = -y;
        }
        if (x > 0) {
            m[make_pair(x,y)].first++;
        } else {
            m[make_pair(y,-x)].second++;
        }
    }

    mint ans = 1;
    for (auto i : m) {
        int s = i.second.first;
        int t = i.second.second;
        ans *= (mint(2).pow(s) - 1 + mint(2).pow(t) - 1 + 1);
    }
    ans -= 1;
    ans += zero;
    cout << ans << endl;
}


Measured memory_bytes: 15892
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int cost(int* A, int n, int* dp)
{
    if (n == 1)
    return dp[1];
    if (n == 2)
    return dp[2];
    if (n == 3)
    return dp[3];
    if (dp[n]!=(-1))
    return dp[n];
    else
    {
     dp[n] = min(cost(A,n-1,dp) + abs(A[n]-A[n-1]),cost(A,n-2,dp)+abs(A[n]-A[n-2]));
     return dp[n];   
    }
}

int main()
{
    int A[100001],n,i,dp[100001],min;
    cin >> n;
    for (i=0; i<n+1; i++)
    dp[i] = -1;
    for (i=1; i<=n; i++)
    {
        cin >> A[i];
    }
    dp[1] = 0;
    dp[2] = abs(A[2]-A[1]);
    dp[3] = abs(A[3]-A[1]);
    min = cost(A,n,dp);
    cout << min;
    return 0;
}

Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0093
???????????´
"""
import sys
from calendar import isleap

def is_leap(year):
    ''' ?????????????????´??? ???????????´ ???????????????True/False??§?????? (callendar.isleap(year) ??¨??????) '''
    if year % 400 == 0:
        return True
    elif year % 100 == 0:
        return False
    elif year % 4 == 0:
        return True
    else:
        return False


def main(args):
    is_first__dataset = True  # 2????????\?????????????????????????????´?????????????????????????????????????????\???????????????????????°
    leap_years = []  # ???????????´????????????
    # ??????????????\???
    while True:
        start_year, end_year = [int(x) for x in input().strip().split(' ')]
        if start_year == 0 and end_year == 0:
            break
        else:
            # ???????????????
            leap_years = []
            for year in range(start_year, end_year+1):
                if isleap(year):  # calendar.isleap()????????¨
                    leap_years.append(year)

        # ???????????????
        if is_first__dataset == True:
            is_first__dataset = False
        else:
            print('')  # 2????????\????????????????????????????????§??????????????????????????\??????

        if len(leap_years) == 0:
            print('NA')
        else:
            print('{0}'.format('\n'.join(map(str, leap_years))))

if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 9028
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  string s;
  cin >> s;
  int cnt1 = 0, cnt2 = 0, n = s.size();
  for (int i = 0; i < n; i++) {
    if (i%2 == 0 && s[i] == '0') cnt1++;
    if (i%2 == 1 && s[i] == '1') cnt1++;
  }
  for (int i = 0; i < n; i++) {
    if (i%2 == 1 && s[i] == '0') cnt2++;
    if (i%2 == 0 && s[i] == '1') cnt2++;
  }
  cout << min(cnt1, cnt2) << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
int n,k,a[666666];
int gcd(int a, int b){return !b?a:gcd(b,a%b);}
int main() {
	read(n);read(k);rep(i,1,n)read(a[i]);
	sort(a+1,a+n+1);int g=0;rep(i,1,n)g=gcd(g,a[i]);
	if(k<=a[n]&&k%g==0)puts("POSSIBLE");else puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 640
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut A: Vec<usize> = sc.vec(N);
    A.sort_by_key(|&i| Reverse(i));
    let mut ans = A[0];
    for i in 1..N/2 {
        ans += 2 * A[i];
    }
    if N % 2 != 0 {
        ans += A[N/2];
    }
    println!("{}", ans);
}


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

bool is_p(int n) {
	int sqr = sqrt(n) + 1;
  	if(n == 1)return false;
  	if(n==2) return true;
  	for(int i = 2; i <= sqr; i++) {
    if(n%i == 0) return false;
    }
  return true;
}

int main() {
	int n; cin >> n;
	int ust = 0;
  for(int i = n; i <=2*n; i++) {
    if(is_p(i)) {cout << i << endl; break;}
  }



}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }

        b := 0
        c := map[int]int{0: 1}
        cnt := 0
        for _, a := range a {
                b = (b + a) % m
                if t, ok := c[b]; ok {
                        cnt += t
                        c[b]++
                        continue
                }
                c[b] = 1
        }
        fmt.Println(cnt)
}

Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x, y, ad=0;
  std::cin >> x >> y;
  if(abs(x) == abs(y)){
    std::cout << abs(abs(x) - abs(y)) + (x*y<0?1:0) << '\n';
    return 0;
  }
  if(abs(x) > abs(y)) {
    int t=x;
    x = -1*y, y = -1*t;
  };
  if(x<0){
    ad++;
    x*=-1;
  }
  if(y<0){
    ad++;
    y*=-1;
  }
  std::cout << y-x+ad << '\n';
  return 0;
}


Measured memory_bytes: 256