akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int sl = s.length();
    vector<int> a(sl + 1, 0);
    ll ans = 0;
    rep(i, sl - 1) {
        if ((s[i] == '>') && (s[i + 1] == '<')) {
            rreps(ii, 1, i + 1) {
                if (s[ii] != '>') break;
                a[ii] = max(a[ii], a[ii + 1] + 1);
            }
            reps(ii, i + 1, sl) {
                if (s[ii] != '<') break;
                a[ii + 1] = max(a[ii + 1], a[ii] + 1);
            }
        }
    }
    rep(i, sl) {
        if (s[i] == '<') {
            a[i + 1] = max(a[i + 1], a[i] + 1);
        }
    }
    rrep(i, sl) {
        if (s[i] == '>') {
            a[i] = max(a[i], a[i + 1] + 1);
        }
    }
    rep(i, sl + 1) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2844
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         long N=gl();
         List<Long> l=insuB(N);
         Map<Long,Integer> m=new HashMap<Long,Integer>();
         for(int i=0; i<l.size();i++) {
        	 if(m.containsKey(l.get(i))) {
        		 m.put(l.get(i), m.get(l.get(i))+1);
        	 } else {
        		 m.put(l.get(i), 1);
        	 }
         }

         int ans=0;
         for(Integer v : m.values()) {
        	 int tmp=1;
        	 while(v-tmp>=0) {
        		 v-=tmp;
        		 tmp++;
        		 ans++;
        	 }
         }

         System.out.println(ans);
     }

  // 素因数分解
 	public static List<Long> insuB(long n) {
 		List<Long> l=new ArrayList<Long>();
 		long tmp=n;
 		for(long i=2; i<=Math.sqrt(n); i++) {
 			while(tmp%i==0) {
 				tmp=tmp/i;
 				l.add(i);
 			}
 		}
 		if(tmp!=1) l.add(tmp);

 		return l;
 	}

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35560
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while (cin >> n, n)
	{
		int a[100];
		for (int i = 0;i < n;i++)cin >> a[i];
		sort(a, a + n);
		int sum = 0;
		for (int i = 1;i < n - 1;i++)
		{
			sum += a[i];
		}
		cout << sum / (n - 2) << endl;
	}
}

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

#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;



int main(){
    int n,m;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string tmp;
        cin >> tmp;
        mp[tmp] = 1;
    }
    cin >> m;
    int cnt = 1;
    rep(i,m){
        string tmp;
        cin >> tmp;
        if(mp[tmp] == 0) {
            cout << "Unknown " << tmp << endl;
        }else{
            cnt++;
            if(cnt % 2 == 0) {
                cout << "Opened by " << tmp << endl;
            }else{
                cout << "Closed by " << tmp << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3244
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            long a = In[0];
            long b = In[1];
            long c = In[2];
            long d = In[3];
            long[] A = new long[] { a * c, a * d, b * c, b * d };
            long max = -1001001001001001001;
            foreach(var i in A)
            {
                max = (long)Math.Max(max, i);
            }
            Console.WriteLine(max);
        }
    }
    //class Program
    //{
    //    static void Main(string[] args)
    //    {
    //        int[] In = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    //        long a = In[0];
    //        long b = In[1];
    //        long c = In[2];
    //        long d = In[3];
    //        if(0<a && 0 <c)
    //        {
    //            Console.WriteLine(b * d);
    //        }
    //        else if(b<=0 && d <= 0)
    //        {
    //            Console.WriteLine(a*c);
    //        }
    //        else
    //        {
    //            Console.WriteLine(-1 * (int)Math.Min(Math.Abs(a), Math.Abs(a)) * (int)Math.Min(Math.Abs(c), Math.Abs(d)));
    //        }
    //    }
    //}
}


