akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=998244353;
const long long LMOD=154590409516822759;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Beg begin
int main()
{
	int n,t,g=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		if((i&1)&(t&1))g++;
	}
	cout<<g;
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

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

    		int N = sc.nextInt();
    		double T = sc.nextDouble();
    		double A = sc.nextDouble();
    		int town = 1;
    		double min = 10000000;
    		for(int i=1; i<=N; i++) {
    			double h = sc.nextDouble();
    			h = T - h*0.006;
    			if(min > Math.abs(A - h)) {
    				town = i;
    				min = Math.abs(A - h);
    			}
    		}
    		System.out.println(town);

    	}
    }
}


Measured memory_bytes: 28312
#include <iostream>
using namespace std;
#define debug 0
int main(){
	int N,M;
	cin>>N>>M;
	int data[101][2]={0};
	for(int i=1;i<=M;i++)cin>>data[i][0]>>data[i][1];
	int ans=0,flag=1;
	for(int i=1;i<=N;){
		if(debug)cout<<i<<" ";
		int f=1,pos;
		for(int j=1;j<=M;j++){
			if(data[j][0]<=i){
				if(f){
					f=0;
					pos=j;
				}
				else if(data[pos][1]<data[j][1]){
					pos=j;
				}
			}
		}
		if(data[pos][1]<i){
			if(debug)cout<<"none"<<endl;
			flag=0;
			break;
		}
		else{
			if(debug)cout<<data[pos][1]<<endl;
			ans++;
			i=data[pos][1]+1;
		}
	}
	
	if(flag)cout<<ans<<endl;
	else cout<<"Impossible"<<endl;
	
	return 0;
}


Measured memory_bytes: 1164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {

    static long mod = (1L<<25);
    static long pow(long a, long b) {
        long ans = 1L;
        long tmp = a;
        int j = 0;
        // for (int j=0;j<20;j++) {
        while (b>0) {
            if (((1L<<j)&b)==(1L<<j)) {
                ans = ans*tmp%mod;
                b-=(1L<<j);
            }
            j++;
            tmp = tmp*tmp%mod;
        }
        return ans;
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        char[] T = in.next().toCharArray();
        char[] S = in.next().toCharArray();
        int[] t = new int[T.length];
        int[] s = new int[S.length];
        for (int i=0;i<T.length;i++) {
            t[i] = (int)T[i]-47;
        }
        for (int i=0;i<S.length;i++) {
            s[i] = (int)S[i]-47;
        }

        long base = 1_000_000_007;
        long hash = 0L;
        for (int i=0;i<S.length;i++) {
            hash = (hash+s[i]*pow(base, S.length-1-i)%mod)%mod;
        }

        long tmp = 0L;
        for (int i=0;i<S.length;i++) {
            if (i==T.length) break;
            tmp = (tmp+t[i]*pow(base, S.length-1-i)%mod)%mod;
        }
            // System.out.println("tmp: "+tmp);
            if (hash==tmp) {
                // set.add(0);
                out.println(0);
            }
        for (int i=0;i<T.length-S.length;i++) {
            tmp = tmp*base%mod;
            tmp -= t[i]*pow(base, S.length)%mod;
            tmp = (tmp+mod)%mod;
            tmp = (tmp+t[i+S.length]);

            // System.out.println("tmp: "+tmp);
            if (hash==tmp) {
                // set.add(i+1);
                out.println(i+1);
            }
        }
        out.close();
    }

    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());
        }

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

    }
}



Measured memory_bytes: 69768
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt() - 1;
        }

        int[] ds = new int[n];
        Arrays.fill(ds, -1);
        int cur = 0;
        int d = 0;
        while (ds[cur] < 0) {
            ds[cur] = d;
            cur = as[cur];
            d++;
        }

        if (k <= ds[cur]) {
            for (int i = 0; i < n; i++) {
                if (1L * ds[i] == k) {
                    out.println(i + 1);
                    break;
                }
            }
        } else {
            debug(k);
            k -= ds[cur];
            k %= d - ds[cur];
            while (k > 0) {
                cur = as[cur];
                k--;
            }
            out.println(cur + 1);
        }

        out.flush();
    }



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

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

