akhauriyash/Code-Regression huggingface dataset:
import java.awt.*;
import java.util.*;

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] field = new boolean[h][w];

        for(int i = 0; i < h; i++){
            String s = sc.next();
            for(int j = 0; j < w; j++){
                field[i][j] = s.charAt(j) == '.';
            }
        }

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

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(field[i][j]){
                    int[][] count = new int[h][w];
                    for(int[] a : count){
                        Arrays.fill(a, -1);
                    }
                    count[i][j] = 0;
                    LinkedList<Point> q = new LinkedList<>();
                    q.add(new Point(j, i));
                    while(!q.isEmpty()){
                        Point p = q.poll();
                        for(int k = 0; k < 4; k++){
                            int y = p.y + dy[k];
                            int x = p.x + dx[k];
                            if(x < 0 || y < 0 || x >= w || y >= h){
                                continue;
                            }
                            if(!field[y][x] || count[y][x] > -1){
                                continue;
                            }
                            count[y][x] = count[p.y][p.x] + 1;
                            max = Math.max(max, count[y][x]);
                            q.add(new Point(x, y));
                        }
                    }
                }
            }
        }

        System.out.print(max);

    }
}

Measured memory_bytes: 28756
#include <stdio.h>

long long K,P[55],up[55];

int main()
{
	int N = 50;
	scanf ("%lld",&K);
	for (int i=0;i<N;i++) up[i] = K / N, P[i] = N-1;
	for (int i=0;i<K%N;i++) up[i]++;

	for (int i=0;i<N;i++){
		P[i] += up[i] * N;
		for (int j=0;j<N;j++) if (i != j) P[j] -= up[i];
	}

	printf ("%d\n",N);
	for (int i=0;i<N;i++) printf ("%lld%c",P[i], i+1<N?' ':'\n');

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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()
{
  int n; cin >> n;
  int k; cin >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(), p.end());
  int res = 0;
  rep(i,k) res += p[i];
  cout << res << "\n";
  return 0;
}


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

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

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

// Self settings
// clang-format off
#define MAX_N 200000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
int A[MAX_N];
int B[MAX_N];

int median(int arr[], int num)
{
  if (num % 2 == 0) {
    return (arr[num / 2] + arr[(num / 2) - 1]) / 2;
  }
  else {
    return arr[num / 2];
  }
}

