akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) {
        int x = a[i] / 400;
        mp[min(x, 8)]++;
    }
    if (sz(mp) == 1) {
        for (auto p : mp) {
            if (p.fi == 8) {
                cout << 1 << " " << p.se << endl;
            } else {
                cout << 1 << " " << 1 << endl;
            }
        }
    } else {
        bool flag = false;
        int x = 0;
        for (auto p : mp) {
            if (p.fi == 8) {
                flag = true;
                x = p.se;
            }
        }
        if (flag) {
            cout << sz(mp) - 1 << " " << sz(mp) - 1 + x << endl;
        } else {
            cout << sz(mp) << " " << sz(mp) << endl;
        }
    }
}

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

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

    vector< int > a(N);
    rep(i, N) cin >> a[i];

    sort(a.begin(), a.end());

    cout << a[a.size()-1] - a[0] << endl;
}


Measured memory_bytes: 256
A=int(input())
l=list(map(int,input().split()))
sum_n=0
ans=0
caseA=0
for i in range(A):
   sum_n+=l[i]
   if i%2==0:
      if 0<sum_n:
         continue
      else:
         ans+=abs(1-sum_n)
         sum_n=1
   else:
      if sum_n < 0:
         continue
      else:
         ans+=abs(-1-sum_n)
         sum_n=-1
caseA=ans
ans=0
sum_n=0
for i in range(A):
   sum_n+=l[i]
   if i%2==1:
      if 0<sum_n:
         continue
      else:
         ans+=abs(1-sum_n)
         sum_n=1
   else:
      if sum_n < 0:
         continue
      else:
         ans+=abs(-1-sum_n)
         sum_n=-1
print(min(ans,caseA))

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

ll lcm(ll a, ll b) {
    return (ll)min(2e18l, (long double)a/__gcd(a,b)*b);
}

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), p(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> p[i];

    vector<ll> f(1LL<<n);
    FOR(mask, 1, 1LL<<n) {
        ll prod = 1;
        REP(i, n) if(mask&1<<i) prod = lcm(prod, a[i]);
        f[mask] = m / prod;
    }
    REP(i, n) REP(mask, 1LL<<n) {
        if(mask&1<<i) f[mask] -= f[mask^(1<<i)];
    }

    double ret = 0;
    REP(mask, 1LL<<n) {
        double prob = 1;
        REP(i, n) {
            if(mask&1<<i) prob *= p[i] / 100.0;
            else prob *= (100 - p[i]) / 100.0;
        }
        ret += prob * abs(f[mask]);
    }
    cout << fixed << setprecision(9) << ret << endl;

    return 0;
}



Measured memory_bytes: 11000
#include <set>
#include <cstdio>
const int MAXN=1E5+10;
const int lr[]={-1,-1,-1,0,0,0,1,1,1};
const int ud[]={-1,0,1,-1,0,1,-1,0,1};
struct pair {
	int x,y;
	pair(int a=0,int b=0) {x=a;y=b;}
	bool operator < (const pair&c) const {
		return x<c.x ||( x==c.x&&y<c.y);
	}
};
std::set<pair>point,tang;
int x[MAXN],y[MAXN];
long long w[10];
int main() {
	int N,H,W;
	scanf("%d%d%d",&H,&W,&N);
	for(int i=1;i<=N;++i) {
		scanf("%d%d",&x[i],&y[i]);
		point.insert(pair(x[i],y[i]));
	}
	for(int i=1;i<=N;++i) {
		for(int aa=0;aa<9;++aa) {
			int xx=x[i]+ud[aa];
			int yy=y[i]+lr[aa];
			if(xx-1<1||xx+1>H||yy-1<1||yy+1>W)
				continue;
			if(tang.count(pair(xx,yy))!=0)
				continue;
			tang.insert(pair(xx,yy));
			int cnt=0;
			for(int bb=0;bb<9;++bb) {
				int xxx=xx+ud[bb];
				int yyy=yy+lr[bb];
				cnt+=point.count(pair(xxx,yyy));
			}w[cnt]++;
		}
	}long long rs=0;
	for(int i=1;i<=9;++i)rs+=w[i];
	w[0]=1ll*(H-2)*(W-2)-rs;
	for(int i=0;i<=9;++i) {
		printf("%lld\n",w[i]);
	}return 0;
}