Measured memory_bytes: 60252
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc =new Scanner(System.in);
		int k = sc.nextInt();
		if(k == 1) {
			System.out.println(1);
			System.out.print(1);
			return;
		}
		int n = 2 * ((k+3)/4);
		int curt = n*2 - k;
		int[][] mat = new int[n][n];
		for(int r=0; r<n; r++) {
			for(int c=0; c<n;c++) {
				if(r%2 == 1 && (r+c)%n < n -curt) {
					mat[r][c] = n + (r+c)%n;
					mat[r][c]++;
				} else {
					mat[r][c] = (r+c)%n;
					mat[r][c]++;
				}
			}
		}
		System.out.println(n);
		for(int[] row: mat) {
			for(int x : row) {
				System.out.print(x+" ");

			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 49620
n = int(input())
blues = [input() for _ in range(n)]
m = int(input())
reds = [input() for _ in range(m)]
words = set(blues)
_max = 0
for w in words:
    score = 0
    score += blues.count(w)
    score -= reds.count(w)
    if _max < score:
        _max = score
print(_max)

Measured memory_bytes: 3064
import sys

readline = sys.stdin.readline

R, G, B, N = map(int, readline().split())

count = 0
for r in range(0, N + 1, R):
    for g in range(0, N - r + 1, G):
        if (N - r - g) % B == 0:
            count += 1

print(count)

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

#define f first
#define s second
#define ll long long
#define pb push_back
#define mp make_pair
#define inp(x) cin>>x
#define print(x) cout<<x
#define pii pair<int,int>
#define pll pair<ll,ll>
#define gcd(a,b) __gcd(a,b)
#define reset(d,val) memset(d,val,sizeof(d))
#define sort(v) sort(v.begin(),v.end())
#define sort_arr(arr,i,f) sort(arr+i,arr+f)
#define pq priority_queue<int,vector<int>,greater<int> >
#define pq1 priority_queue<pll,vector<pll>,greater<pll> >

const int mod = 1e9+7;

int c[13],arr[13][13];

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m,x;
	cin>>n>>m>>x;
	int ans = mod;
	for (int i = 0; i < n; ++i)
	{
		cin>>c[i];
		for (int j = 0; j < m; ++j)
		{
			cin>>arr[i][j];
		}
	}
	for (int i = 0; i < (1<<n); ++i)
	{
		std::vector<int> v;
		int val = 0;
		for(int j=0;j<n;j++) {
			if(i&(1<<j)) {
				v.pb(j);
				val += c[j];
			}
		}
		int cnt = 0;
		for (int j = 0; j < m; ++j)
		{
			int y = 0;
			for(int k=0;k<v.size();k++) {
				y += arr[v[k]][j];
			}
			if(y>=x) cnt++;
		}
		if(cnt==m) ans = min(ans,val);
	}
	cout<<(ans==mod?-1:ans);
	return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numOfPeople = sc.nextInt();
        Boolean[] isExist = new Boolean[numOfPeople];
        for (int i = 0; i < numOfPeople; i++) {
            isExist[i] = false;
        }
        int numOftype = sc.nextInt();
        int[] nowType = new int[numOftype];
        int[][] A = new int[numOftype][numOfPeople];
        int ans = 0;

        for (int i = 0; i < numOftype; i++) {
            nowType[i] = sc.nextInt();
            for (int j = 0; j < nowType[i]; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i < numOftype; i++) {
            for (int j = 0; j < nowType[i]; j++) {
                for (int k = 0; k < numOfPeople; k++) {
                    if (A[i][j] == k + 1) {
                        isExist[k] = true;
                    }
                }
            }
        }
        for (int i = 0; i < numOfPeople; i++) {
            if (!isExist[i]) {
                ans++;
            }

        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 46192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 200005

ll i=0,j=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    // program to find the longest common subsequence of 2 strings;
    string s,t;
    cin>>s>>t;
    ll m=s.size();
    ll n=t.size();
    ll lcs[m+1][n+1];
    memset(lcs,0,sizeof(lcs));
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(s[i-1]==t[j-1])
            {
                lcs[i][j]=1+lcs[i-1][j-1];
            }
            else
            {
                lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
            }
        }
    }
   /* for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            cout<<lcs[i][j]<<" ";
        }
        cout<<endl;
    }*/
    ll i=m;
    ll j=n;
    string ans="";
    while(i>=1 and j>=1)
    {
        if(s[i-1]==t[j-1])
        {
            ans.push_back(s[i-1]);
            i--;
            j--;
            continue;
        }
        if(lcs[i-1][j]>lcs[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(all(ans));
    cout<<ans<<endl;
}



Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)

using namespace std;

int main()
{
  int n, W; cin >> n >> W;
  vector<int> v(n);
  vector<int> w(n);
  REP(i,n) cin >> v[i] >> w[i];
  vector<int> dp(10001,0);
  dp[0] = 0;
  REP(i,n) FOR(j,w[i],W)
    dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
  cout << *max_element(dp.begin(),dp.begin()+W+1) << endl;
  return 0;
}

Measured memory_bytes: 3092
l = [0]*31
pos = goal = 0
def solve(cur,sum):
    global pos, goal
    if cur == goal:
        print " ".join(map(str,l[:pos]))
        return
    for i in range(sum,0,-1):
        if cur + i <= goal:
            l[pos] = i
            pos += 1
            solve(cur+i,i)
            pos -= 1
while True:
    goal = int(raw_input())
    if goal == 0: break
    solve(0,goal)

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

const int MOD = 1e9 + 7;

int lgput(int x, int p) {
    if(p < 0)
        return 0;
    int ans = 1;
    while(p) {
        if(p % 2)
            ans = (1LL * ans * x) % MOD;
        p /= 2;
        x = (1LL * x * x) % MOD;
    }

    return ans;
}

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

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<int> v(n + 1, 0);
    for(int i = 1; i <= n; i ++)
        cin >> v[i];
    sort(v.begin() + 1, v.end());

    int ans = 0;
    for(int i = 1; i <= n; i ++) {
        int x = (1LL * lgput(2, n + i - 1) * v[i]) % MOD;
        int aux = (1LL * lgput(2, n - i) + 1LL * (n - i) * lgput(2, n - i - 1)) % MOD;
        x = (1LL * x * aux) % MOD;
        ans = (ans + x) % MOD;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 1024
def main():
    s = input()
    ans = 0
    if s == "SUN":
        ans = 7
    elif s == "MON":
        ans = 6
    elif s == "TUE":
        ans = 5
    elif s == "WED":
        ans = 4
    elif s == "THU":
        ans = 3
    elif s == "FRI":
        ans = 2
    else:
        ans = 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.regex.Pattern;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());
        int[] d = toIntArray(stdin.readLine());

        long[] c = new long[Arrays.stream(d).max().getAsInt() + 1];
        for (int v : d) {
            c[v]++;
        }

        if (d[0] != 0 || c[0] != 1) {
            stdout.println(0);
            return ;
        }

        long ans = 1;
        for (int k = 0; k < c.length - 1; k++) {
            ans *= modPow(c[k], c[k + 1]);
            ans %= mod;
        }
        stdout.println(ans);
    }

    private long mod = 998244353;

    private long modPow(long x, long y) {
        long z = 1;
        while (y > 0) {
            if (y % 2 == 0) {
                x = (x * x) % mod;
                y /= 2;
            } else {
                z = (z * x) % mod;
                y--;
            }
        }
        return z;
    }

    private Pattern space = Pattern.compile(" ");

    private int[] toIntArray(String line) {
        return space.splitAsStream(line).mapToInt(Integer::parseInt).toArray();
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}

Measured memory_bytes: 38524
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-13 19:59:05
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#include<vector>
#include<map>
const int N=200010;
int n,ans[N],s;
std::vector<int> e[N];
void dfs1(int,int,int,int);
int dfs2(int u,int f,int F)
{
	int ans=1;
	for(auto v:e[u]) if(v!=f&&v<F) ans+=dfs2(v,u,F);
	return ans;
}
void dfs3(int u,int f,int F,int s)
{
	ans[u]=s;
	for(auto v:e[u]) if(v!=f){ if(v<F) dfs3(v,u,F,s); else dfs1(v,u,F,s); }
}
void dfs1(int u,int f,int mx,int s)
{
	s+=dfs2(u,f,mx);
	if(u>mx)
	{
		ans[u]=s;
		for(auto v:e[u]) if(v!=f) dfs1(v,u,u,s-(v<mx?dfs2(v,u,mx):0));
	}
	else dfs3(u,f,mx,s);
//	printf("%d %d %d   %d\n",u,f,mx,s);
}
int main()
{
	n=read();
	fr(i,1,n-1)
	{
		int u=read(),v=read();
		e[u].push_back(v); e[v].push_back(u);
	}
	for(auto i:e[1]) dfs1(i,1,1,0);
	fr(i,2,n) printf("%d%c",ans[i],i==n?'\n':' ');
	return 0;
}

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

using namespace std;

#define MOD 1000000007
#define N 10004
#define M 102
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

string s;
vector <ll> num;
ll n, d;
ll dp[N][M][2];

ll get(int pos, ll sum, bool flag){
    ll &ans = dp[pos][sum][flag];
    if(pos == n && sum%d == 0){
        return (ans = 1);
    }
    if(pos == n && sum%d != 0){
        return (ans = 0);
    }
    if(ans != -1){
        return ans;
    }
    ans = 0;
    int lim = flag ? 9 : num[pos];
    for(int i=0; i<=lim; i++){
        ans = (ans + get(pos+1, (sum+i)%d, flag | (i < num[pos]))) % MOD;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>s>>d;
    for(auto it : s){
        num.pb(it-'0');
    }
    n = num.size();
    memset(dp, -1, sizeof dp);
    cout<<(get(0, 0, 0) - 1 + MOD)%MOD;
    return 0;
}

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

int main()
{
	int n, k; long long count = 0; cin >> n >> k; vector<int>arr(n);
	for (int i = 0; i < n;i++) {
		cin >> arr[i];
	}
	int pointer = arr.size() - 1;
	sort(arr.begin(), arr.end());
	if (k > n)k = n;
	for (int x = k; x > 0; x--) {
		arr[pointer--] = 0;
	}
	for (int i = 0; i < arr.size(); i++) {
		count += arr[i];
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n,k;
    int h[100010];
    int dp[100010];
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    dp[0] = 0;
    for(int i=1;i<n;i++){
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        for(int j=1;j<=min(k,i);j++){
            dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

    cout << dp[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
#define mod 998244353
using namespace std;
int x[500],y[500],k[500];
int ans,n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]);
	k[0]=1;
	for(int i=1;i<=n;i++)
		k[i]=(k[i-1]<<1)%mod;
	ans=k[n]-1-n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)
		{
			int num=0;
			for(int ki=1;ki<j;ki++)
				if((x[i]-x[j])*(y[i]-y[ki])==(x[i]-x[ki])*(y[i]-y[j])) num++;
			ans=(ans-k[num]+mod)%mod;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

ll n, m;
bool dist[100005][2];
int main()
{
    cin >> n >> m;
    rep(i, n) rep(j, 2) dist[i][j] = false;
    map<ll, set<ll>> edge;
    ll a,b;
    rep(i,m){
        cin >> a >> b;
        a--;
        b--;
        edge[a].insert(b);
        edge[b].insert(a);
    }
    dist[0][0] = true;
    set<ll> check;
    check.insert(0);
    while (!(check.empty())){
        ll now = *check.begin();
        check.erase(now);
        for (auto nex:edge[now]){
            if (dist[now][0] && !(dist[nex][1])){
                dist[nex][1] = true;
                check.insert(nex);
            }
            if (dist[now][1] && !(dist[nex][0])){
                dist[nex][0] = true;
                check.insert(nex);
            }
        }
    }
    ll x = 0, y = 0, z = 0;
    rep(i,n){
        if (dist[i][0] && dist[i][1])
            x++;
        else if (dist[i][0])
            y++;
        else if (dist[i][1])
            z++;
    }
    ll ans = n * (n - 1) / 2 - y * (y - 1) / 2 - z * (z - 1) / 2;
    cout << ans - m << endl;
}


Measured memory_bytes: 19328
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int N,i,j,tmp,Alice=0,Bob=0;
	int *a;
	scanf("%d",&N);
	a = (int*)malloc(sizeof(int)*N);
	for(i=0;i<N;i++) scanf("%d",&a[i]);
	for(i=0;i<N;i++){
		for(j=0;j<N-i;j++){
			if(a[j]>=a[j+1]) continue;
			else{
				tmp = a[j];
				a[j] = a[j+1];
				a[j+1] = tmp;
			}
		}
	}
		for(i=0;i<N;i+=2) Alice+=a[i];
		for(i=1;i<N;i+=2) Bob+=a[i];
		printf("%d\n",Alice-Bob);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.text.DecimalFormat;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int d = a/b;
		int r = a%b;
		 DecimalFormat df1 = new DecimalFormat("0.00000");
		double a2 = a;
		double b2 = b;
		double f = a2/b2;
		System.out.println(d +" "+ r +" "+ df1.format(f));
	}
}

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

int main()
{
	multimap<string, int> cpp;
	string str, v;
	int n, com, q;
	cin >> q;

	while (q--)
	{
		cin >> com >> str;
		multimap<std::string, int>::iterator iter,prev;

		switch (com)
		{
		case 0:
			cin >> n;
			cpp.insert(make_pair(str, n));
			break;
		case 1:
			iter = cpp.lower_bound(str);
			for (; iter != cpp.end() && (iter->first) == str; ++iter)
				cout << iter->second << endl;
			break;                                          
		case 2:
			cpp.erase(str);
			break;
		case 3:
			cin >> v;
			for (prev = cpp.lower_bound(str); prev != cpp.upper_bound(v); prev++)   
					cout << prev->first << " " << prev->second << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 24800
#!/usr/bin/python3
# -*- coding: utf-8 -*-

sx, sy, tx, ty = [int(i) for i in input().split()]
dx, dy = tx - sx, ty - sy
path = []

# 1
path += ['R'] * dx
path += ['U'] * dy
path += ['L'] * dx
path += ['D'] * dy

# 2
path += ['D']
path += ['R'] * (dx + 1)
path += ['U'] * (dy + 1)
path += ['L', 'U']
path += ['L'] * (dx + 1)
path += ['D'] * (dy + 1)
path += ['R']

print(''.join(path))


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

class EratosthenesSieve {
private:
    std::vector<bool> prime;

    void build(int N)
    {
        prime.assign(N, true);
        prime[0] = prime[1] = false;
        for (int i = 2; i * i < N; i++)
            if (prime[i])
                for (int j = i * 2; j < N; j += i)
                    prime[j] = false;
    }

public:
    EratosthenesSieve(int N)
    {
        build(N);
    }

    bool is_prime(int x)
    {
        return prime.at(x);
    }
};

int main()
{
    const int N = 114514;
    EratosthenesSieve es(N);
    std::vector<int> x(N);
    for (int i = 1; i < N; i += 2)
        if (es.is_prime(i) && es.is_prime((i + 1) / 2))
            x[i] = 1;

    for (int i = 1; i < N; i++)
        x[i] += x[i - 1];

    int Q;
    std::cin >> Q;
    for (int i = 0; i < Q; i++) {
        int l, r;
        std::cin >> l >> r;
        std::cout << x[r] - x[l - 1] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3612
S = input()
T = input()
Ls = len(S)
Lt = len(T)
ans = 1000
for i in range(Ls-Lt+1):
    count = 0
    for j in range(Lt):
        if S[i+j] != T[j]:
            count += 1
    ans = min(ans, count)
print(ans)


Measured memory_bytes: 8984
a = [list(map(int,input().split()))for i in range(3)]
raw = []
for i in range(3):
    raw.append([a[i][0],a[i][1],a[i][2]])
    raw.append([a[0][i],a[1][i],a[2][i]])
raw.append([a[0][0],a[1][1],a[2][2]])
raw.append([a[0][2],a[1][1],a[2][0]])
cnt = [0]*8
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        if b in raw[j]:cnt[j]+=1
cnt.sort()
if cnt[-1] == 3:print("Yes")
else:print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

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

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
	static int[][] board = new int[10][10];

	public static void main(String[] args) throws IOException {
		// 宣言
		Scanner sc = new Scanner(System.in);
		String[] str;
		int count = 0;
		int max = 0;

		while (sc.hasNext()) {
			str = sc.nextLine().split(",");
			int x = Integer.parseInt(str[0]);
			int y = Integer.parseInt(str[1]);
			int size = Integer.parseInt(str[2]);
			if (size == 1) {
				small(x, y);
			} else if (size == 2) {
				middle(x, y);
			} else if (size == 3) {
				big(x, y);
			}
		}
		for (int xx = 0; xx < 10; xx++) {
			for (int yy = 0; yy < 10; yy++) {
				// 1個目の答え
				if (board[xx][yy] == 0) {
					count++;
				}
				// 2個目の答え
				if (max < board[xx][yy]) {
					max = board[xx][yy];
				}
			}
		}
		System.out.println(count);
		System.out.println(max);
	}

	// インク小　中心と上下左右1マス
	static void small(int x, int y) {
		paint(x, y);
		// 左右、上下のマスを塗る
		paint(x + 1, y);
		paint(x - 1, y);
		paint(x, y - 1);
		paint(x, y + 1);
	}
	// インク中　上下左右斜め9マス
	static void middle(int x, int y) {
		for (int yr = -1; yr <= 1; yr++) {
			for (int xr = -1; xr <= 1; xr++) {
				paint(x + xr, y + yr);
			}
		}
	}
	//　インク大　インク中＋上下左右2マス
	static void big(int x, int y) {
		middle(x, y);
		//左右、上下の2マス目を塗る
		paint(x, y - 2);
		paint(x, y + 2);
		paint(x + 2, y);
		paint(x - 2, y);
	}

	static void paint(int x, int y) {
		//範囲外にあたる場合は何もしない
		if (x < 0 || y < 0 || x >= 10 || y >= 10) {
			return;
		} else {
			board[x][y] += 1;
		}

	}

}

Measured memory_bytes: 17188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	string S, T;
	cin >> S >> T;
	cout << T << S << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  int ans = 0;
  ans = min(b / a, c);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i,j;
  string S,T={"abcdefghijklmnopqrstuvwxyz"};
  cin>>S;
  vector<int> al(26);
  for(i=0;i<S.size();i++){
    for(j=0;j<26;j++){
      if(S.at(i)==T.at(j)){
        al.at(j)++;
        break;
      }
    }
  }
  for(i=0;i<26;i++){
    if(al.at(i)==0){
      cout<<T.at(i)<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
}


Measured memory_bytes: 512
s = input()

def is_kaibun(st):
    return len(st) == 1 or st[:len(st) // 2] == st[-(len(st) // 2):][::-1]

if is_kaibun(s) and is_kaibun(s[:len(s) // 2]) and is_kaibun(s[-(len(s) // 2):]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import collections
N=int(raw_input())
A=map(int, raw_input().split())
count_A=collections.Counter(A).most_common(1)
cnt = 0
if N == 1:
    if A[0] == 0:
        print 1
    else:
        print 0
elif N%2 == 0:
    if A.count(0) != 0:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print (2**(N/2)) % (10**9+7)
else:
    if A.count(0) != 1:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print (2**(N/2)) % (10**9+7)

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

int main(){
  int x, y;
  char op;
  vector<int> ans;

  while(true){
    cin >> x >> op >> y;
    if(op=='?') break;
    else if(op=='+') ans.push_back(x+y);
    else if(op=='-') ans.push_back(x-y);
    else if(op=='*') ans.push_back(x*y);
    else if(op=='/') ans.push_back(x/y);
  }

  for(int i=0; i<(int)ans.size(); i++){
    cout << ans[i] << endl;
  }
  return 0;
}



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

int main(){
  int N,num=0,x=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N;++i){
    if(S.at(i)=='I'){
      ++x;
    }else{
      --x;
    }
    num = max(num,x);
  }
  cout << num <<endl;
}

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

int main()
{
  int N, A;
  cin >> N >> A;
  N %= 500;
  string ans = "Yes";
  if (N > A)
    ans = "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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

  if(a+b==15) puts("+");
  else if(a*b==15) puts("*");
  else puts("x");
  
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if((C+B-1)/B<=(A+D-1)/D) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
using namespace std;

int main(){
  int N, K, check = 0;
  cin >> N ;
  for(int i=0;i<N;i++){
    cin >> K ;
    if((i+1) != K) check++ ;
  }  
  if((check == 0) || (check == 2)){
    cout << "YES" << endl ;
  }  
  else{
    cout << "NO" << endl ;
  }  
  return 0 ;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;


/*
ll gcd(ll x, ll y) {
if (y == 0) return x;
return gcd(y, x%y);
}
/*
ll lcm(ll x, ll y) {
ll g = gcd(x, y);
return x / g * y;
}
ll pw(int x, int n) {
ll y = 1;
ll p = x;
while (n != 0) {
if (n % 2) {
y = y*p%mod;
n = n - 1;
}
else {
p = p*p%mod;
n = n / 2;
}
}
return y;
}

ll modinv(ll x) {
return pw(x, mod - 2);
}*/

ll n, k;
int main() {
	cin >> n >> k;
	if (k % 2) {
		cout << (n / k)*(n / k)*(n / k) << endl;
	}
	else {
		cout << (n / k)*(n / k)*(n / k) + ((n + k / 2) / k)*((n + k / 2) / k)*((n + k / 2) / k) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n, m, x;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for (int bit = 0; bit < 1 << n; bit++) {
        int sum = 0;
        int b[m] = {};
        rep(i, n) {
            if (bit & (1 << i)) {
                sum += c[i];
                rep(j, m) {
                    b[j] += a[i][j];
                }
            }
        }
        rep(i, m) {
            if (b[i] < x) goto fin;
        }
        ans = min(ans, sum);
    fin:;
    }
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>

#define min(a,b) a<b?a:b
int e;
const int MAX_E = 1000000;
using namespace std;

void solve() {

    int ans=100000000;
    for(int z=0;z*z*z<=MAX_E;z++) {
        for(int y=0;y*y<=MAX_E;y++) {
            int x = e - y*y;
            if(x<0) break;
            x -= z*z*z;
            if(x<0) break;
            ans=min(ans,x+y+z);
        }
    }
    cout<<ans<<endl;

}

int main() {

    while(cin>>e) {
        if(e==0) return 0;
        solve();

    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    vector<int>isprime(100001,1);
    isprime[0]=0;
    isprime[1]=0;
    for(int i=2;i<=100000;i++){
        if(isprime[i]){
            for(int j=2;i*j<=100000;j++){
                isprime[i*j]=0;
            }
        }
    }

    vector<int>pri_2017(100001,0);
    for(int i=2;i<=100000;i++){
        if(i%2==0) continue;
        if(isprime[i]==1&&isprime[(i+1)/2]==1) pri_2017[i]=1;  
    }
    /*for(int i=3;i<=100000;i++){
        if(isprime[i]==0) continue;
        int j=(i+1)/2;
        if(isprime[j]==0) isprime[i]=0;
    }*/
    vector<int>rui(100001,0);
    rep(i,100001){
        if(i==0) rui[i]=pri_2017[i];
        else{
            rui[i]=rui[i-1]+pri_2017[i];
        }
    }
    int q;
    cin >> q;
    vector<int>ans(q);
    rep(i,q){
        int l,r;
        cin >> l >> r;
        ans[i]=rui[r]-rui[l-1];
    }
    rep(i,q){
        cout <<ans[i] <<endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<stack>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}
int main() {
	ll N, K;
	cin >> N >> K;
	map<ll, ll>mp;
	for (ll i = 0; i < N; i++) {
      	ll a,b;
      	cin>>a>>b;
		mp[a]+=b;
	}
	ll ans = 0;
	for(ll i=1; i<=100000; i++){
      ans+=mp[i];
      if(ans>=K){
        ans=i;
        break;
      }
    }
    cout<<ans<<endl;
      
}
			



Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    char sp = '0';
    int ans = 0;
    for(int i=0; i<n; i++){
        if(sp!=s[i]){
            ans += 1;
        }
        sp = s[i];
    }
    cout << ans << endl;
}

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

using namespace std;

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

  vector<double> A;
  for (size_t i = 0; i < N; i++) {
    size_t a;
    cin >> a;
    A.emplace_back(a);
  }

  double sum = 0.0;
  for (const auto& a : A) {
    sum += 1.0 / a;
  }
  cout << 1.0 / sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	ll x;
	cin>>x;
	ll cnt=0;
	ll a=100;
	while(a<x){
		a=a*1.01;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3652
require 'prime'

def solve n
	i = 1
	while n * i <= @a_max
		@dp[n * i] = 1
		i += 1
	end
end

n = gets.to_i
as = gets.chomp.split.map(&:to_i).sort
@a_max = as[-1]
@dp = Array.new(@a_max+1,0)
ans = 0

n.times do |i|
	a = as[i]
	ans += 1 if !(i < n - 1 && a == as[i+1]) && @dp[a] == 0
	solve(a) if @dp[a] == 0
end

puts ans

Measured memory_bytes: 39756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define c(s) cout<< (s) << endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define cyn(c) cout<<(c?"Yes":"No")<<endl;
#define cYN(c) cout<<(c?"YES":"NO")<<endl;
#define pyn(c) printf("%s\n",c?"Yes":"No");
#define pYN(c) printf("%s\n",c?"YES":"NO");
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    bool flag=true;
    string w; cin>>w;
    int al[26]={};
    rep(i,w.size()){
        al[w[i]-'a']++;
    }
    rep(i,26){
        if(al[i]%2!=0){
            flag=false;
        }
    }
    pyn(flag);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#define ll long long
#define int ll
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define gcd(A,B) (__gcd(A,B))
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define ld long double
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

typedef pair<int,int> pii;

vector <pii> edge;
vector <pii> allpair;
int n, k;
void printedge(int u, int v)
{
    cout << u << ' ' << v << '\n';
    return;
}
int32_t main()
{
    usecppio
    cin >> n;
    cin >> k;
    if (k > ((n-1)*(n-2))/2)
    {
        cout << -1;
        return 0;
    }
    int m = 0;
    int u = ((n-1)*(n-2))/2-k;
    for (int i = 2; i<=n; i++)
    {
        m++;
        edge.push_back({1,i});
    }
    for (int i = 2; i<n; i++)
    {
        for (int j = i+1; j<=n; j++)
        {
            allpair.push_back({i,j});
        }
    }
    for (int i = 0; i<u; i++)
    {
        m++;
        edge.push_back(allpair[i]);
    }
    cout << m << '\n';
    for (auto it:edge)
    {
        cout << it.first << ' ' << it.second << '\n';
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> s(n);

    ll ans = 0;

    rep(i,n){
        cin >> s[i];
        ans += s[i];
    }

    if(ans %10 != 0){
        cout << ans << endl;
        return 0;
    }

    sort(all(s));

    bool jud = false;

    rep(i,n){
        if(s[i] %10 != 0){
            ans -= s[i];
            jud = true;
            break;
        }
    }

    if(!jud) cout << 0 << endl;
    else cout << ans << endl;
}

    
    

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int len (LL l) {
  return int(to_string(l).length());
}

int getMaxDivisor (LL num) {
  int ans = 20;
  for (LL i = 1 ; i * i < num + 1; i++) {
    if (num % i == 0) {
      LL divisor = i;
      LL divided = num / i;
      ans = min(ans, max(len(divisor), len(divided)));
    }
  }
  return ans;
}

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

  LL llN = stoll(n);

  printf("%d\n",getMaxDivisor(llN));

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,A,B; cin >> N >> A >> B;
    cout << min(N*A,B) << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


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








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

Measured memory_bytes: 1024
#include <stdio.h>
int main ()
{
	int m,d, i,d1,d10,count=0;
	scanf ("%d%d",&m,&d);
	if (m<4 || d<22)
	    printf ("0\n");
	else {
		i=22;
		while (i<=d){
			d1=i/10;
			d10=i%10;
			if (d1*d10<=m && d1>=2 &&d10>=2)
			    count++;
			i++;
		}
		printf ("%d\n",count);
	}

	return 0;
}


Measured memory_bytes: 128
from itertools import accumulate
def inpl(): return map(int, input().split())

N, M = inpl()
X = [0]*(N+1)
for _ in range(M):
    l, r = inpl()
    X[l-1] += 1
    X[r] -= 1
S = list(accumulate(X))
print(sum([s == M for s in S]))

Measured memory_bytes: 53592