int main(void)
{
  cin >> N;
  REP(i, N) cin >> A[i];

  REP(i, N) B[i] = A[i] - (i + 1);
  sort(B, B + N);

  int b = median(B, N);
  ll sum = 0;
  REP(i, N) sum += abs(B[i] - b);
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll x;
	cin >> x;
	
	ll ans = 0LL;
	while( ans * (ans + 1LL) / 2LL < x ) {
		ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
}


Measured memory_bytes: 256
import math
def check(n,a):
    l1 = []
    l2 = []
    count1 = 0
    count2 = 0
    for i in range(len(a)):
        if a[i]%n > n - a[i]%n:
            count1 = count1 + n - a[i]%n
            l1.append(n-a[i]%n)
        else:
            count2 = count2 + a[i]%n
            l2.append(a[i]%n)
    b = (count2 - count1) // n
    l1.sort(reverse=True)
    l2.sort(reverse=True)
    if b == 0:
        return count1
    elif b > 0:
        for i in range(b):
            count2 = count2 - l2[i]
        return count2
    else:
        for i in range(-1*b):
            count1 = count1 - l1[i]
        return count1
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = sum(a)
l = []
for i in range(1,int(math.sqrt(p))+1):
    if p%i == 0:
        l.append(i)
        if i != p//i:
            l.append(p//i)
l.sort(reverse=True)
for i in range(len(l)):
    if check(l[i],a) <= k:
        print(l[i])
        break

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

bool ok;
int K;

void dfs(int k, int a, int b, int c) {
    if(k == K) {
        if(a < b and b < c) ok = true;
    }
    else {
        dfs(k+1, a*2, b, c);
        dfs(k+1, a, b*2, c);
        dfs(k+1, a, b, c*2);
    }
}

int main() {
    int A, B, C; cin >> A >> B >> C >> K;
    ok = false;
    dfs(0, A, B, C);
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

int n,c,k,t[100010];

int main(){
    cin>>n>>c>>k;
    for (int i=1; i<=n; i++) cin>>t[i];
    sort(t+1,t+1+n);
    int u=t[1]+k, ans=1, cnt=1;
    for (int i=2; i<=n; i++){
        if (t[i]<=u && cnt<c) cnt++;
        else if (cnt+1>c || t[i]>u) cnt=1,u=t[i]+k,ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskD {
        public void solve(int testNumber, MyScan in, PrintWriter out) {
            HashMap<Integer, Integer> sums = new HashMap<>();
            sums.put(0, 1);
            int n = in.nextInt();
            int m = in.nextInt();
            int cur = 0;
            long res = 0;
            while (n-- > 0) {
                cur += in.nextInt();
                cur %= m;
                res += sums.getOrDefault(cur, 0);
                sums.merge(cur, 1, Math::addExact);
            }
            out.println(res);

        }

    }

    static class MyScan {
        private final InputStream in;
        private byte[] inbuf = new byte[1024];
        public int lenbuf = 0;
        public int ptrbuf = 0;

        public MyScan(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 30124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n,k;cin>>n>>k;
  vector<ll> h(n);
  repl(i,n){
    cin>>h[i];
  }
  sort(all(h));
  k=n-k;
  ll ans=0;
  repl(i,k){
    ans+=h[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INt_MAX
#define inf llONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 2e5 + 10;

pair < ll, ll > a[N], tmp;
ll c[N];
ll dp[100];

bool cmp(pair < ll, ll > A, pair < ll, ll > B) {
    return A.fir * (B.sec + 1) > B.fir * (A.sec + 1);
}

void solve() {

    int n; ll t;
    scanf("%d %lld", &n, &t);
    int cnt1 = 0, cnt2 = 0;
    rep(i, 1, n) {
        scanf("%lld %lld", &tmp.fir, &tmp.sec);
        if(tmp.fir == 0) c[++ cnt2] = tmp.sec + 1;
        else a[++ cnt1] = tmp;
    }

    sort(c + 1 , c + cnt2 + 1);
    sort(a + 1, a + cnt1 + 1, cmp);

    rep(i, 1, 30) dp[i] = t + 1;
    dp[0] = 0;
    rep(i, 1, cnt2 ) c[i] += c[i - 1];

    for(int i = 1; i <= cnt1 ;i ++)
    {
      for(int j = 30 ;j >= 1 ;j --)
       dp[j] = min(dp[j] , (dp[j - 1] + 1) * (a[i].first + 1)+ a[i].second) ;
    }
    int ans = 0 ;
    for(int i = 0 ;i <= 30 ;i ++)
     {
       if(dp[i] > t) continue ;
       int j = 0 ;
       if(cnt2)
        j = upper_bound(c + 1 , c + cnt2 + 1 , t - dp[i]) - c - 1;
       ans = max(ans , i + j) ;
     }
    printf("%d\n", ans);
    return ;
}
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>

typedef struct {
    int tx, ty;
    int power;
    int time;
} CHEESE;

CHEESE queue[400000];
int head, tail;

void enq(CHEESE t)
{
    queue[tail % 400000] = t;
    tail++;
}

void deq(CHEESE *t)
{
    *t = queue[head % 400000];
    head++;
}

int main(void)
{
    CHEESE first, temp;
    int x, y, ch;
    int i, j;
    static char map[1001][10001];
    static char v[1001][1001];
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    
    scanf("%d%d%d", &y, &x, &ch);
    getchar();
    
    for (i = 0; i < y; i++){
        for (j = 0; j < x; j++){
            scanf("%c", &map[i][j]);
            if (map[i][j] == 'S'){
                first.tx = j;
                first.ty = i;
            }
        }
        getchar();
    }
    
    first.time = 0;
    first.power = 1;
    v[first.ty][first.tx] = 1;
    memset(v, 0, sizeof(v));
    head = tail = 0;
    enq(first);
    
    while (head != tail){
        deq(&temp);
        
        if (temp.power == ch + 1){
            printf("%d\n", temp.time);
            break;
        }
        
        for (i = 0; i < 4; i++){
            first = temp;
            first.tx = temp.tx + dx[i];
            first.ty = temp.ty + dy[i];
            first.time = temp.time + 1;
            if (0 <= first.tx && first.tx < x && 0 <= first.ty && first.ty < y && !v[first.ty][first.tx] && map[first.ty][first.tx] != 'X'){
                v[first.ty][first.tx] = 1;
                if (map[first.ty][first.tx] == '.' || map[first.ty][first.tx] - '0' != temp.power){
                    enq(first);
                }
                else {
                    first.power = temp.power + 1;
                    memset(v, 0, sizeof(v));
                    v[first.ty][first.tx] = 1;
                    head = tail = 0;
                    enq(first);
                    break;
                }
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

string res;

bool check(string s){
	rep(i,s.size()){
		if(s[i] != 'x') res+=s[i];
	}

	rep(i,res.size() / 2){
		if(res[i] != res[res.size() - 1 - i]){
			return false;
		}
	}
	return true;
}

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

	if(s.size() == 1){ //文字が一文字
		cout << 0 << endl;
		return 0;
	}

	if(not check(s)){
		cout << -1 << endl;
		return 0;
	}

	if(res.size() == 0){
		cout << 0 << endl;
		return 0;
	}

	int i = 0, cnt = 0;
	if(res.size() % 2){
		while(cnt != res.size() / 2 + 1){
			if(s[i] != 'x') cnt++;
			if(cnt == res.size() / 2 + 1) break;
			i++;
		}
	}else{
		while(cnt != res.size() / 2){
			if(s[i] != 'x') cnt++;
			if(cnt == res.size() / 2) break;
			i++;
		}
	}

	int start = i;
	i++;
	while(s[i] == 'x'){
		i++;
	}

	int left, right;
	if(res.size() % 2 == 1){ //文字が中心
		left = start - 1;
		right = start + 1;
	}else{ //xが真ん中になる
		int x = i - start - 1; //xの数
		//show(x);

		if(x % 2){
			start += x / 2 + 1;
			left = start - 1;
			right = start + 1;
		}else{
			start += x / 2;
			left = start;
			right = start + 1;
		}
	}

	//cout << left << ' ' << right << endl;
	int ans = 0;
	for(int j = 0; true; j++){
		if(left < 0 && right >= s.size()) break;
		else if(left < 0){
			ans++;
			right++;
		}else if(right >= s.size()){
			ans++;
			left--;
		}else if(s[left] == s[right]){
			left--;
			right++;
		}else if(s[left] == 'x' && s[right] != 'x'){
			ans++;
			left--;
		}else if(s[left] != 'x' && s[right] == 'x'){
			ans++;
			right++;
		}
	}
	cout << ans << endl;
}


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

int main() 
{ 
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll i,ans = 0;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());
    ans = a[0];
    int cnt = 2;
    if(cnt==n)
    {
        cout<<ans;
        return 0;
    }
    for(i=1;i<n;i++){
        ans = ans+a[i];
        cnt++;
        if(cnt==n)
            break;
        ans = ans+a[i];
        cnt++;
        if(cnt==n)
            break;
    }
    cout<<ans; 
    return 0; 
} 

Measured memory_bytes: 4804
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, K;
    cin >> N >> K;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
        A[i]--;
    }

    mat dest(61, vec(N));
    Rep (i, N) {
        dest[0][i] = A[i];
    }

    Rep (i, 60) {
        Rep (j, N) {
            dest[i+1][j] = dest[i][dest[i][j]];
        }
    }

    // Rep (i, 5) {
    //     Rep (j, N) {
    //         cout << dest[i][j] << " \n"[j==N-1];
    //     }
    // }

    ll now = 0;
    while (K) {
        for (ll i = 60; i >= 0; i--) {
            if (K & ((ll)1 << i)) {
                now = dest[i][now];
                K -= ((ll)1 << i);
            }
        }
        // cout << K << "\n";
    }

    cout << now + 1 << "\n";
}

Measured memory_bytes: 101732
n,m = list(map(int, input().split()))
k = [list(map(int, input().split()))[1:] for i in range(m)]
p = list(map(int, input().split()))

ans=0
for i in range(2**n):
    # 1,2,3...,Nのスイッチの状態
    state=[(i>>j)&1 for j in range(n)]
#    print('state=',state)
    ok=1
    for ii, x in enumerate(k):
#        print('x=',x)
        on_cnt=0
        for y in x:
            if state[y-1]==1:
                on_cnt+=1
        if on_cnt%2!=p[ii]:
            ok=0
            break
    if ok==1:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll a, b, k;
	ll now = 0;

	cin >> a >> b >> k;

	RFOR(i, 0, min(a, b) + 1) {
		if (!(a % i) && !(b % i)) {
			now++;
		}
		if (now == k) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int a, b;
  int i;

  for(;;) {

    std::cin >> a >> b;

    if( std::cin.eof() ) { break; }

    a = a + b;

    for(i = 1; i < 9; i++) {
      if(a <= 9) {
        break;
      }
      a /= 10;
    }
    std::cout << i << std::endl;

  }

  return 0;
}

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

using namespace std;

using ll = long long;

tuple<int, int, int> Solve() {
    int n, y;
    cin >> n >> y;

    const vector<int> a = {10000, 5000, 1000};
    for (int i = 0; i <= n && a[0] * i <= y; ++i) {
        int res = y - a[0] * i;
        for (int j = 0; i + j <= n && a[1] * j <= res; ++j) {
            if (a[0] * i + a[1] * j + a[2] * (n - i - j) == y)
                return make_tuple(i, j, n - i - j);
        }
    }

    return make_tuple(-1, -1, -1);
}

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

    auto ans = Solve();
    cout << get<0>(ans) << ' ' << get<1>(ans) << ' ' << get<2>(ans) << '\n';

    return 0;
}


Measured memory_bytes: 256
# %% constants
# ------------

# %% body
# -------

function main(io = stdin)
    readto(target = '\n') = readuntil(io, target)
    readnum(T::Type{<:Number} = Int; dlm = isspace, kwargs...) =
        parse.(T, split(readto(), dlm; kwargs...))

    # handle IO and and stuff
    X, = readnum()
    println(X ≥ 30 ? "Yes" : "No")
end

function solve()
    # ...
end

@static if @isdefined(Juno) || @isdefined(VSCodeServer)
    main(open(replace(@__FILE__, r"(.+)\.jl" => s"\1.in")))
else
    main()
end


Measured memory_bytes: 186508
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <random>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <complex>
#include <functional>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> int(a);)
#define all(v) v.begin(),v.end()
#define trav(x, v) for(auto &x : v)
#define sz(v) int((v).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vi in(n), out(n);
	vector<vi> gr(n);
	vector<vi> type(n);
	rep(_,0,m){
		int a,b;
		cin >> a >> b;
		--a, --b;
		++in[a], ++out[b];
		gr[a].push_back(b), gr[b].push_back(a);
		type[a].push_back(1);
		type[b].push_back(2);
	}
	ll ans = 0;
	vector<bool> vis(n);
	vector<int> col(n);
	rep(i,0,n) if(!vis[i]){
		bool paint = 0, paintall = 0;
		int stor = 0;
		int es = 0;
		ll cnt[3] = {};
		function<void(int)> f = [&](int v){
			++cnt[col[v]];
			vis[v] = 1;
			es += in[v];
			++stor;
			paint |= in[v] && out[v];
			rep(i,0,sz(gr[v])){
				int u = gr[v][i];
				int ucol = (col[v]+type[v][i])%3;
				if(!vis[u]){
					col[u] = ucol;
					f(u);
				} else if(col[u] != ucol){
					paintall = 1;
				}
			}
		};
		f(i);
		if(paintall)
			ans += (ll)stor*(stor-1) + stor;
		else if(paint)
			ans += cnt[0]*cnt[1] + cnt[1]*cnt[2] + cnt[2]*cnt[0];
		else
			ans += es;
	}
	cout << ans << endl;
}

Measured memory_bytes: 18688
N, M = map(int, input().split())
route = [[0 for i in range(N)] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    route[a-1][b-1] += 1
    route[b-1][a-1] += 1
for i in route:
    print(sum(i))


Measured memory_bytes: 9004
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
char a[105], b[105];
int main(){
	scanf("%s", a);
	scanf("%s", b);
	int x = strlen(a);
	int y = strlen(b);
	if(x > y)
		printf("GREATER\n");
	else if(x < y)
		printf("LESS\n");
	else{
		int flag = 0;
		for(int i = 0; i < x; i++){
			if(a[i] > b[i]){
				flag = 1;
				break;
			}
			if(a[i] < b[i]){
				flag = 2;
				break;
			}
		}
		if(flag == 0)
			printf("EQUAL\n");
		else if(flag == 1)
			printf("GREATER\n");
		else 	printf("LESS\n");
	}
	return 0;
}

Measured memory_bytes: 128
import math
n = int(input())
max_cakes = math.ceil(n/4)
max_donuts = math.ceil(n/7)
flag = 0
for i in range(max_cakes+1):
    for j in range(max_donuts+1):
        if 4*i+7*j == n:
            flag = 1
if flag:print("Yes")
else:print("No")

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var answer = true;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] != t[t.Length - 1 - i]) answer = false;
            }
            Console.WriteLine(answer ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 25744
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
int main(void)
{
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, 0, n)
    {
        int tmp;
        cin >> tmp;
        if (tmp >= k)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
n = int(input())
cnt = 0
ca = 0
cb = 0
cab = 0
for i in range(n):
    tmp = input()
    cnt += tmp.count("AB")
    if tmp[0] == "B" and tmp[-1] == "A":
        cab += 1
    elif tmp[0] == "B" and tmp[-1] != "A":
        cb += 1
    elif tmp[0] != "B" and tmp[-1] == "A" :
        ca += 1
if ca == cb == 0 and cab > 0:
    cnt -= 1
print(cnt + cab + min(ca, cb))


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)

struct query
{
    ll l, r;
};
ll Q;
vector<query> queries;

bool is_prime(ll n)
{
    if (n < 2)
    {
        return false;
    }
    ll i = 2;
    while (i * i <= n)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    ll right = INT64_MIN;
    ll left = INT64_MAX;
    cin >> Q;
    queries.resize(Q);
    rep(i, queries.size())
    {
        cin >> queries[i].l >> queries[i].r;
        left = min(left, queries[i].l);
        right = max(right, queries[i].r);
    }
    vector<ll> dp((right - left) / 2 + 1);
    for (ll i = left; i <= right; i += 2)
    {
        ll j = (i - left) / 2;
        if (j != 0)
        {
            dp[j] = dp[j - 1];
        }
        if (is_prime(i) && is_prime((i + 1) / 2))
        {
            dp[j]++;
        }
    }
    for (query query : queries)
    {
        ll ans = 0;
        ans += dp[(query.r - left) / 2];
        if (query.l != left)
        {
            ans -= dp[(query.l - left) / 2 - 1];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 2560
/*
h3110_fr13nd,
 
AUTHOR : @sam_jn
*/
 
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------// 

void solve(){   
    ll a, b, c, k;
    ll ans = 0;
    cin >> a >> b >> c >> k;
    ans += min(a, k);
    k -= ans;
    // ans += min(b, k);
    k -= min(b, k);
    ans -= min(c, k);
    cout << ans;
}
int main(){


                                                            // #ifndef ONLINE_JUDGE    
                                                            // freopen("/home/samyak/Desktop/CP/input.txt", "r", stdin);
                                                            // freopen("/home/samyak/Desktop/CP/output2.txt", "w", stdout);
                                                            // #else
                                                            // // online submission
                                                            // #endif


    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}

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

using namespace std;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define ll long long
const int maxn=1e6+10;
const int mod=1e9+7;
const double pi=acos(-1);


ll qpow(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % mod;
            b--;
        }
        b >>= 1;
        a = a * a % mod;
    }
    return ans;
}
void extgcd(ll a,ll b,ll& d,ll& x,ll& y){
    if(!b){ d=a; x=1; y=0;}
    else{ extgcd(b,a%b,d,y,x); y-=x*(a/b); }
}
ll inverse(ll a,ll n){
    ll d,x,y;
    extgcd(a,n,d,x,y);
    return d==1?(x+n)%n:-1;
}

ll C(ll n, ll m)
{
    ll ans=1;
    m=min(m,n-m);
    for(int i=1;i<=m;i++)
    {
        ans=ans*n%mod;
        n--;
        ans=ans*inverse(i,mod)%mod;
    }
    return ans;
}

int main()
{
    int n,a,b;
    sint(n);
    sint2(a,b);
    if(n<=2)
        cout<<0;
    else
    {
        ll ans=qpow(2,n);
        ans=(ans-C(n,a)+mod)%mod;
        ans=(ans-C(n,b)+mod)%mod;
        cout<<ans-1;
    }
    return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n,k;
  int cnt=0;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]>=k)
      cnt++;
  }
  cout << cnt << endl;
}

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

int main(){
	int w, c;
	bool f;
	while (cin >> w && w != -1) {
		c = 1150;
		f = false;
		if (w > 30) {
			c += (w - 30) * 160;
			f = true;
		}
		if (w > 20) {
			if (f) {
				c += 1400;
			}
			else {
				c += (w - 20) * 140;
				f = true;
			}
		}
		if (w > 10) {
			if (f) {
				c += 1250;
			}
			else {
				c += (w - 10) * 125;
				f = true;
			}
		}
		cout << 4280 - c << endl;
	}

	return 0;
}

Measured memory_bytes: 3092
n = int(input())
ls = [[_ for _ in input().split()] for _ in range(n)]
x = input()

idx = 0
ans = 0

for i in range(n):
    if ls[i][0] == x:
        idx = i
        break

for j in range(idx + 1, n):
    ans += int(ls[j][1])

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int main(void){
    int N;
    scanf("%d", &N);
    int temp;
    int max = INT_MIN;
    int min = INT_MAX;
    int i;
    for(i=0; i<N; i++) {
        scanf("%d", &temp);
        if(temp < min) {
            min = temp;
        }
        if(temp > max) {
            max = temp;
        }
    }
    printf("%d\n", max-min);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <string>

using namespace std;

int main() {
	string str;
	int i;
	int sum;
	char numstr[10];
	while(1) {
		getline(cin, str);

		if(str == "0") break;
		sum = 0;
		for(i = 0; i < str.size(); i++) {
			sprintf(numstr, "%c", str[i]);
			sum += atoi(numstr);
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3268
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

struct Point{
	double x, y;
};


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

	int n;
	cin >> n;

	vi A(n), B(n);
	REP(i, n) {
		cin >> A[i] >> B[i];
	}

	LL ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		LL diff = (ans + A[i]) % B[i];

		if (diff) {
			ans += B[i] - diff;
		}
	}

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

Measured memory_bytes: 1152
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
#define N 3
#define N2 9

struct Puzzle{
	int f[N2];
	int space;
	string path;
	
	bool operator < (const Puzzle &p)const
	{
		REP(i,N2)
		{
			if(f[i]==p.f[i])continue;
			return f[i]>p.f[i];
		}
		return false;
	}
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool istgt(Puzzle p)
{
	REP(i,N2)
	{
		if(p.f[i]!=(i+1))return false;
	}
	return true;
}

string bfs(Puzzle s)
{
	queue<Puzzle> Q;
	map<Puzzle,bool> V;
	Puzzle u,v;
	s.path="";
	Q.push(s);
	V[s]=true;
	
	while(!Q.empty())
	{
		u=Q.front();Q.pop();
		if(istgt(u))return u.path;
		int sx=u.space/N;
		int sy=u.space%N;
		REP(r,4)
		{
			int tx=sx+dx[r];
			int ty=sy+dy[r];
			if(tx<0||ty<0||tx>=N||ty>=N)continue;
			v=u;
			swap(v.f[u.space],v.f[tx*N+ty]);
			v.space=tx*N+ty;
			if(!V[v])
			{
				V[v]=true;
				v.path+=dir[r];
				Q.push(v);
			}
		}
	}
	return "unsolvable";
}

int main()
{
	Puzzle in;
	REP(i,N2)
	{
		cin>>in.f[i];
		if(in.f[i]==0)
		{
			in.f[i]=N2;
			in.space=i;
		}
	}
	string ans=bfs(in);
	cout<<ans.size()<<endl;
	return 0;
}

Measured memory_bytes: 30524
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1e9+9;
const int INF = 1e9;

int main(){
    ll n, h;
    cin >> n >> h;
    vector<ll> a(n), b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    ll A_MAX = a[n-1];
    sort(b.rbegin(), b.rend());
    int ans = 1e9;
    rep(k,n+1){
        if (k > 0) h -= b[k-1];
        int cnt = 0;
        if (h > 0) cnt = (h+A_MAX-1) / A_MAX;
        ans = min(ans, k+cnt);
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector< vi > vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

main(){
  int n,k;
  cin >> n >> k;
  int x,ans=0;
  rep(i,n){
    cin >> x;
    ans+=2*min(x,abs(k-x));
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, x, y, f[2005]={0}, minn;
int main()
{
      ios::sync_with_stdio(), cin.tie(0), cout.tie(0);
      cin >> n >> x >> y;
      for (ll i=1; i<=n; i++)
      {
            for (ll j=i+1; j<=n; j++)
            {
                  minn=min(j-i, abs(x-i)+1+abs(j-y));
                  f[minn]++;
            }
      }
      for (ll i=1; i<n; i++)
      {
            cout << f[i] << endl;
      }
      return 0;
}


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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)

bool primes[100001]={};
int likes[100001]={};
 // 66 primes
int main(){
	int q,l,r;
	int ruiseki=0;
	REP3(i,2,318){//篩
		REP3(j,2,100001){
			if(j>i&&j%i==0)primes[j]=true;//逆だよ
		}
	}
	primes[1]=true;

	REP3(i,1,100001){
		if(i%2&&!primes[i]&&!primes[i/2+1])ruiseki++;
		likes[i]=ruiseki;
	}

	cin>>q;
	REP(i,q){
		cin>>l>>r;
		cout<<likes[r]-likes[l-1]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    int r,c,i,j;
    ll sumr;
    int arr[200][200];
    scanf("%d%d",&r,&c);
    for(i=0;i<r;i++)
    {
        sumr=0;
        for(j=0;j<c;j++)
        {
            scanf("%d",&arr[i][j]);
            sumr+=arr[i][j];
            printf("%d ",arr[i][j]);
        }
        printf("%d\n",sumr);
        arr[i][j] = sumr;
    }
    for(i=0;i<=c;i++)
    {
        sumr=0;
        for(j=0;j<r;j++)
        {
            sumr+=arr[j][i];
        }
        printf("%d%c",sumr,(i!=c)?' ':'\n');
    }
    return 0;
}




Measured memory_bytes: 2060
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
    static ArrayList<Coordinate> list;
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
        list = new ArrayList<Coordinate>();
	Coordinate p1 = new Coordinate(0, 0);
	Coordinate p2 = new Coordinate(100, 0);
	koch(n, p1, p2);
	list.add(0, p1);
	list.add(list.size(), p2);
	Coordinate c;
	for (int i = 0; i < list.size(); i++) {
	    c = list.get(i);
	    System.out.println(c.x + " " + c.y);
	}
    }
    static void koch (int n, Coordinate p1, Coordinate p2) {
	if (n == 0) {
	    return;
	}
	Coordinate s, t, u;
	double sx, sy, tx, ty, ux, uy, radian60;
	sx = (2 * p1.x + p2.x) / 3;
	sy = (2 * p1.y + p2.y) / 3;
	tx = (p1.x + 2 * p2.x) / 3;
	ty = (p1.y + 2 * p2.y) / 3;
	s = new Coordinate(sx, sy);
	t = new Coordinate(tx, ty);
	radian60 = Math.toRadians(60);
	ux = (t.x - s.x) * Math.cos(radian60) - (t.y - s.y) * Math.sin(radian60) + s.x;
	uy = (t.x - s.x) * Math.sin(radian60) + (t.y - s.y) * Math.cos(radian60) + s.y;
	u = new Coordinate(ux, uy);
	koch(n-1, p1, s);
	list.add(s);
	koch(n-1, s, u);
	list.add(u);
	koch(n-1, u, t);
	list.add(t);
	koch(n-1, t, p2);
    }

}
class Coordinate {
    double x, y;
    Coordinate (double x, double y) {
	this.x = x;
	this.y = y;
    }
}

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

int main(){
  int n; cin>>n;
  if(n>=1 && n<=13 && n!=4 && n!=7 && n!=8 && n!=12 && n!=11) cout<<"No"<<endl;
  else if(n==17) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int h,w,fir[10],las[10];
bool ans=1;
char a[10][10];
int main() {
    cin>>h>>w;
    for(int i=1;i<=h;i++) {
        scanf("%s",a[i]+1);
        int num=0;
        for(int j=1;j<=w;j++) {
            if(a[i][j]=='#'&&a[i][j+1]!='#')
                num++,las[i]=j;
            if(!fir[i]&&a[i][j]=='#')
                fir[i]=j;
        }
        if(num!=1) ans=0;
        if(fir[i]!=las[i-1]&&i>1) ans=0;
    }
    if(a[h][w]!='#') ans=0; 
    ans ? cout<<"Possible\n":cout<<"Impossible\n";
    return 0;
}


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

int main(){
  int A[3];
  cin >> A[0] >> A[1] >> A[2];

  sort(A, A+3);

  int cost = 0;
  for(int i = 1; i < 3; i++) {
    cost += abs(A[i] - A[i-1]);
  }

  cout << cost << endl;

  return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n;
bool appear[30005];

const int LIM = 30000;

int main(){
	scanf("%d", &n);
	if(n == 3){
		printf("2 5 63\n");
		return 0;
	}
	
	appear[2] = appear[4] = true;
	appear[3] = appear[9] = true;
	n -= 4;
		
	for(int i = 8; i <= LIM && n > 1; i += 6){
		appear[i] = true;
		appear[i + 2] = true;
		n -= 2;
	}
	for(int i = 15; i <= LIM && n > 1; i += 12){
		appear[i] = true;
		appear[i + 6] = true;
		n -= 2;
	}
	for(int i = 6; i <= LIM && n > 0; i += 6){
		appear[i] = true;
		n--;
	}
	for(int i = 1; i <= LIM; i++){
		if(appear[i]){
			printf("%d ", i);
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 384
# B
def keta(n):
    count = 0
    while n != 0:
        n = n//10
        count+=1
    return count

n  = int(input())
k = keta(n)
if k == 1:
    print(n)
elif k == 2:
    print(9)
elif k == 3:
    print(9 + n-99)
elif k == 4:
    print(909)
elif k == 5:
    print(909 + n-9999)
elif k == 6:
    print(90909)
    

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long x, y; cin >> x >> y;
  long long cnt = 0;
  while (x <= y) {
    cnt++;
    x *= 2;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> Vec<T>
where
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).unwrap();
    b.split_whitespace()
        .map(|x| x.trim().parse::<T>().unwrap())
        .collect()
}

fn main() {
    let _ = read::<i64>()[0];
    let ai = read::<i64>();

    let mut ans0 = ai[0];
    let mut ans1 = -ai[0];

    for x in 1..ai.len() {
        let a = ai[x];
        let n0 = std::cmp::max(ans0 + a, ans1 - a);
        let n1 = std::cmp::max(ans0 - a, ans1 + a);
        ans0 = n0;
        ans1 = n1;
    }

    println!("{}", ans0);
}


Measured memory_bytes: 8444
import sys


class AlgSegmentTreeMin:
    def __init__(self, n, default_value):
        self.Nelem = n
        self.default_value = default_value
        self.size = 1 << (n.bit_length())
        self.data = [self.default_value] * (2 * self.size)

    def build(self):
        # raw_data は 0-indexed
        for i, x in enumerate([self.default_value] * (self.Nelem + 1)):
            self.data[self.size + i] = x
        for i in range(self.size - 1, 0, -1):
            x = self.data[i + i];
            y = self.data[i + i + 1]
            self.data[i] = x if x < y else y

    def update(self, i, x):
        i += self.size
        self.data[i] = x
        i >>= 1
        while i:
            x = self.data[i + i]
            y = self.data[i + i + 1]
            self.data[i] = min(x, y)
            i >>= 1

    def get_value(self, left, right):
        left += self.size
        right += self.size + 1
        x = self.default_value
        while left < right:
            if left & 1:
                y = self.data[left]
                x = min(x, y)
                left += 1
            if right & 1:
                right -= 1
                y = self.data[right]
                x = min(x, y)
            left >>= 1
            right >>= 1
        return x


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    stree = AlgSegmentTreeMin(n, 10 ** 15)
    stree.build()
    lrc = [list(map(int, readline().split())) for _ in range(m)]
    lrc.sort()
    stree.update(0, 0)
    for l, r, c in lrc:
        l -= 1
        r -= 1
        tm = stree.get_value(l, r)
        now = stree.get_value(r, r)
        tm = tm + c if tm + c < now else now
        stree.update(r, tm)
    mt = stree.get_value(n-1, n)
    print(mt if mt != stree.default_value else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 97244