Measured memory_bytes: 28296
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct segtree{
  ll M=1, INIT;
  vector<ll> dat;
  segtree(ll N, ll num){
    INIT = num;
    while(M<N) M*=2;
    for(int i=0;i<M*2-1;i++)  dat.push_back(num);
  }
  void update(ll x, ll k, ll l=0, int r=-1){
    if(r==-1) r = M;
    k+=M-1;
    dat[k] = x;
    while(k>0) k = (k-1)/2, dat[k] = min(dat[k*2+1],dat[k*2+2]);
  }
  ll query(ll a, ll b=-1, ll k=0, ll l=0, ll r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return INIT;
    if(a<=l && r<=b) return dat[k];
    ll A = query(a, b, k*2+1, l, (l+r)/2);
    ll B = query(a, b, k*2+2, (l+r)/2, r);
    return min(A, B);
  }
};
int main(int argc, char const *argv[]) {
  ll n, e, t;std::cin >> n >> e >> t;
  vll x(n+1, -10000000000);re(i, n) scanf("%lld", &x[i+1]);

  ll INF = 1000000000000000000;
  vll dp(n+1, INF);
  dp[0] = e;
  segtree seg(n+1, INF);
  seg.update(dp[0]-2*x[1], 0);

  for(int now=1;now<=n;now++){
    ll l = lower_bound(all(x), x[now]-t/2) - x.begin();

    if(now!=1){
      dp[now] = dp[max((ll)0, l-1)] + t;
      dp[now] = min(dp[now], 2*x[now]+seg.query(0, l-1));
    }else{
      dp[now] = dp[0] + t;
    }
    if(now!=n) seg.update(dp[now]-2*x[now+1],now);
  }

  //std::cout << dp[1] << '\n';
  //std::cout << dp[2] << '\n';
  std::cout << dp[n] << '\n';
  return 0;
}


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

long long f(long long n, long long x){
  if(n == -1) return 0;
  else return (n / x + 1);
}

signed main(){
  long long a,b,x;
  cin >> a >> b >> x;
  cout << f(b,x) - f(a-1,x) << endl;
}

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

int main() {
    int n;

    cin >> n;

    int x[n];
    int b[n];

    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }

    for(int i = 0; i < n; i++) {
        b[i] = x[i];
    }

    sort(x, x + n);
   
    for(int i = 0; i < n; i++) {
        if(b[i] <= x[(n - 1) / 2]) {
            cout << x[(n + 1) / 2] << endl;
        }
        else {
            cout << x[(n - 1) / 2] << endl;
        }
    }

}

Measured memory_bytes: 3712
def main():
    import fractions

    a, b, c, d = [int(i) for i in input().split()]

    d_c = b // c - (a-1) // c
    d_d = b // d - (a-1) // d

    cd = c * d // fractions.gcd(c, d)
    d_cd = b // cd - (a - 1) // cd

    print(b-a + 1 - (d_c + d_d - d_cd))


if __name__ == "__main__":
    main()



Measured memory_bytes: 10568
from collections import deque
H,W,s,t = input().split()
H = int(H)
W = int(W)
M = [(".") * (W + 2)]
E = {}

for i in range(0,H):
    a = input()
    M.append("." + a + ".")

M.append((".") * (W + 2))
H = H + 2
W = W + 2

for h in range(0,H):
    for w in range(0,W):
        if M[h][w] not in [".","-","|","o"]:
            E[M[h][w]] = [h,w]

G = {k:[] for k in E.keys()}
for e,(h,w) in E.items():
    if M[h][w+2] == "-":
        i = 2
        while M[h][w+i] == "-":
            i += 1

        G[e].append(M[h][w+i+1])

    if M[h][w - 2] == "-":
        i = 2
        while M[h][w - i] == "-":
            i += 1

        G[e].append(M[h][w - i - 1])

    if M[h + 2][w] == "|":
        i = 2
        while M[h + i][w] == "|":
            i += 1

        G[e].append(M[h + i + 1][w])

    if M[h - 2][w] == "|":
        i = 2
        while M[h - i][w] == "|":
            i += 1

        G[e].append(M[h - i - 1][w])

visited = {k:False for k in E.keys()}
Q = deque([[s,0]])
while Q:
    e,c = Q.popleft()
    visited[e] = True
    for ne in G[e]:
        if ne == t:
            print(c+1)
            Q = []
            break

        if visited[ne] == True:
            continue
        else:
            Q.append([ne,c +1])




Measured memory_bytes: 6024
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
using namespace std;

