akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n;
	cin >> n;
	int count = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < n; j++) {
			int ans = i * j;
			if (ans < n) {
				count++;
			} else {
				break;
			}
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3584
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n;
vi a;

signed main(){
    I(n);
    a.resize(n);
    REP(i,n) I(a[i]);

    vpi best;
    REP(i,n) best.eb(a[i],i);
    sort(all(best));
    
    int ans = 0;
    REP(i,n){
        ans += abs(best[i].second - i) & 1; 
    }
    cout << ans/2 << endl;


}

Measured memory_bytes: 3188
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	vb b(n,false) ;
	ll ans = 0 ;
	ll cur = 0 ;
	while(1){
		if(cur==1) break ;
		if(b.at(cur)){
			cout << -1 << endl ;
			return 0 ;
		}
		ans++ ;
		b.at(cur) = true ;
		cur = a.at(cur)-1 ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

const int MSQ = sqrt(N) + 5;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	int n;
	cin>>n;
	string a;
	cin>>a;
	vector<set<int>> nxt(26);
	for(int i=0;i<n;i++){
		nxt[a[i]-'a'].insert(i+1);
	}
	int q;
	cin>>q;
	while(q--){
		int t;
		cin>>t;
		if (t==1){
			int p;
			char c;
			cin>>p>>c;
			p--;
			nxt[a[p]-'a'].erase(p+1);
			a[p]=c;
			nxt[c-'a'].insert(p+1);
		}
		else{	
			int l,r;
			cin>>l>>r;
			int ans=0;
			for(int i=0;i<26;i++){
				auto wa=nxt[i].lower_bound(l);
				if (wa!=nxt[i].end() && *wa<=r) 
                   		ans++;
			}
			cout<<ans<<"\n";
		}
	}
	
}		



Measured memory_bytes: 26268
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int ans = B / A > C ? C : B / A;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const [N, A, B] = lines[0].split(" ").map(v=>BigInt(v));
    console.log(calc(N, A, B).toString());
});
calc = (N, a, b)=>{
    if(abs(a,b)%2n==0n) return abs(a,b)/2n;
    if(a==1n) return min(b-1n, calc(N, a, b-1n)+1n);
    if(b==1n) return min(a-1n, calc(N, b, a-1n)+1n);
    if(a==N) return calc(N, N-a+1n, N-b+1n);
    if(b==N) return calc(N, N-a+1n, N-b+1n);
    if(a==b) return 0;
    if(a>b){
        return min(
            calc(N, a-(b-1n), 1n) + (b-1n),
            calc(N, N, b+(N-a)) + (N-a)
        );
    }else{
        return min(
            calc(N, a+(N-b), N) + (N-b),
            calc(N, 1n, b-(a-1n)) + (a-1n)
        );
    }
}
abs = (a,b)=>{return a<b?(b-a):(a-b)}
min = (...a)=>{return a.reduce((a,b)=>a<b?a:b, a[0])};
max = (a,b)=>{return a>b?a:b};