Measured memory_bytes: 47872
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#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 RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
string s;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}



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

	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

const int INF=1000000000;

int main(){
	int a,b;
	int s[5002],t[5002];
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",&s[i]);
	}
	for(int i=0;i<b;i++){
		scanf("%d",&t[i]);
	}

	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;

	int ret=0,p,q,cnt;
	for(int i=0;i<b-ret;i++){
		p=0; q=i; cnt=0;
		for(int p=0;p<a;p++){
			if(s[p]==t[q]){
				if(p>=memo[q])break;
				memo[q]=p;
				cnt++;
				q++;
			}
		}
		ret=max(ret,cnt);
	}


	printf("%d\n",ret);
}

Measured memory_bytes: 1084
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}

int main() {
	int n=read();
	if (n%1000==0) puts("0");
	else printf("%d\n",1000-n%1000);
	return 0;
}

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

int main()
{
  int array;
  int topNo, priceA, priceB, calorie;
  int calorieSum, priceSum;
  vector<int> topping;

  cin >> topNo;  //??????????????°??°

  cin >> priceA >> priceB;  //??????

  cin >> calorie;  //????????????

  for (int i = 0; i < topNo; i++) {
    cin >> array;
    topping.push_back(array);
  }
    
  sort(topping.begin(), topping.end(), greater<int>());
  calorieSum = calorie;
  priceSum = priceA;

  float greatestPizza, MAX=0;
  for (int i = 0; i < topNo; i++) {
    calorieSum += topping[i];
    priceSum += priceB;
    greatestPizza = calorieSum / priceSum;
    
    if(greatestPizza > MAX) {
      MAX = greatestPizza;
      continue;
    }
    //cout << greatestPizza << endl;
    //break;
  }

  int output;
  output = MAX;
  cout << output << endl;;
  
  return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define int long long

//not accepted

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,w;
	cin>>n>>w;
	pair<int,int> arr[n+1];
	int value=0;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i].second>>arr[i].first;
		value+=arr[i].first;
	}
	int dp[n+1][value+1];
	
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=value;j++)
		{
			dp[i][j]=INT_MAX;
		}
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=value;j++)
		{
			if(j<arr[i].first)
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=min(dp[i-1][j],arr[i].second+dp[i-1][j-arr[i].first]);
			}
		}
	}
	int gg=0;
	for(int i=0;i<=value;i++)
	{
		if(dp[n][i]<=w)
			gg=i;
	}
	cout<<gg<<endl;
return 0;
}

Measured memory_bytes: 79104
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

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

    vector<string> w{"dream", "dreamer", "erase", "eraser"};

    while(true) {
        bool f = false;
        FOR(i,w) {
            int index = (int)s.rfind(*i);
            if(index != -1 && index == s.size()-(*i).size()) {
                s.erase(s.end()-(*i).size(), s.end());
                f = true;
                break;
            }
        }
        if(!f) break;
    }

    if(s.empty()) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    if n == 2:
        print(1)
        return
    if n == 3:
        print(2)
        return
    ans = 0
    for i in range(2, int(sqrt(n)) + 1):
        m = n
        if m % i == 0:
            while m % i == 0:
                m //= i
            if m % i == 1:
                ans += 1
    m = n - 1
    l = []
    for i in range(2, int(sqrt(m)) + 1):
        t = 0
        while m % i == 0:
            m //= i
            t += 1
        if t:
            l.append(t)
    if m != 1:
        l.append(1)
    tmp = 1
    for li in l:
        tmp *= (li + 1)
    print(ans+tmp)

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  int a;
  int min_a=1010, max_a=-1;

  rep(i,n){
    cin >> a;
    min_a = min(min_a, a);
    max_a = max(max_a, a); 
    }

  cout << (max_a - min_a) << endl;
  return 0;
} 

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