void test() {
    string s;
    cin >> s;
    if (s.back() == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 3624
using System;

namespace abc101_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int sum = 0;
            for (int i = 0; i < s.Length; i++) sum += int.Parse(s.Substring(i, 1));
            Console.WriteLine(int.Parse(s) % sum == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <unordered_map>
using namespace std;

long long MOD = 1000000007;

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

    unordered_map<long long,long long> M;
    vector<long long> V;
    
    long long s = 0;
    for ( int i = 0; i < N; i++ ) {
        long long a;        
        cin >> a;
        s += a;
        M[s]++;
        V.push_back(s);
    }
    sort( V.begin(), V.end() );

    long long ans = 0;
    for ( int i = 0; i < V.size(); i++ ) {
        if ( ( i == 0 ) ||  ( i && V[i-1] != V[i] ) )  {
            ans += ( M[V[i]]*(M[V[i]]-1) )/2;
        }
    }
    if ( M[0] != 0 ) { ans += M[0]; }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 10044
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
string s;
cin>>s;
stack<char> st;
st.push(s[0]);
for(int i=1;i<s.length();i++)
{
if(st.size()==0)
{
st.push(s[i]);
continue;
}
if(s[i]!=st.top())
{
st.pop();
}
else
{
st.push(s[i]);
}
}
cout<<s.length()-st.size()<<endl;
}

Measured memory_bytes: 3852
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      	
      	//高橋が青木に攻撃
      	int AoCount =0;
      	while(c > 0){
          c -= b; 
          AoCount ++; 
        }
      	
      	//青木が高橋に攻撃
      	int TkCount =0;
      	while(a > 0){
          a -= d; 
          TkCount ++; 
        }

      	if(TkCount<AoCount){
        System.out.println("No");
      }else{
        System.out.println("Yes");
      }
    }
}

Measured memory_bytes: 35692
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{	
	int a, b, m = 0;
	bool f[100];

	memset(f, 0, sizeof(f));

	while (cin >> a >> b) {
		if (a > 0 || b > 0) {
			m = max({ m, a, b });
			f[a - 1] = !f[a - 1];
			f[b - 1] = !f[b - 1];
		}
		else {
			bool g = 1;

			if (f[0] && f[1]) {
				for (int i = 2; i < m; i++) {
					if (f[i]) {
						g = 0;
						break;
					}
				}
			}
			else
				g = 0;

			if (g)
				cout << "OK" << endl;
			else
				cout << "NG" << endl;

			memset(f, 0, sizeof(f));
			m = 0;
		}
	}

	return 0;
}



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

int main(){
  int a = 0;
  int b = 0;
  
  cin >> a >> b;
  
  if(a*b % 2 == 0){
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
  try (Scanner sc = new Scanner(System.in)) { String line = sc.nextLine();
    int length = line.length();
    for (int i = 0; i < length; i++) {
    char ch = line.charAt(i);

    if (Character.isLowerCase(ch)) {
      ch = Character.toUpperCase(ch);
    } else if (Character.isUpperCase(ch)) {
      ch = Character.toLowerCase(ch);
    }
    if (i == length -1) {
      System.out.printf("%c\n", ch);
    } else {
      System.out.printf("%c", ch);
    }
    }
  }
} }



Measured memory_bytes: 29588
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int k[10];
    int s[10][10];
    rep(i, M) {
        cin >> k[i];
        rep(j, k[i]) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    int p[10];
    rep(i, M) cin >> p[i];
    int ans = 0;
    rep(bit, (1 << N)) {
        int cnt[10] = {};
        bool ok = true;
        rep(i, M) {
            rep(j, k[i]) {
                if(bit & (1 << s[i][j])) {
                    cnt[i]++;
                }
            }
            if(cnt[i] % 2 != p[i]) ok = false;
        }
        ans += ok;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;

#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

void test() {
    vvi f(11, vi(11, 0));
    f[0][1] = 1;
    rep(n, 1, 11) {
        rep(m, 1, 11) {
            rep(k, 1, m + 1) {
                f[n][m] += f[n - 1][k];
            }
            debug("f[%d,%d]=%d\n", n, m, f[n][m]);
        }
    }
    int ans = 0;
    rep(m, 1, 11) {
        ans += f[10][m];
    }
    debug("total=%d\n", ans);
}

typedef tuple<int, int, int, int> req;

int n, m, q, ans = 0;
vector<req> reqs;

int score(vi &arr) {
    int ans = 0;
    rep(i, 0, q) {
        auto [a, b, c, d] = reqs[i];
        if (arr[a] + c == arr[b]) {
            ans += d;
        }
    }
    return ans;
}

void dfs(int which, vi &a) {
    if (which >= n) {
        ans = max(ans, score(a));
        return;
    }
    int lb = which == 0 ? 1 : a[which - 1];
    rep(x, lb, m + 1) {
        a.push_back(x);
        dfs(which + 1, a);
        a.pop_back();
    }
}

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

    test();

    cin >> n >> m >> q;
    rep(i, 0, q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--,b--;
        reqs.push_back({a, b, c, d});
    }
    vi a;
    dfs(0, a);
    cout << ans << el;
}


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

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

typedef struct Point {
	double x, y;
	Point operator - (const Point& o) const { return Point{x - o.x, y - o.y}; }
	Point operator + (const Point& o) const { return Point{x + o.x, y + o.y}; }
	Point operator * (double d) const { return Point{x * d, y * d}; }
	Point operator / (double d) const { return Point{x / d, y / d}; }
} Vector;

double angle(double a, double b, double c) { return acos((b * b + c * c - a * a) / (2.0 * b * c)); }
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a)); }
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
Vector unitVector(Vector a) { return a / abs(a); }
Vector rotate(Vector a, double s) { return Vector{a.x * cos(s) - a.y * sin(s), a.x * sin(s) + a.y * cos(s)}; }