Measured memory_bytes: 30980
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h,w;
  cin >> h>>w;
  vector<string> v(h);
  rep(i,0,h)cin>>v[i];

  vector<bool> hb(h,false), wb(w,false);
  rep(i,0,h){
    int c = 0;
    rep(j,0,w){
      if(v[i][j]=='#')c++;
    }
    if(c==0)hb[i]=true;
  }

  rep(i,0,w){
    int c = 0;
    rep(j,0,h){
      if(v[j][i]=='#')c++;
    }
    if(c==0)wb[i]=true;
  }

  rep(i,0,h){
    if(hb[i])continue;
    rep(j,0,w){
      if(wb[j])continue;
      cout<<v[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3664
/*
 * I won't be broken
 * I won't be tortured
 * I won't be beaten down
 * I have the answer
 * I can take the pressure
 * I will turn it all around
 * Lift me up above this
 * The flames and the ashes
 * Lift me up and help me to fly away
*/
#include <bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
        scanf("%d%d%d",&n,&a,&b);
        if((abs(a-b))%2==0){
                printf("Alice\n");
        } 
        else
                printf("Borys\n");
        return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  reverse(a.begin(),a.end());
  bool p=true;
  for(int i=0;i<n-1;i++){
    if(a.at(i)+1<a.at(i+1)){
      p=false;
      break;
    }
    else if(a.at(i)+1==a.at(i+1)){
      a.at(i+1)-=1;
    }
  }
  if(p){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 640
A = int(input())
B = int(input())
C = int(input())
N = int(input())

ans = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if i*500 + j*100 + k*50 == N:
        ans += 1

print(ans)

Measured memory_bytes: 3060
n = int(input())
l = []
for x in range(0,n):
	l.append(input())
print(f'AC x {l.count("AC")}')
print(f'WA x {l.count("WA")}')
print(f'TLE x {l.count("TLE")}')
print(f'RE x {l.count("RE")}')


Measured memory_bytes: 16100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        CF_Reader in = new CF_Reader();

        final long MOD = 1000000007;
        long n = in.longNext();
        long a = in.longNext();
        long b = in.longNext();

        long binomial_nCr_summation = binpow_withMod(2, n, MOD) - 1 + MOD;
        long nCr_A = nCr_withMod(n, a, MOD);
        long nCr_B = nCr_withMod(n, b, MOD);
        out.println((binomial_nCr_summation - nCr_A - nCr_B + 2*MOD) % MOD);

        out.close();
    }

    static long binpow_withMod(long a, long b, long MOD) {
        long res = 1;
        while (b > 0) {
            if (b % 2 == 1) res = (res * a) % MOD;
            a = (a * a) % MOD;
            b /= 2;
        }
        return res;
    }

    static long nPr_withMod(long n, long r, long MOD) {
        long res = 1;
        for (long i = (n - r + 1); i <= n; i++) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static long nCr_withMod(long n, long r, long MOD) {
        long r_factorial = nPr_withMod(r, r, MOD);
        long first = nPr_withMod(n, r, MOD);
        long second = binpow_withMod(r_factorial, MOD-2, MOD);
        return  (first * second) % MOD;
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

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

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

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 22356
#include <stdio.h>

int n, A[50];

int solve (int i, int m) {
    if ( m == 0) return 1;
    if ( i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m -A[i]);
    return res;
}

int main () {
    int q, M, i;

    scanf("%d", &n);
    for ( i = 0; i < n; i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for ( i = 0; i < q; i++) {
        scanf("%d",&M);
        if (solve(0,M)) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define check system("pause")
#define all(x) (x).begin(),(x).end()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
const ll mod = 1e9+7;
const int N = 2e5+20;
#define dep(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mes(p,b) memset(p,b,sizeof(p))
#define sz(x) int(x.size())
ll b[N],a[N],n;
int main()
{
  	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n;
	rep(i,0,n) cin>>a[i];
	dep(i,n,0) b[i]=b[i+1]+a[i];
	ll lim=1,ans=0;
	rep(i,0,n){
		lim=min(lim,b[i]);
		ans+=lim;
		lim-=a[i];
		if(lim<0){
			cout<<-1;return 0;
		}
		lim<<=1;
	}
	cout<<ans;
  	return 0;
}



Measured memory_bytes: 5168
n = gets.chomp.to_i

root = Math.sqrt(n)
temp = 0
(1..root).to_a.each do |v|
  a, b = n.divmod(v)
  next if not b.zero?
  temp = a + v -2 if temp.zero?
  temp = temp > a + v -2 ? a + v -2 : temp
end

p temp

Measured memory_bytes: 9724
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = [readline().rstrip().decode() for _ in range(n)]
b = [readline().rstrip().decode() for _ in range(m)]
for y in range(n - m + 1):
    for x in range(n - m + 1):
        flag = True
        for i in range(m):
            for j in range(m):
                if a[i + y][j + x] != b[i][j]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

int n;

// char X[100][100];
// int dp[1000000001];
bool p[55556];

vector<int> ps;
vector<int> ans;

int main(void){
    cin >> n;
    // cout << p[0] << endl;
    REP(i,2,55556) {
        p[i] = false;
    }
    REP(i,2,sqrt(55555)+1) {
        if (!p[i]) {
            for(int j = i * 2; j <= 55555; j += i) {
                // cout << j << endl;
                p[j] = true;
            }
        }
        // break;
    }
    
    REP(i,2,55556) {
        if (!p[i]) {
            // cout << i << endl;
            ps.push_back(i);
        }
    }
    
    
    int count = 0;
    for(auto u: ps) {
        if (u % 5 == 1) {
            ans.push_back(u);
            count++;
        }
        if (count == n) {
            break;
        }
    }
    
    for (auto u: ans) {
        cout << u << " ";
    }
    cout << endl;

}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
int s[2005], t[2005];
int dp[2006][2006];
signed main() {
	int n, m; cin >> n >> m;
	rep(i, n)cin >> s[i];
	rep(i, m)cin >> t[i];
	rep(i, n + 1)dp[i][0] = 1;
	rep(i, m + 1)dp[0][i] = 1;
	rep(i, n) {
		rep(j, m) {
			if (s[i] == t[j])dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j];
			else dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j]+MOD;
			dp[i + 1][j + 1] %= MOD;
		}
	}
	cout << dp[n][m] << endl;
}

Measured memory_bytes: 31616
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  myout((one[0] == one[1]) ? "Yes" : "No");
}


Measured memory_bytes: 30076
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << "  " << y << endl
#define dbg3(x, y, z) cout << x << "  " << y << "  " << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    bool yes = true;
    int l = s.length();
    if(l%2){
        yes = false;
    }
    f(i, 0, l){
        if(i%2){
            if(s.at(i) != 'i'){
                yes = false;
            }
        }
        else if(s.at(i) != 'h'){
            yes = false;
        }
    }
    if(yes){
        dbg("Yes");
    }
    else{
        dbg("No");
    }
}

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

using namespace std;
int gcd(int x,int y){return y?gcd(y,x%y):x;}


int main(void){
  int n,t;
  vector <int> cities;
  int diff, gcdDiff = 0;
  
  cin >> n >> t;
  cities.push_back(t);
  for (int i=0; i<n; i++){
    cin >> t;
    cities.push_back(t);
  }
  sort(cities.begin(), cities.end());
  
  for (int i=0; i<n; i++){
    diff = cities[i+1] - cities[i];
    //cout << diff << " ";
    gcdDiff = gcd(gcdDiff, diff);
  }
  cout << gcdDiff << endl;
  
  return 0;
  
}


Measured memory_bytes: 892
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	int N,M;
	ArrayList<Integer>[] graph;

	@SuppressWarnings("unchecked")
	public void solve() {
		N = nextInt();
		M = nextInt();

		graph = new ArrayList[N];
		for(int i = 0;i < N;i++){
			graph[i] = new ArrayList<Integer>();
		}

		for(int i = 0;i < M;i++){
			int a = nextInt()-1;
			int b = nextInt()-1;

			graph[a].add(b);
			graph[b].add(a);
		}

		boolean flag = false;

		ArrayDeque<Long> q = new ArrayDeque<Long>();
		int[] dis = new int[N];
		Arrays.fill(dis, Integer.MAX_VALUE);

		q.add(0L);
		dis[0] = 0;

		while(q.size() > 0){

			long d = q.poll();
			int v = (int)(d / 1000000);
			int c = (int)(d % 1000000);

			if(c == 2 && v == N-1){
				flag = true;
				break;
			}

			if(c >= 3)continue;

			if(dis[v] < c)continue;
			dis[v] = c;

			for(int next : graph[v]){
				if(dis[next] > dis[v] + 1){
					q.add(next * 1000000L + (dis[v] + 1));
				}
			}
		}

		out.println(flag ? "POSSIBLE" : "IMPOSSIBLE");
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 83316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, s, b;
  in(n);
  vector<ll> c(n), d(100009, 0);
  rep(i, n){
    in(c[i]);
    d[c[i]]++;
  }
  rep(i, d.size()){
    if(d[i] > 1)
      d[i] = 1;
  }
  a = 0;
  rep(i, d.size()){
    if(d[i] == 1)
      a++;
  }
  if(a % 2 == 0)
    a--;
  out(a);
  memi;
}

Measured memory_bytes: 4840
import sys
from collections import deque, defaultdict
from itertools import combinations, permutations
from heapq import heapify, heappop, heappush

def solve():
    input = sys.stdin.readline
    H, N = map(int, input().split())
    M = [tuple(int(a) for a in input().split()) for _ in range(N)]
    DP = [1000000000] * (H + 2) #ダメージiを与えるのに必要な最小MP, DP[H+1]はH以上のダメージを与えた場合
    DP[0] = 0
    for i, m in enumerate(M):
        a, b = m
        for j in range(max(H-a+1, 0)): DP[j + a] = min(DP[j + a], DP[j] + b)
        for j in range(max(H-a+1, 0), H): DP[H + 1] = min(DP[H + 1], DP[j] + b)
    print(min(DP[H], DP[H + 1]))

    return 0

if __name__ == "__main__":
    solve()

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

int main() {
  int m1, d1;
  cin >> m1 >> d1;

  int m2, d2;
  cin >> m2 >> d2;

  if(m1!=m2){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int sonzai[52];
    int n;
    int i;
    char kindc[4]={'S','H','C','D'};
    char kind;
    int num;

    for(i=0;i<52;i++)sonzai[i]=0;

    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf(" %c %d ",&kind,&num );
        switch(kind) {
            case 'D':num+=13;
            case 'C':num+=13;
            case 'H':num+=13;
            //case 'S':num+=13;
        }
        sonzai[num-1]=1;
    }
    for(i=0;i<52;i++) {
        if(sonzai[i]==0)
            printf("%c %d\n",kindc[i/13],i%13+1);
    }
    return 0;
}

Measured memory_bytes: 1784
import sys
from heapq import heapify, heappushpop
from heapq import _heapify_max as heapify_max, _siftup_max


def heappushpop_max(heap, item):
    if heap and heap[0] > item:
        item, heap[0] = heap[0], item
        _siftup_max(heap, 0)
    return item


fin = sys.stdin.readline
N = int(fin())
a_list = [int(elem) for elem in fin().split()]

left_pq = a_list[:N]
right_pq = a_list[2 * N:]
heapify(left_pq)
heapify_max(right_pq)

left_sum = [sum(left_pq)]
right_sum = [sum(right_pq)]
for k in range(N, 2 * N):
    left_item = a_list[k]
    right_item = a_list[-k - 1]
    left_sum.append(left_sum[-1] - heappushpop(left_pq, left_item) + left_item)
    right_sum.append(right_sum[-1] - heappushpop_max(right_pq, right_item) + right_item)

max_sum = max(map(sum, zip(left_sum, [-item for item in right_sum[::-1]])))
print(max_sum)


Measured memory_bytes: 41004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define F first
#define S second
typedef vector<pli> vpli;
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end() 
#define tests int t; cin>>t; while(t--)
#define take(a,b,c) for(b=0;b<c;b++) cin>>a[b];
#define INF 1e18
// https://codeforces.com/problemset/page/3?tags=1500-1800
int main()
{	
  //auto start = std::chrono::high_resolution_clock::now();
  int n,m;
  cin>>n>>m;
  cout<<(n*(n-1)/2+m*(m-1)/2)<<"\n";
  //auto stop = std::chrono::high_resolution_clock::now(); 
  //auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start);
  //cout << duration.count() << endl; 

}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

#define all(x)                          \
(x).begin(), (x).end()

#define rall(x)                         \
(x).rbegin(), (x).rend()

#define rep(i, n)                       \
for(int i = 0; (i) < (n); ++(i))

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

    Vi d(3); rep(i, 3) cin >> d[i];
    int ans = 0;
    do{
        ans = max(d[0] * 10 + d[1] + d[2], d[0] + d[1] * 10 + d[2]);
    }while(next_permutation(all(d)));

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
#include<cmath>

using namespace std;
typedef vector< vector<int> > vv;

int main(){
  int n;cin >> n;
  vv f(n,vector<int>(10,0));
  for(int i=0;i<n;i++)for(int j=0;j<10;j++)cin >> f[i][j];
  vv p(n,vector<int>(11,0));
  for(int i=0;i<n;i++)for(int j=0;j<=10;j++)cin >> p[i][j];
  int ma=-1000000000;
  int bits=pow(2,10);
  for(int i=1;i<bits;i++){
    bitset<10> bit(i);
    vector<int> v(n);
    for(int j=0;j<10;j++){
      if(bit[j]){
        for(int k=0;k<n;k++){
          v[k]+=f[k][j];
        }
      }
    }
    int ma_sub=0;
    for(int l=0;l<n;l++){
      ma_sub+=p[l][v[l]];
    }
    ma=max(ma,ma_sub);
  }
  cout << ma << endl;
}


Measured memory_bytes: 256
//Tonight's the night and it is going to happen again and again.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define endl "\n"
#define mod 1000000007
char a[1010][1010];
int dp[1010][1010];int h,w;
int ways(int h1,int w1)
{
	if(a[h1][w1]=='#'){return 0;}
	if(h1>h||w1>w){return 0;}
	if(dp[h1][w1]!=-1){return dp[h1][w1];}
	if(h1==h&&w1==w)
	{
		return 1;
	}
	if(a[h1-1][w1]=='#'&&a[h1][w1-1]=='#'){return 0;}
    return dp[h1][w1]=(ways(h1+1,w1)+ways(h1,w1+1))%mod;
}
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
 cin>>h>>w;
 for(int i=1;i<h+1;i++)
 {
 	for(int j=1;j<w+1;j++)
 	{
 		cin>>a[i][j];dp[i][j]=-1;
 	}
 }
int k=ways(1,1);
cout<<k<<endl;
/*for(int i=1;i<h+1;i++)
 {
 	for(int j=1;j<w+1;j++)
 	{
 		cout<<dp[i][j]<<" ";
 	}cout<<endl;
 }*/
}

Measured memory_bytes: 8676
import scala.io.StdIn._
object Main extends App {
  val MOD = 1000000007L
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val broken = Array.fill(m){readLine.toInt}.toSet
  val memo = Array.fill(n + 2){0L}
  memo(n) = 1
  for (i ← (0 until n).reverse if !broken.contains(i)) {
    memo(i) = (memo(i + 1) + memo(i + 2)) % MOD
  }
  println(memo.head)
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), a.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int N;
    cin >> N;
    if(N % 2 == 0) {
        cout << N / 2 << endl;
    } else {
        cout << N / 2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,n;
    cin>>k>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int d=INT_MIN;
    for(int i=1;i<n;i++)
    {
        if(abs(arr[i-1]-arr[i])>d)
        {
            d=abs(arr[i-1]-arr[i]);
        }
    }
    int c=k-(arr[n-1]-arr[0]);
    if(c>d)
    {
        d=c;
    }
    cout<<k-d;
    return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    for(int i = a; i <= b; i ++){
        count += (int)(c % i == 0);
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3112
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [N] = input[0].split(" ").map((x: string): number => +x);

top:
	for (let h = 1; h <= 3500; h++) {
		for (let n = 1; n <= 3500; n++) {
			const w = N * h * n / (4 * h * n - N * n - N * h);
			if (w > 0 && Number.isInteger(w)) {
				console.log(h, n, w);
				break top;
			}
		}
	}


Measured memory_bytes: 9420
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if((a * b) % 2 == 1) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    if (s.size() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    for (auto i : irange(0uL, s.size(), 2uL)) {
        if (s[i] != 'h' || s[i + 1] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
// use goroutine by force
package main

import (
	"fmt"
	"sort"
	"sync"
	//"time"
)

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

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	A := 0
	B := 0
	var lock sync.Mutex
	addAlice := func() {
		lock.Lock()
		defer lock.Unlock()
		if len(a) > 0 {
			A += a[0]
			a = a[1:]
		}
	}
	addBob := func() {
		lock.Lock()
		defer lock.Unlock()
		if len(a) > 0 {
			B += a[0]
			a = a[1:]
		}
	}

	startA := make(chan interface{})
	close(startA)
	toA := make(chan int)
	toB := make(chan int)

	terminated := make(chan interface{})
loop:
	for {
		select {
		case <-terminated:
			break loop
		default:
		}

		// wgを使わないとBのgoroutineが起動する前にAが重複して起動する
		var wg sync.WaitGroup
		wg.Add(2)
		go func() {
			wg.Done()
			if len(a) == 0 {
				//fmt.Println("len a == 0")
				close(terminated)
			}
			<-startA
			addAlice()
			//fmt.Printf("A: %d %v\n", A, a)
			toB <- 1
			<-toA
		}()
		go func() {
			wg.Done()
			<-toB
			addBob()
			//fmt.Printf("B: %d %v\n", B, a)
			toA <- 1
		}()
		wg.Wait()
		//time.Sleep(1 * time.Second)
		//time.Sleep(1 * time.Millisecond)
	}

	//fmt.Printf("A: %d B: %d\n", A, B)
	fmt.Println(A - B)
}


Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N);
  for_each(begin(L), end(L), [](auto& x) { cin >> x; });
  sort(begin(L), end(L));

  ll count = 0;
  for (ll a = 0; a < N - 2; a++) {
    for (ll b = a + 1; b < N - 1; b++) {
      for (ll c = b + 1; c < N; c++) {
        if ((L[a] < L[b] + L[c]) && (L[b] < L[a] + L[c]) && (L[c] < L[b] + L[a])) {
          count++;
        } else {
          break;
        }
      }
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

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

    vector<vector<double> > dist(n,vector<double>(n));
    vector<vector<int> > place(n,vector<int>(2));

    rep(i,n){
        rep(j,2){
            cin >> place[i][j];
        }
    }

    rep(i,n){
        rep(j,n){
            dist[i][j] = sqrt((place[i][0]-place[j][0])*(place[i][0]-place[j][0])+
            (place[i][1]-place[j][1])*(place[i][1]-place[j][1]));
        }
    }

    vector<int> order(n);
    rep(i,n){
        order[i] = i;
    }

    int res = INF;
    double temp_dist = 0;
    do{
        for(int i=1;i<n;++i){
            temp_dist += dist[order[i-1]][order[i]];
        }
    }while(next_permutation(order.begin(),order.end()));

    printf("%.10g\n",temp_dist/(double)factrial(n));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const int mod=1e9+7;
const int inf=1e9+7;
  
//const int maxn=
  
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
      
    int n;
    cin>>n;
    
    int flag=0;
    
    for(int i=0,x;i<n;i++)
    {
    	cin>>x;
    	
    	if(flag==1)
    		continue;
    	
    	if(x%2==0)
    	{
    		if(x%3!=0&&x%5!=0)
    		{
    			flag=1;
			}
		}
	}
	
	if(flag==0)
		cout<<"APPROVED"<<endl;
	else
		cout<<"DENIED"<<endl;
  
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int a, b;
  cin >> a >> b;

  if (a + b == 15) cout << '+' << "\n";
  else if (a * b == 15) cout << '*' << "\n";
  else cout << "x" << "\n";

  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

int pre(int x) {
  if(x < 10) return x;
  else return pre(x / 10);
}

int main() {
  int n;
  cin >> n;
  int d[10][10];
  rep(p,10) rep(q,10) {
    d[p][q] = 0;
    rep(i,n) if(pre(i+1) == p && (i+1) % 10 == q) d[p][q]++;
  }
  int s = 0;
  rep(i,n) s += d[(i+1)%10][pre(i+1)];
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3588
from collections import Counter

def main():
    n = int(input())
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1,n-1):
        if p[i-1] < p[i] < p[i+1]:
            ans += 1
        elif p[i-1] > p[i] > p[i+1]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);

		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		char[][] board = new char[N][];
		char[][] template = new char[M][];
		
		for(int i = 0; i < N; i++){
			board[i] = sc.next().toCharArray();
		}
		for(int i = 0; i < M; i++){
			template[i] = sc.next().toCharArray();
		}
		
		for(int oy = 0; oy <= (N - M); oy++){
			for(int ox = 0; ox <= (N - M); ox++){
				boolean ok = true;
				
				LOOP:
				for(int dy = 0; dy < M; dy++){
					for(int dx = 0; dx < M; dx++){
						if(board[oy + dy][ox + dx] != template[dy][dx]){
							ok = false;
							break LOOP;
						}
					}
				}
				
				if(ok){
					System.out.println("Yes");
					return;
				}
			}
		}
		
		System.out.println("No");
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22484
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
    if (b == 0) {
        return 1;
    }
    if (b == 1) {
        return a;
    }
    ll ans = pow(a, b / 2);
    ans *= ans;
    ans *= b % 2 == 1 ? a : 1;
    return ans;
}

namespace SOLVE {
    struct edge {
        ll v1, v2, weight;
    };
    
    VI id;
    
    ll parent(ll a) {
        if (id[a] == a) {
            return a;
        }
        id[a] = parent(id[a]);
        return id[a];
    }
    
    void unite(ll a, ll b) {
        id[parent(a)] = parent(b);
    }
    
    int query(ll a, ll b) {
        return (parent(a) == parent(b));
    }
    
    bool comp(edge a, edge b) {
        return a.weight < b.weight;
    }
    
    void main() {
        ll V, E, a, b, c;
        cin >> V >> E;
        
        vector<edge> edges;
        
        REP(i, 0, E) {
            cin >> a >> b >> c;
            edge x;
            x.v1 = a;
            x.v2 = b;
            x.weight = c;
            edges.push_back(x);
        }
        
        sort(edges.begin(), edges.end(), comp);
        
        id.resize(V);
        REP(i, 0, V) {
            id[i] = i;
        }
        
        ll ans = 0;
        for(int i = 0;i<E;i++){
            const edge&e = edges[i];
            if (!query(e.v1, e.v2)) {
                // join them
                unite(e.v1, e.v2);
                // cout << e.v1 << ' ' << e.v2 << ' ' << e.weight << endl;
                ans += e.weight;
                
            }
        }
        cout << ans << endl;
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    //    in(t);
    t = 1;
    while (t--) {
        SOLVE::main();
        
    }
    
    return 0;
}



Measured memory_bytes: 5904
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)

def check1():
    for Z in range(-100, 101):
        flag = True

        for v in x:
            if Z <= v:
                flag = False
                break
        
        for v in y:
            if v < Z:
                flag = False
                break
        
        if flag:
            return False
        
    return True


def check2():
    return max(x) >= min(y)

if check1():
    print("War")
else:
    print("No War")


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		// 標準入力からデータを読み込む準備
	try(Scanner sc = new Scanner(System.in)){
 
		int[] counter = new int[128];

		while(sc.hasNext()){
			 String str = sc.nextLine().toLowerCase();
			 for(int I =0; I < str.length(); I++){
				counter[str.charAt(I)]++;
			 }
		}

		for(char ch='a';ch<='z';ch++){
			System.out.println(ch + " : "+ counter[ch]);
		}

	}
	}

}


Measured memory_bytes: 26024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		String op = scan.next();
		int B = scan.nextInt();
		int result = 0;

		if(op.equals("+")){
			result = A + B;
			System.out.println(result);
		}else if(op.equals("-")){
			result = A - B;
			System.out.println(result);
		}

	}

}


Measured memory_bytes: 22612
from collections import deque

N = int(input())
b = list(map(int, input().split()))

result = deque([])
while b:
    for i in range(len(b) - 1, -1, -1):
        if b[i] == i + 1:
            result.appendleft(b.pop(i))
            break
    else:
        break

if not b:
    #print('\n'.join(str(i) for i in result))
    print(*result, sep='\n')
else:
    print(-1)


Measured memory_bytes: 9392
n = int(input())
a = [int(i) for i in input().split()]

if n // 2 == 1:
    print(max(a))
    exit()
if n < 20:
    d = a.copy()
    
    for i in range(1, n // 2):
        b = [0] * n
        c = -10 ** 24
        ans = -10 ** 24
        for j in range(i * 2, n):
            c = max(c, a[j - 2])
            b[j] = c + d[j]
            ans = max(ans, c + d[j])

        a = b.copy()
    print(ans)
    exit()

b = a[:10]
e = [True]*10

for i in range(1, n // 2):
    c = [0] * 10
    f = [False]*10
    d = -10**24
    for j in range(10):
        if 2 * i + j >= n:
            continue
        if not e[j]:
            continue
        d = max(d, b[j])
        c[j] = d + a[2 * i + j]
        f[j] = True
    e = f.copy()
    b = c.copy()
ans = -10 ** 24
for i in range(10):
    if e[i]:
        ans = max(ans, b[i])
print(ans)


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

int main()
{
  int N,M;
  cin >>N >>M;
  int a[M],b[N];
  for(int i=0; i<M; i++)
  {
    a[i]=N;
  }
  for(int i=0; i<N; i++)
  {
    b[i]=M;
  }
  if(a[0]<=b[0])
  {
    for(int i=0; i<M; i++)
  {
    cout << a[i];
  }
    cout <<endl;
  }
  else
  {
     for(int i=0; i<N; i++)
  {
    cout << b[i];
  }
    cout <<endl;   
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

const int N=25,M=(1<<20)+10,mod=1e9+7;
int n,m,len,a[M],cnt,head[N],x,y,val[N],f[2][M],g[2][M];
struct edge{int to,nxt,i;}e[N*N];

inline void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}

void adde(int x,int y,int i){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt; e[cnt].i=i;
}

void dfs(int u,int par,int st){
	val[u]=st;
	for (int i=head[u],v;i;i=e[i].nxt)
		if (v=e[i].to,v!=par) dfs(v,u,st|(1<<(e[i].i-1)));
}

void fmt(int *a){
	rep (i,0,len-1)
		rep (j,0,(1<<len)-1)
			if (!(j>>i&1)) a[j|1<<i]+=a[j];
}

int main(){
	scanf("%d%d",&n,&m); len=n-1;
	rep (i,1,n-1) scanf("%d%d",&x,&y),adde(x,y,i),adde(y,x,i);
	dfs(1,0,0);
	rep (i,n,m) scanf("%d%d",&x,&y),a[val[x]^val[y]]++; fmt(a);
	int now=0,tmp; f[0][0]=1;
	rep (i,1,m){
		now^=1;
		memset(f[now],0,sizeof(f[now]));
		memset(g[now],0,sizeof(g[now]));
		rep (j,0,(1<<len)-1)
			if (tmp=f[now^1][j],tmp){
				int s=((1<<len)-1)^j;
				for (int r=s;r;r-=r&-r){
					int k=r&-r;
					if (!(j&k)){
						upd(f[now][j|k],tmp);
						upd(g[now][j|k],(g[now^1][j]+(ll)tmp*i%mod)%mod);
					}
				}
				upd(f[now][j],(ll)tmp*(a[j]-(i-1-__builtin_popcount(j)))%mod);
				upd(g[now][j],(ll)g[now^1][j]*(a[j]-(i-1-__builtin_popcount(j)))%mod);
			}
	}
	printf("%d\n",g[now][(1<<len)-1]);
	return 0;
}

Measured memory_bytes: 20736
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
string s;
int main()
{
	getline(cin,s);
	cout<<s[0]<<(s.size()-2)<<s[s.size()-1];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256