using namespace std;

int main()
{
	int n,m;
	while(cin>>n>>m,n)
	{
		vector<int> G[500];
		int u,v;
		for(int i=0;i<m;i++)
		{
			cin>>u>>v;
			u--;v--;
			G[u].push_back(v);
			G[v].push_back(u);
		}
		vector<int> F;
		for(int i=0;i<G[0].size();i++)
		{
			F.push_back(G[0][i]);
			for(int j=0;j<G[G[0][i]].size();j++)
			{
				F.push_back(G[G[0][i]][j]);
			}
		}
		sort(F.begin(),F.end());
		F.erase(unique(F.begin(),F.end()),F.end());
		if(F.size())cout<<F.size()-1<<endl;
		else cout<<F.size()<<endl;
	}
	return 0;
}

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

using namespace std;

long long n, p;

inline long long qpow(long long a, long long p)
{
    long long res = 1;
    for( ; p; p >>= 1, a *= a)
        if(p&1) res *= a;
    return res;
}

int main()
{
    cin >> n >> p;
    double lgp = log(p);
    long long l = 1, r = p/n;
    while(l < r)
    {
        long long mid = (l+r+1)>>1;
        if(lgp/log(mid) < n || qpow(mid, n) > p) r = mid-1;
        else l = mid;
    }
    for(long long i = l; i; i--)
    {
        if(p%qpow(i, n) == 0)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
		
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final String s = sc.next();
			final String s_fst = s.substring(0, (s.length() - 1) / 2);
			final String s_snd = s.substring((s.length() + 3) / 2 - 1);
			//System.out.println(s_fst + " " + s_snd);
			
			boolean answer = true;
			
			for(int i = 0; i < s.length(); i++) {
				if(s.charAt(i) != s.charAt((s.length() - 1) - i)) {
					answer = false;
					break;
				}
			}
			for(int i = 0; i < s_fst.length(); i++) {
				if(s_fst.charAt(i) != s_fst.charAt((s_fst.length() - 1) - i)) {
					answer = false;
					break;
				}
			}
			for(int i = 0; i < s_snd.length(); i++) {
				if(s_snd.charAt(i) != s_snd.charAt((s_snd.length() - 1) - i)) {
					answer = false;
					break;
				}
			}
			
			System.out.println(answer ? "Yes" : "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: 22868
#include<bits/stdc++.h>
using namespace std;

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

const int N = 1e7 + 2 ;
int min_div[N] , dp[N] ;

ll f ( int n )
{
    ll ans = 1 ;
    while ( n > 1 )
    {
        int d = min_div[n] ;
        int exp = 0 ;

        while ( n % d == 0 )
            n /= d , exp ++ ;

        ans *= ( exp + 1 ) ;
    }

    return ans ;
}

void solve ( int test_case )
{
    ll n ;
    cin >> n ;

    for ( int i = 2 ; i*i <= n ; i ++ )
    {
        if ( min_div[i] ) C ;

        for ( int j = i*i ; j <= n ; j += i )
        {
            if ( min_div[j] == 0 )
                min_div[j] = i ;
        }
    }

    for ( int i = 1 ; i <= n ; i ++ )
    {
        if ( min_div[i] == 0 )
            min_div[i] = i ;
    }

    ll ans = 0 ;

    for ( ll i = 1 ; i <= n ; i ++ )
    {
        ans += i * f ( i ) ;
    }

    cout << ans ; line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 42720
h,w = map(int, input().split())
grid = [list(input()) for _ in range(h)]


dx = [-1,-1,-1,0,0,1,1,1]
dy = [-1,0,1,-1,1,-1,0,1]

for i in range(h):
    for j in range(w):
        if grid[i][j] == ".":
            cnt = 0
            for k in range(8):
                nx = j + dx[k]
                ny = i + dy[k]            
                if (nx < 0) or (w-1 < nx) or (ny < 0) or (h-1 < ny):
                    continue
                elif grid[ny][nx] == "#":
                    cnt += 1
                else:
                    pass
            grid[i][j] = cnt
for i in range(h):
  ans = ''.join(map(str,grid[i]))
  print(ans)

Measured memory_bytes: 9196
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();//メニューの数
    int p = 0;
    int q = 0;
    int aa = (1<<m) - 1; //2^m-1
    int bb = 0;
    //System.out.println(aa);

    for(int i=0; i<n; i++){
      int lo = sc.nextInt();
      for(int k=0; k<lo; k++){
        p = sc.nextInt();
        q =  q + (int)Math.pow(2,p-1);
      }
      if(i==0){
        bb = q & aa;
      }else{
        bb = bb & q;
      }

      q =0;

    }

    System.out.println(Integer.bitCount(bb));












  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 1e9+7;

vector<ll> fact,ifact,inv,pow2;
ll add(ll a, ll b)
{
	a+=b; a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	if(a>MOD) a%=MOD;
	if(b>MOD) b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}
ll pw(ll a, ll b)
{
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

const bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll n; cin>>n;
	cout<<add(add(pw(10,n), pw(8,n)),add(-pw(9,n),-pw(9,n)))<<'\n';
	
	return 0;
}


Measured memory_bytes: 3656
a = Hash.new(0)
n = gets.to_i
n.times do
    k = gets.to_i
    a[k] += 1
end
a = a.to_a
cnt = 0
(0..a.length - 1).each  do |i|
    if a[i][1] % 2 != 0
    cnt += 1
    end
end
puts cnt


Measured memory_bytes: 13180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll n, m, ans = 1;
	cin>>n>>m;
	vlli s(n), t(m), p(n, 0);
	scan(s, 0, n);
	scan(t, 0, m);
	forn(i, 0, m){
		ll x = 0;
		forn(j, 0, n){
			if(j == 0){
				x = add(x, p[j]);
				if(s[j] == t[i]){
					p[j] = add(p[j], 1);
				}
			} else {
				if(s[j] == t[i]){
					ll y = add(x, p[j]);
					p[j] = add(p[j], add(x, 1));
					x = y;
				} else {
					x = add(x, p[j]);
				}
			}
		}
	}
	forn(i, 0, n){
		ans = add(ans, p[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
string a;
string b;
int main()
{
    cin>>a;
	cin>>b;
	if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int N,K;
    cin >> N>>K;
    vector<int> l(N);
    for (int i = 0; i < N;i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());

    int sum = 0;
    for (int i = 0; i < K;i++){
        sum += l[i];
    }
    cout << sum;
}

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

typedef long long LL;
LL Q, H, S, D, N;

template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

int main() {
	in(Q), in(H), in(S), in(D), in(N);
	if ((Q << 3) < D) D = Q << 3;
	if ((Q << 2) < S) S = Q << 2;
	if ((Q << 1) < H) H = Q << 1;
	if ((H << 2) < D) D = H << 2;
	if ((H << 1) < S) S = H << 1;
	if ((S << 1) < D) D = S << 1;
	printf("%lld\n", (N >> 1) * D + (N & 1) * S);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main() {
 int N,B;
 scanf("%d",&N);  
 while(N!=0)
 {   
  B=N%10;
 
  if(B==7) {
  printf("Yes");
  break;
  }
  N=N/10;
 }  
  if(B!=7)
  printf("No");    
    
 return 0;
}

Measured memory_bytes: 1720
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  (n:k:_) <- map read . words <$> getLine :: IO [Int]
  s <- getLine :: IO String
  print $ solve n k s

solve n k s = go k counts
  where
    counts = unfoldr f s
    f :: String -> Maybe (Int, String)
    f [] = Nothing
    f (s:ss) = Just (1 + (length . takeWhile (==s) $ ss), dropWhile (==s) ss)

    go 0 cs = (sum cs) - (length cs)
    go i (c0:c1:c2:cs) = go (i-1) $ (c0+c1+c2):cs
    go _ cs = (sum cs) - 1


Measured memory_bytes: 14716
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong x;
  scanf("%lld", &x);

  llong ans = 0;
  ans += (x / 11) * 2;
  x %= 11;

  if(x != 0 && x <= 6){
    ans += 1;
  }else if(x > 6){
    ans += 2;
  }

  printf("%lld\n", ans);
  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(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    char a, b;
    cin >> a >> b;

    if(a == 'H'){
        cout << b << endl;
    }else{
        if(b == 'H'){
            cout << 'D' << endl;
        }else{
            cout << 'H' << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static boolean judge(String s, String p){
        String ss = s.concat(s);
        if(ss.contains(p))
            return true;
        return false;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String p = sc.next();
        if(judge(s,p))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

using namespace std;
using ll = long long;

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

  const double pi = acos(-1);

  int r;
  cin >> r;
  cout << fixed << setprecision(2) << 2 * pi * r << endl;

  return 0;
}


Measured memory_bytes: 3812
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let X = xs[0];
   let Y = xs[1];
   let ans = 0;
     if(X%Y==0){
       ans = -1;
     }else{
       ans = X;
     }
    console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
import sys
input = lambda: sys.stdin.readline().rstrip()
r, c, k = map(int, input().split())
pt = [[0 for _ in range(c + 5)] for _ in range(r + 5)]

for i in range(k):
    r1, c1, v = map(int, input().split())
    pt[r1][c1] = v

memo = [[0] * 4 for _ in range(c + 1)]
prev = [[0] * 4 for _ in range(c + 1)]
for i in range(1, r + 1):
    memo, prev = prev, memo
    for j in range(1, c + 1):
        V = pt[i][j]
        memo[j][0] = max(prev[j][3], memo[j - 1][0])
        memo[j][1] = max(memo[j][0] + V, memo[j - 1][1])
        memo[j][2] = max(memo[j][1], memo[j - 1][1] + V, memo[j - 1][2])
        memo[j][3] = max(memo[j][2], memo[j - 1][2] + V, memo[j - 1][3])
print(memo[-1][3])


Measured memory_bytes: 149724
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


/*
int N;
Graph G;

int main() {
  cin >>N;
  rep(i, N-1){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b); G[b].push_back(a);
  }
}
*/

int main() {
  int n,k; cin >>n >>k;
  cout <<n-k+1 <<endl;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                a, b, c = sorted([L[i], L[j], L[k]])
                if c < a + b and a != b and b != c and c != a:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68332
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define True 1
#define False 0
#define MAX 1000

int top, S[MAX];

void push(int);
int pop(void);

int main()
{
  int a,b,ret;
  char s[100];
  
  top = 0;

  while(1){
    if(scanf("%s",s) == EOF)break;
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }else {
      push(atoi(s));
    }
  }

  printf("%d\n",pop());  

  return 0;
}

void push(int x){
  S[++top] = x;
}

int pop(void){
  top--;
  return S[top+1];
}




Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,x,t;
  cin >> n >> x >> t;
  int ans = 0, tot = 0;
  while(n>tot){
    ans+=t;
    tot+=x;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] ans = new int[3];
        for(int i = 0; i < 3; i++){
            ans[i] = sc.nextInt();
        }
        System.out.println(ans[2] + " " + ans[0] + " " + ans[1]);
    }

}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
ll nxt(){ll x;cin>>x;return x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int h,w,k;
	cin>>h>>w>>k;
	vector<string> a(h);
	for(auto& it:a) cin>>it;
	int ans=INF;
	forn(par,1<<(h-1)){
		int sz=1+__builtin_popcount(par);
		vector<int> cnt(sz);
		int tmp=__builtin_popcount(par);
		int last=0;
		forn(i,w){
			int now=0;
			forn(j,h){
				if(a[j][i]=='1') cnt[now]++;
				if(par>>j&1) now++;
			}
			if(*max_element(all(cnt))>k){
				if(i==last){
					tmp=INF;
					break;
				}
				tmp++;
				cnt=vector<int>(sz);
				last=i;
				i--;
			}
		}
		ans=min(ans,tmp);
	}
	cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s;
    cin>>n;
    p=0;
    while(n){
        n=n/2;
        p++;
    }
    ans=1;
    rep(i,0,p)
    ans=ans*2;
    cout<<ans-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF 2000000000
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define msi map<string,int>
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define TRvi(c,it) for(vi::iterator it=(c).begin();it!=(c).end();it++)
#define TRvii(c,it) for(vii::iterator it=(c).begin();it!=(c).end();it++)
#define TRmsi(c,it) for(msi::iterator it=(c).begin();it!=(c).end();it++)


using namespace std;


int main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
 	int N;
 	cin >> N;
 	int dp[N+1];
 	dp[0]=0;
 	REP(i,1,N)
 		dp[i]=1000000;
 	REP(i,0,N-1)
 	{
 		dp[i+1]=min(dp[i]+1,dp[i+1]);
 		for(int j=6;i+j<=N;j*=6)
 			dp[i+j]=min(dp[i+j],dp[i]+1);
 		for(int j=9;i+j<=N;j*=9)
 			dp[i+j]=min(dp[i+j],dp[i]+1);
 	}
 	cout << dp[N];
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
int ans = 0;
	ll L,R; cin >> L >> R;
	ll D = R - L;
	int l = L % 2019;
	int r = R % 2019;
	vector<int> v;
	if(D >= 2019);
	else
	{
		if(l > r);
		else{
			FOR(i,l,r)
			{
				int p;
				FOR(j,i+1,r+1)
				{
					p = (j*i)%2019;
					v.PB(p);
				}
			}
			sort(ALL(v));
			ans = v.at(0);
		}
	}
	


	cout << ans << endl;
}



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

bool clear;
map<int, set<int>> Next;

void check(vector<int> &v);
void f(vector<int> &v, int val) {
    if(val == 10) {
        check(v);
        return;
    }
    f(v, val + 1);
    for(int i = 0; i < v.size(); i++) {
        v[i] |= (1 << val);
        f(v, val + 1);
        v[i] &= ~(1<<val);
    }
    v.push_back(1 << val);
    f(v, val + 1);
    v.pop_back();
}

void check(vector<int> &v) {
    if(v.size() <= 1) return;
    int used = 0;
    for(int i = 0; i < v.size(); i++) {
        used |= v[i];
    }
    bool deadlock = true;
    for(int i = 0; i < v.size(); i++) {
        bool NowDeadlock = false;
        for(auto itr = Next[v[i]].begin(); itr != Next[v[i]].end(); itr++) {
            if((used >> *itr) & 1) NowDeadlock = true;
        }
        if(!NowDeadlock) deadlock = false;
    }
    if(deadlock) clear = false;
    /*
    if(deadlock) {
        cerr << used << endl;
        for(int i = 0; i < v.size(); i++) {
            cerr << v[i] << " ";
        }
        cerr << endl;
    }
    */
    return;
}

int main() {
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        string S;
        cin >> S;
        clear = true;
        Next.clear();
        int now = 0;
        for(int i = 0; i < S.size(); i++) {
            if(S[i] == 'u') {
                now = 0;
                continue;
            }
            int nownum = (int)(S[i] - '0');
            if((now >> nownum) & 1) clear = false;
            Next[now].insert(nownum);
            now |= (1 << nownum);
        }
        /*
        for(int i = 0; i < (1 << 10); i++) {
            if(Next[i].empty()) continue;
            cerr << "----" << i << "----" << endl;
            for(auto itr = Next[i].begin(); itr != Next[i].end(); itr++) {
                cerr << *itr << " ";
            }
            cerr << endl;
        }
        */
        vector<int> v;
        f(v, 0);
        if(clear) cout << "SAFE" << endl;
        else cout << "UNSAFE" << endl;
    }
}


Measured memory_bytes: 3400
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

int gcd(int a, int b) {
	if (a > b) {
		swap(a, b);
	}
	if (a == 0) {
		return b;
	}

	return gcd(b%a, a);
}

int main() {
	int n, m;

	cin >> n >> m;
	vector<int> a(n);
	bool isHcm = true;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] /= 2;
	}
	int g = a[0];
	long long lcm = 1;
	for (int i = 0; i < n; i++) {
		g = gcd(lcm, a[i]);
		lcm = lcm * a[i] / g;
		if (lcm > m) {
			isHcm = false;
			break;
		}
	}
	/*
	map<int, int> p;

	for (int i = 0; i < n; i++) {
		int num = a[i];
		
		for (int j = 2; j < sqrt(a[i])+1; j++) {
			int cnt = 0;
			while (num%j == 0) {
				cnt++;
				num /= j;
			}
			
			if (cnt > 0) {

				if (p[j] < cnt) {
					p[j] = cnt;
				}
			}
		}

		if (num != 0) {
			if (p[num] < 1) {
				p[num] = 1;
			}
		}
		
	}
	long long  lcm = 1;
	for (auto it = p.begin(); it != p.end(); it++) {
		
		for (int i = 0; i < it->second; i++) {
			lcm *= it->first;
		}
	}
	*/
	
	//cout << lcm << endl;
	if (isHcm) {
		for (int i = 0; i < n; i++) {
			if ((lcm / a[i]) % 2 == 0) {
				isHcm = false;
				break;
			}
		}
	}

	int ans = 0;
	if (isHcm) {
		int num = m / lcm;
		ans = (num / 2) + num % 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

main() {
    
        int m,f,b;
  
        scanf("%d %d %d\n", &m,&f,&b);
        
        int a=b-m;
        
        if(a>f){
            printf("NA\n");
        }else{
            if(a<0){
                printf("0\n");
            }else{
                printf("%d\n",a);
            }
        }

    
  
  return 0;
}


Measured memory_bytes: 2108
import math

a,b = map(int, input().split())
t = 1
x = False
y = False
z = False

while t <= 10000:
    c = math.floor(t * 0.08)
    d = math.floor(t * 0.1)
    
    if c == a:
        x = True
    else:
        x = False
        
    if d == b:
        y = True
    else:
        y = False
        
    if x and y:
        print(t)
        z = True
        break
        
    t = t + 1

if z == False:
    print('-1')

Measured memory_bytes: 3188
def main():
    H, W, K = (int(i) for i in input().split())
    c = [input() for i in range(H)]
    ans = 0
    from itertools import combinations
    for i in range(H+1):
        for j in range(W+1):
            for sh in combinations(range(H), i):
                for sw in combinations(range(W), j):
                    v = 0
                    for h in sh:
                        for w in sw:
                            if c[h][w] == "#":
                                v += 1
                    if v == K:
                        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68208
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

int main(){

    int n,soma=0,a,b;

    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        soma=soma+(b-a);
    }
    soma+=n;

    printf("%d\n",soma);


    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

		
		
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		String s = scan.next();
		
		boolean flg = true;
		
		if (!s.substring(0, a).matches("[0-9]{" + a + "}")) {
			flg = false;
		}
		
		if (!s.substring(a, a + 1).equals("-")) {
			flg = false;
		}
		
		if (!s.substring(a + 1).matches("[0-9]{" + b + "}")) {
			flg = false;
		}
		
		if (flg) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  ll a,b;
  scanf("%lld%lld",&a,&b);
  if (a%b) cout<<a<<endl;
  else cout<<-1<<endl;
  return 0;
}






















Measured memory_bytes: 256
import Prelude

main :: IO ()
main = do
  [x, y] <- readInts
  putStrLn $ if isGroupOf x == isGroupOf y then "Yes" else "No"

isGroupOf :: Int -> Int
isGroupOf n = fst $ head $ filter (elem n . snd) groups

groups :: [(Int, [Int])]
groups = zip [0..] [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]

readInts :: IO [Int]
readInts = map read . words <$> getLine


Measured memory_bytes: 508