int n;
double x[100], y[100], r[100];

pair< Point, Point > crossPoint(int i, int j) {
	Point a{x[i], y[i]}, b{x[j], y[j]};
	Point x = unitVector(b - a) * r[i];
	double s = angle(r[j], abs(b - a), r[i]);
	return pair< Point, Point >(a + rotate(x, s), a + rotate(x, -s));
}

int ccw(Point a, Point b, Point c) {
	Vector ba = b - a, ca = c - a;
	if (cross(ba, ca) > 0) return 1;
	if (cross(ba, ca) < 0) return -1;
	if (dot(ba, ca) < 0) return 2;
	if (abs(ba) < abs(ca)) return -2;
	return 0;
}

void solve() {
	vector< vector< Point > > vp(2, {Point{x[0], y[0]}});
	
	for_(i,0,n-1) {
		pair< Point, Point > cp = crossPoint(i, i + 1);
		vp[0].push_back(cp.first);
		vp[1].push_back(cp.second);
	}
	
	vp[0].push_back(Point{x[n-1], y[n-1]});
	vp[1].push_back(Point{x[n-1], y[n-1]});
	
	assert((int)vp[0].size() == n+1);
	vector< vector< double > > dst(2, vector< double >(n+1, 1e9));
	dst[0][0] = dst[1][0] = 0;
	
	for_(i,0,n) for_(bi,0,2) for_(j,i+1,n+1) for_(bj,0,2) {
		bool flag = true;
		for_(k,i+1,j) flag &= (ccw(vp[bi][i], vp[bj][j], vp[0][k]) * ccw(vp[bi][i], vp[bj][j], vp[1][k]) == -1);
		if (flag) dst[bj][j] = min(dst[bj][j], dst[bi][i] + abs(vp[bi][i] - vp[bj][j]));
	}
	
	printf("%.9f\n", dst[0][n]);
}

int main() {
	while (cin >> n, n) {
		for_(i,0,n) cin >> x[i] >> y[i] >> r[i];
		solve();
	}
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 200003

int main(){
  ll K;
  cin>>K;

  ll res=1;
  ll num=0;
  int i=0;
  while(true){
    num+=7*res;
    num%=K;
    if(num==0){
      cout<<i+1<<endl;
      break;
    }
    i++;
    res*=10;
    res%=K;

    if(i>1000000){
      cout<<-1<<endl;
      break;
    }
  }
}


Measured memory_bytes: 3628
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , ANS = inf  , k ;
void bk ( int i , int sum ){
if ( i == n ){
    ANS = min ( ANS , sum );
    return ;
}
bk(i+1,sum+sum);
bk(i+1,sum+k);
}
int main ( ){
    cin >> n >> k ;
    bk(0,1);
    cout << ANS ;
return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int r, g;
    cin >> r >> g;
    cout << g * 2 - r;
    return 0;
}

Measured memory_bytes: 256
def sum_digits(n):
    s = 0
    while n:
        s += n%10
        n //= 10
    return s

n, a, b = map(int, input().split())

ans = 0
for i in range(1,n+1):
    if a <= sum_digits(i) <= b:
        ans += i
print(ans)

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    bitset<3> bit(s);
    cout << bit.count() << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

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

	sum := 0
	for i := range ls {
		sum += rs[i] - ls[i] + 1
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
#include <chrono>

int fibonacci(int n) {
	if (n < 0)return -1;
	if (n == 0)return 0;
	if (n == 1)return 1;
	return fibonacci(n - 1) + fibonacci(n - 2);
}
int d_fibonacci(int n) {
	int a, b, c;
	a = 0;
	b = 1;
	if (n == 0)return a;
	if (n == 1)return b;
	rep(i, n) {
		c = a + b;
		a = b;
		b = c;
	}
	return c;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long int N, K;
	cin >> N >> K;
	auto M = N % K;
	//cout << M << " " << K - M << endl;
	if (M < K - M) {
		cout << M;
	}
	else {
		cout << K - M;
	}

	return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005

#include <iostream>
using namespace std;
#define ll long long
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N;
  long long L[100];
  cin >> N;
  rep(i, N) {
    cin >> L[i];
  }
  sort(L, L + N);
  long long ans = 0;
  rep(i, N) {
    for(long long j = i+1; j < N; j++) {
      if(L[i] == L[j]) continue;
      for(long long k = i+1; k < j; k++) {
        if(L[k] > L[j]-L[i] && L[k] != L[i] && L[k] != L[j]) {
          // cout << i << " " << j << " " << k << endl;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
n=int(input())
w=list(map(int,input().split()))

l=r=0
i=c=0
j=n-1
for _ in range(n):
    if l<=r:
        l+=w[i]
        i+=1
    else:
        r+=w[j]
        j-=1
    c+=1
    if c==n:
        break
print(abs(l-r))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int n, k;
    cin >> n;
    string s = to_string(n);
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == '7') ans++;
    }

    if(ans > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


void solve(long long A, long long B){
    cout << A*B << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3660
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    val n = scanner.nextInt()
    val reversed =
      Iterator.from(0, 1)
        .takeWhile(_ < n)
        .map(_ => scanner.nextInt())
        .foldLeft(List.empty[Int]) { case (acc, num) => num :: acc }
        .mkString(" ")
    println(reversed)
  }
}

Measured memory_bytes: 45176
#include <bits/stdc++.h>
using namespace std;
const int mn=510;
int n,m,d,id[mn][mn];
int d1[mn][mn],d2[mn][mn];
bool ok(int a) {
	return 1<=a%(2*d)&&a%(2*d)<=d;
}
int main() {
	scanf("%d %d %d",&n,&m,&d);
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			d1[i][j]=i+j-1;
			d2[i][j]=n-(i-j);
		}
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			if (ok(d1[i][j])&&ok(d2[i][j]))
				printf("G");
			else if (ok(d1[i][j])&&!ok(d2[i][j]))
				printf("R");
			else if (!ok(d1[i][j])&&ok(d2[i][j]))
				printf("Y");
			else printf("B");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    bool ok = 0;
    for (int i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            if (i <= 9 && (n / i) <= 9) ok = 1;
        }
    }
    if (!ok) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b,k;
  cin>>a>>b>>k;
  vi v;

  FOR(i,1,1000){
    if(a%i==0&&b%i==0){
      v.PB(i);
    }
  }

  reverse(all(v));
  cout<<v[k-1]<<endl;


}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, _ = rm()
li = np.array([np.array(rl()) for _ in range(n)])
cnt = 0
for i in range(n):
  for j in range(i):
    a = sum((li[i] - li[j]) ** 2)**0.5
    if a - a//1 == 0:
      cnt += 1
print(cnt)









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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005
vi v[100004];
ll vis[100005],dp[100005][2],ans=0;
ll dfs(ll x,ll val,ll p)
{
    if(dp[x][val]!=-1)
        return dp[x][val];
    ll ans=1;
    for(auto i:v[x])
    {
        if(i==p)
            continue;
        dp[i][0]=dfs(i,0,x);
        dp[i][1]=dfs(i,1,x);
        if(val==0)
            ans=(ans*(dp[i][0]+dp[i][1]))%hell;
        else
            ans=(ans*(dp[i][0]))%hell;
    }
    return ans;
}
int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        cin>>n;
        for(i=0;i<n-1;i++)
        {
            cin>>l>>m;
            v[l].pb(m);
            v[m].pb(l);
        }
        clr(vis,0);
        clr(dp,-1);
        dp[1][0]=dfs(1,0,0);
        dp[1][1]=dfs(1,1,0);
        cout<<(dp[1][1]+dp[1][0])%hell;
    }
    return 0;
}

Measured memory_bytes: 16384
import fractions
a, b = map(int,input().split())
gcd = fractions.gcd(a,b)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)
print(len(prime_factorize(gcd))+1)  
  


Measured memory_bytes: 5048
using System.Linq;
using static System.Console;
using static System.Math;
class Z { static void Main() => new _K(); }
class _K
{
	int[] G => Strs.Select(int.Parse).ToArray();
	string[] Strs => ReadLine().Split();
	int K, L;
	readonly int[,,] sum;
	public _K()
	{
		var I = G;
		K = I[1];
		L = 4 * K;
		sum = new int[L + 1, L + 1, 2];
		var tot = new int[2];
		for (var i = 0; i < I[0]; i++)
		{
			var S = Strs;
			var c = S[2] == "B" ? 0 : 1;
			Add(int.Parse(S[0]) % (2 * K) + 1, int.Parse(S[1]) % (2 * K) + 1, c);
			tot[c]++;
		}
		for (var c = 0; c < 2; c++)
		{
			for (var x = 0; x < L; x++) for (var y = 0; y <= L; y++) sum[x + 1, y, c] += sum[x, y, c];
			for (var x = 0; x <= L; x++) for (var y = 0; y < L; y++) sum[x, y + 1, c] += sum[x, y, c];
		}
		var max = 0;
		for (var i = 0; i < K; i++) for (var j = 0; j < K; j++)
			{
				var s = Sum(i, j);
				max = Max(max, Max(s, I[0] - s));
			}
		WriteLine(max);
	}
	void Add(int x, int y, int c)
	{
		sum[x, y, c]++;

		{
			sum[x + 2 * K, y, c]++;
			sum[x + 2 * K, y + 2 * K, c]++;
		}
		sum[x, y + 2 * K, c]++;
	}
	int Sum(int i, int j) => Sum(i, j, 0) + Sum(i + K, j + K, 0) + Sum(i, j + K, 1) + Sum(i + K, j, 1);
	int Sum(int i, int j, int c) => sum[i + K, j + K, c] - sum[i + K, j, c] - sum[i, j + K, c] + sum[i, j, c];
}


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

int convert(int n){
	static int c[8]={0,1,2,3,5,7,8,9};
	return c[n];
}
int main(){
	int n;
	vector<int> v;
	vector<int>::reverse_iterator i;
	while(cin>>n,n){
		v.clear();
		while(n){
			v.push_back(convert(n%8));
			n/=8;
		}
		for(i=v.rbegin();i!=v.rend();++i)
			cout<<*i;
		cout<<endl;
	}
}

Measured memory_bytes: 904
mod = 10**9+7
s = int(input())
df = [0]*2000

df[2] = 1
df[3] = 1
df[4] = 1
temp = 0
for i in range(5, 2000):
    temp+=df[i-3]
    df[i]+=temp+1
    df[i]%=mod
    

    
print(df[s-1])

Measured memory_bytes: 63708
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

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

int state[310][310];
ll d[310][310];
vector<P> edge[310];

#define MAX_V 300


void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    for(int i = 0; i < 310; i++){
        d[s][i] = 1e9+7;
    }
    d[s][s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        ll v = p.sc;
        if(d[s][v] < p.fs){
            continue;
        }
        for(auto e: edge[v]){
            if(d[s][e.fs] > d[s][v] + e.sc){
                d[s][e.fs] = d[s][v] + e.sc;
                que.push(P(d[s][e.fs], e.fs));
            }
        }
    }
}

int main(){
    set<int> sts[310][310];
    ll N, M, L;
    cin >> N >> M >> L;
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edge[a].emplace_back(P(b, c));
        edge[b].emplace_back(P(a, c));
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            state[i][j] = -1;
        }
    }

    for(int i = 0; i < N; i++){
        dijkstra(i);
    }
//    for(int i = 0; i < N; i++){
//        for(int j = 0; j < N; j++){
//            cout << d[i][j] << " ";
//        }
//        cout << endl;
//    }

    for(int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if(d[i][j] <= L){
                state[i][j] = 0;
                sts[i][0].insert(j);
            }
        }
    }

    for(int i = 0; i < N; i++){
        for(int n = 1; n < N; n++){
            bool update = false;
            for(auto v: sts[i][n-1]){
                for(auto u: sts[v][0]) {
                    if (state[i][u] != -1) {
                        continue;
                    }
                    state[i][u] = n;
                    sts[i][n].insert(u);
                    update = true;
                }
            }
            if(!update){
                break;
            }
        }
    }

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << state[s][t] << endl;
    }

    return 0;
}


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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> sumW(n + 1, 0);
    REP(i, n) {
        if (s[i] == 'W') sumW[i + 1] = sumW[i] + 1;
        else sumW[i + 1] = sumW[i];
    }

    vector<int> sumE(n + 1, 0);
    REP(i, n) {
        if (s[i] == 'E') sumE[i + 1] = sumE[i] + 1;
        else sumE[i + 1] = sumE[i];
    }

    int mini = INT_MAX;
    REP(i, n + 1) {
        int toRight = sumW[i];
        int toLeft = sumE[n] - sumE[i];
        mini = min(mini, toRight + toLeft);
    }

    cout << mini << '\n';
    return 0;
}


Measured memory_bytes: 2964
#include<stdio.h>
int main()
{
	int s = 0,h = 0,m = 0,ss = 0;
	scanf("%d", &s);
	h = s / 3600;
	m = (s % 3600)/60;
	ss = s-(h*3600)-(m*60);
	printf("%d:%d:%d\n",h,m,ss);
	return 0;
}

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

int main(void){
    int n,s=0;
    cin>>n;
    int a[n], b[n], c[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        s+=t;
    }
    for(int i=0;i<n-1;i++) cin>>b[i];
    for(int i=0;i<n-1;i++){
        if(a[i]+1==a[i+1]) s+=b[ a[i] - 1 ];
    }
    cout<<s;
}


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

using namespace std;
typedef long long int tkkw; 

tkkw dp[16][16];
	
int main(){
	while(1){
	for(int i=0;i<16;i++){
		for(int j=0;j<16;j++){
			dp[i][j] =0;
		}
	}
	int a,b,n;
	cin >> a>>b;
	if(a==0 && b==0)break;
	cin >> n;
	dp[0][0] = 1;
	for(int i=0; i<n ; i++ ){
		int l,m;
		cin >> l>>m;
		dp[l-1][m-1] = -1;
	}

	for(int i=0;i< a ;i++){
		for(int j=0;j<b; j++){
			if(dp[i][j] ==-1) {
				dp[i][j] =0;
				continue;
			}
			if(i>0) dp[i][j] += dp[i-1][j];
			if(j>0) dp[i][j] += dp[i][j-1];
		}
	}
	cout << dp[a-1][b-1] << "\n";
}
	//cout <<dp[0][0]<< endl;
	return 0;

}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c,d;
  cin>>a>>b>>c>>d;
  long long int cma=(a-1)/c,dma=a/d,cdma=a/((c*d)/__gcd(c,d)),cmb=b/c,dmb=b/d,cdmb=b/((c*d)/__gcd(c,d));
  cout<<b-a+1-cmb-dmb+cdmb+cma+dma-cdma;
  return 0;
}
  

Measured memory_bytes: 256
using System;

class Plogram
{
    static void Main()
    {
        var line = Console.ReadLine().Split();
        int N = int.Parse(line[0]);
        int T = int.Parse(line[1]);
        int min = int.MaxValue;

        for(int i = 0; i<N; i++)
        {
            var ct = Console.ReadLine().Split();
            int c = int.Parse(ct[0]);
            int t = int.Parse(ct[1]);

            if (T >= t)
            {
                if (min > c)
                {
                    min = c;
                }
            }
        }
        if(min == int.MaxValue)
        {
            Console.WriteLine("TLE");
        }
        else
        {
            Console.WriteLine(min);
        }
    }
}

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

int main() {
    int n, x;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        }
        else {
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                else {
                    x /= 10;
                }
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3104
n = int(input())
h = list(map(int, input().split()))

flag = 'Yes'

h.reverse()
for i in range(n-1):
  if h[i] < h[i+1]:
    h[i+1] -= 1
  if h[i+1] > h[i]:
    flag = 'No'
    break
if h[-1] < 0:
  flag = 'No'
print(flag)

Measured memory_bytes: 14224
#!/usr/bin/env python3
# coding: utf-8
import random


class Dice() :

    mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),
            'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1)}
    way = ("N","E","W","S")

    def __init__(self, data):
        self.label = data

    def move(self, data):
        self.label = [self.label[idx] for idx in self.mask[data]]

    def get_up(self):
        return self.label[0]

    def compare(self, dice2):
        ok = False
        for i in range(1000):
            check = True
            for i2 in range(6):
                if self.label[i2] == dice2.label[i2] :
                    continue
                else:
                    check = False
                    break

            if check :
                ok = True
                break
            else:
                self.move(self.way[random.randint(0,3)])
        return ok

dice1 = Dice(input().split())
dice2 = Dice(input().split())

if dice1.compare(dice2) :
    print ("Yes")
else:
    print ("No")


Measured memory_bytes: 8188
import itertools
N, K = map(int, input().split())
xy = []
x, y = [], []
for i in range(N):
    a, b = map(int, input().split())
    xy.append([a, b])
    x.append(a)
    y.append(b)

ans = float('inf')
for sx, ex in itertools.combinations(x, 2):
    for sy, ey in itertools.combinations(y, 2):
        if ex < sx:
            sx, ex = ex, sx
        if ey < sy:
            sy, ey = ey, sy
        s = (ex-sx)*(ey-sy)
        if s == 0:
            continue

        c = 0
        for k in range(N):
            a, b = xy[k]
            if sx <= a and a <= ex and sy <= b and b <= ey:
                c += 1
        if c >= K and s < ans:
            ans = s

print(ans)


Measured memory_bytes: 75292
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//stack<int> st;
// cout << << endl;
// cin >> ;

int main(){
  ll a,b,x=0,y=0,d=0,n,h,w,k,max=-100000,min=100000000000000,ans=1,count=0,sum=0;
  string s;
  cin >> k >> a >> b;

  if(a-1 >= k || abs(a-b)==1 || (a >= b)){
    cout << k + 1 << endl;
    return 0;
  }

  w = k;
  while(w>=a+1){
    w -= a+1;
    ans += b-1;
    if(1 < (b-a)*(0.5)){
      ans = ans + (w/2)*(b-a);
      w = w%2;
    }
  }

  if(w>0)
    ans+=w;

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

Measured memory_bytes: 256
#include<iostream>
  
using namespace std;
  
int bubbleSort(int A[], int N) {
  
   int sw = 0;
   bool flag = 1;
   for (int i = 0; flag; i++) {
       flag = 0;
       for (int j = N - 1; j >= i + 1; j--) {
          if (A[j] < A[j - 1]) {
             swap(A[j], A[j - 1]);
             flag = 1;
             sw++;
          }
       }
   }
   return sw;
}
  
  
int main() {
  
   int A[100], N, sw;
   cin >> N;
  
   for (int i = 0; i < N; i++) 
       cin >> A[i];
  
   sw = bubbleSort(A, N);
  
   for (int i = 0; i < N; i++) {
       if (i) cout << " ";
       cout << A[i];
   }
  
   cout << endl;
   cout << sw << endl;
  
   return 0;
}

Measured memory_bytes: 3080
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

res = -10**12
for i in range(1, 2**10):
    tres = 0
    cnts = [0]*N
    for j in range(10):
        bo = (i>>j) & 1
        for k in range(N):
            cnts[k] += F[k][j] & bo
    for k in range(N):
        tres += P[k][cnts[k]] 
    if res < tres:
        res = tres
print(res)


Measured memory_bytes: 74640
n = int(input())
s = []
for i in range(n):
    ss = sorted(input())
    s.append(''.join(ss))

s.sort()
ans = 0
lcnt = 1
for i in range(1,len(s)):
    if s[i] == s[i-1]:
        lcnt += 1
    else:
        ans += lcnt * (lcnt-1)//2
        lcnt=1

ans += lcnt * (lcnt-1)//2

print(ans)

Measured memory_bytes: 10640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int A[100010], D[100010];

vector<int> kabe;

signed main()
{
    int N, T, Q; cin >> N >> T >> Q;

    rep(i, N) {
        cin >> A[i] >> D[i];
    }

    rep(i, N - 1) {
        if (D[i] == 1 && D[i + 1] == 2) {
            kabe.PB((A[i] + A[i + 1]) / 2);
        }
    }

    rep(i, Q) {
        int x; cin >> x;
        -- x;

        if (D[x] == 1) {
            vi::iterator itr = upper_bound(all(kabe), A[x]);
            if (itr == kabe.end()) {
                cout << A[x] + T << endl;
            } else {
                cout << min(A[x] + T, *itr) << endl;
            }
        } else {
            vi::iterator itr = lower_bound(all(kabe), A[x]);

            if (itr == kabe.begin()) {
                cout << A[x] - T << endl;
            } else {
                itr -= 1;
                cout << max(A[x] - T, *itr) << endl;
            }
        }
    }
}

Measured memory_bytes: 2976
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int n = sc.nextInt();
        _out.printf("ABC%03d\r%n", n);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21844