akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

  int ans = 100;

  for (int i = 0; i < s.size(); ++i)
  {
    string t = s;
    int cnt = 0;
    while (true)
    {
      bool same = true;

      for (int j = 0; j < t.size() - 1; ++j)
      {
        if (t[j] != t[j + 1])
        {
          same = false;
          break;
        }
      }
      if (same)
        break;

      string tmp = "";
      for (int j = 0; j < t.size() - 1; ++j)
      {
        if (t[j] == s[i] || t[j + 1] == s[i])
        {
          tmp += s[i];
        }
        else
        {
          tmp += t[j];
        }
      }
      t = tmp;
      cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.Calendar.Builder;



public class Main {
	static int INF = 2 << 27;
	static int N;
	static int M;
	static int A;
	static int B;
	static int C;
	static int T;
	static long[][] dp;
	public static void main(String[] args) {	
		//FastScanner sc = new FastScanner();
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			N = sc.nextInt();
			M = sc.nextInt();
			A = sc.nextInt();
			B = sc.nextInt();
			C = sc.nextInt();
			T = sc.nextInt();
			
			if(N == 0 && M == 0 && A == 0 && B == 0 && C == 0 && T == 0) break;
			long[] X = new long[N];
			for(int i = 0; i < N; i++) {
				X[i] = sc.nextLong();
			}
			
			long[][] matrix = new long[N][N];
			for(int i = 0; i < N; i++) {
				if(i - 1 >= 0) matrix[i][i - 1] = A;
				matrix[i][i] = B;
				if(i + 1 < N) matrix[i][i + 1] = C;
			}
			
			String TB = Integer.toBinaryString(T);
			long[][] mt = new long[N][N];
			for(int i = 0; i < N; i++) {
				mt[i][i] = 1;
			}
			for(int i = 0; i < TB.length(); i++) {
				if(TB.charAt(TB.length() - i - 1) == '1') {
					mt = mul(mt, matrix);
					mt = mod(mt);
				}
				matrix = mul(matrix,matrix);
				matrix = mod(matrix);
				
			}
			
			
			
			for(int i = 0; i < N; i++) {
				long ans = 0;
				for(int j = 0; j < N; j++) {
					ans = (mt[i][j] * X[j] + ans) % M;
				}
				if(i != 0) System.out.print(" " + ans);
				else System.out.print(ans);
			}
			System.out.println();
		}
	}
	static long[][] mul(long[][] a, long[][] b) {
		int n = a.length;
		long[][] ret = new long[n][n];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				for(int k = 0; k < n; k++) {
					ret[i][j] = (a[i][k] * b[k][j] + ret[i][j]);
				}
			}
		}
		return ret;
	}
	static long[][] mod(long[][] a) {
		long[][] ret = new long[a.length][a.length];
		for(int i = 0; i < a.length; i++) {
			for(int j = 0; j < a[i].length; j++) {
				ret[i][j] = a[i][j] % M;
			}
		}
		return ret;
	}
	
	static long[][] add(long[][] a, long[][] b) {
		int n = a.length;
		long[][] ret = new long[n][n];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				ret[i][j] = (a[i][j] + b[i][j]);
			}
		}
		return ret;
	}

}

Measured memory_bytes: 65552
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  long int n, k;
  long int ans = 0;
  long int a[100001];
  long int b[100001];
  long long int cnt[100001] = {0};

  // nとkを取得して
  scanf("%ld%ld", &n, &k);

  // a[], b[] も取得する
  for(long int i = 0; i < n; i++){
    scanf("%ld%ld", &a[i], &b[i]);
    // どの値が何個あるか格納しておく
    cnt[a[i]] += b[i];
  }

  /* 
  for(long int i = 0; i < n; i++){
    for(long int j = 0; j < b[i]; j++){
      cnt[a[i]]++;
    }
  } 
  */
  //  qsort(c, n, sizeof(long long int), compare_int);
  //  qsort(r, n, sizeof(long int), compare_int_small)  //  fprintf(stderr, "l[0] = %ld  r[0] = %ld\n", l[0], r[0]);

  long long int j = 0;
  // kが0以下になった時の値が答えになる
  while(k > 0){
    fprintf(stderr, "j = %lld\n", j);
    ans = j;
    k -= cnt[j];
    j++;
  }
  
  
  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}
template <typename T>
T Min(T a) {
    return a;
}

template <typename T, typename... Args>
T Min(T a, Args... args) {
    return std::min(Min(args...), a);
}

int main() {
    auto v = IntsIn(3);
    auto ans = 0LL;
    if ((v[0] % 2 == 1) && (v[1] % 2 == 1) && (v[2] % 2 == 1)) {
        ans = Min(v[0] * v[1], v[1] * v[2], v[2] * v[0]);
    }
    PUTS(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll gcd(ll a, ll b, ll c) { return gcd(a,gcd(b,c));}
int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i,n)rep(j,n)rep(k,n){
    ans += gcd( i+1, j+1, k+1 );
  }
  cout << ans << endl;
}


Measured memory_bytes: 3192
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	d, _ := strconv.Atoi(sc.Text())

	var ans int
	for i := 0; i < n; i++ {
		sc.Scan()
		f, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		s, _ := strconv.Atoi(sc.Text())
		if d >= int(math.Ceil(math.Sqrt(float64((f*f)+(s*s))))) {
			ans++
		}

	}
	fmt.Println(ans)
}


Measured memory_bytes: 4904
n = int(input())
s = input()
white = 0
red = 0
white_ren = 0
red_ren = 0
for i in range(n):
    if s[i] == "W":
        white += 1
    else:
        red += 1
for i in range(red):
    if s[i] == "R":
        red -= 1
for i in range(white):
    if s[-i - 1] == "W":
        white -= 1
remain = white + red
ans1 = min(red, white)
remain -= 2 * ans1
print(remain + ans1)


Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string weather;
  cin >> weather;
  if (weather == "Sunny") {
  	cout << "Cloudy" << endl;
  } else if (weather == "Cloudy") {
  	cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}

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

int main(void)
{
	long long int n, x = 1, y = 1, min = 10000000000000;
	scanf("%lld", &n);
	for (int i = 1; i <= (long long int)sqrt(n); i++) {
		if (n % i == 0) {
			x = n / i - 1;
			y = i - 1;
			if ((x + y) < min)min = x + y;
		}
	}
	printf("%lld\n", min);
	return 0;
}


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

typedef long long ll;

int const MAX_V = 100001;
int const MAX_E = 200001;
int const INF = 1<<29;

vector<int> G[MAX_V];
int ord[MAX_V], low[MAX_V];

vector<int> tree[MAX_V];
ll size[MAX_V];
ll A[MAX_V];

void dfs(int pos){
  size[pos]=A[pos];
  for(int i=0;i<(int)tree[pos].size();i++){
    int to=tree[pos][i];
    dfs(to);
    size[pos]+=size[to];
  }
}

int V,E;
void init();
vector<int> ans;

void rec(int pos,int prev,int& k){
  low[pos]=ord[pos]=k++;
  int flg=0,child=0;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(ord[to]==-1){
      tree[pos].push_back(to);

      child++;
      rec(to,pos,k);
      low[pos]=min(low[pos],low[to]);
      if(low[to]>=ord[pos]&&prev!=-1)flg=true;
    }
    low[pos]=min(low[pos],ord[to]);
  }
  if(prev==-1&&child>=2)flg=true;
  if(flg)ans.push_back(pos);
}

void init() {
  ans.clear();
  for(int i=0;i<V;i++){
    low[i]=INF;
    ord[i]=-1;
    G[i].clear();
  }
}

ll total=0;
int vd[MAX_V];
ll mem[MAX_V];

ll solve(int x){

  if(vd[x])return mem[x];
  vd[x]=1;

  if(x==0){
    ll res=0;
    for(int i=0;i<(int)tree[x].size();i++){
      int to=tree[x][i];
      res=max(res, size[to]);
    }
    return mem[x]=res;
  }

  if(!binary_search(ans.begin(),ans.end(),x)){
    mem[x]=total-A[x];
    return mem[x];
  }

  ll res=0;
  ll ps=total-size[x];

  for(int i=0;i<(int)tree[x].size();i++){
    int to=tree[x][i];
    if(low[to]>=ord[x]){
      res=max(res,size[to]);
    }else{
      ps+=size[to];
    }
  }
  res=max(res,ps);
  return mem[x]=res;
}



int main(){

  scanf("%d %d",&V,&E);
  init();
  for(int i=0;i<V;i++){
    scanf("%lld",&A[i]);
    total+=A[i];
  }

  for(int i=0;i<E;i++){
    int u, v;
    scanf("%d %d",&u,&v);
    u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  int k=0;
  for(int i=0;i<V;i++)
    if(ord[i]==-1)
      rec(i,-1,k);

  dfs(0);

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


  for(int i=0;i<V;i++) {
    printf("%lld\n",solve(i));
  }

  //for(int i=0;i<V;i++)cout<<low[i]<<' '<<ord[i]<<' '<<i<<endl;

  return 0;
}

Measured memory_bytes: 16320
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define PQ priority_queue
#define pb push_back
#define fu(i,a,j) for(int i=a;i<j;i++)
#define fd(i,a,j) for(int i=a;i>=j;i--)
#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define MOD 1000000007 
#define MOD2 1000000021
#define MAXN 2000000
#define INF 1e9
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;

//ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }
ll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };
db dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }
int dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };
int dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };

int n, m, k, t;

string ansok[2] = { "NO","YES" };
ll a[200001];

int main()
{
	SYNC;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll ans = 0;
	int mn = a[0];
	for (int i = 1; i < n; i++) {
		if (a[i - 1] > a[i]) {
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 5236
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                    # ll = deepcopy(l)
from heapq import *                    # heappush(hp,x)
from string import *                # alpha = ascii_lowercase
from random import *                # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                # minn = -maxsize
from operator import *                # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                # pre = [0] + list(accumulate(l))
from decimal import Decimal         # a = Decimal(a)    # use this for math questions
from collections import Counter        # d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
    n = len(l)
    xor = 0
    for i in l:
        xor ^= i
    ans = []
    for i in l:
        ans.append(xor^i)
    return ans
    

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(*ans)



Measured memory_bytes: 32944
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
  	int i[5],k;
  	int index = 0;
  	int last_order= -1;
  	while(cin >> i[index])
    {
      if(last_order == -1 && i[index] % 10 != 0) last_order = index;
      else if(i[index] % 10 != 0 && i[last_order] % 10 > i[index] %  10) last_order = index;

      index++;
      if(index == 5) break;
    }
  	int time = 0;
  	if(last_order == -1)
    {
      time = i[0] + i[1] + i[2] + i[3] + i[4];
    }else
    {
      for(index = 0;index < 5;index++)
      {  
      	if(index == last_order) time += i[index];
      	else
        {
          if(i[index] % 10 == 0) time += i[index];
          else
          {
            time += (i[index]/ 10 + 1) * 10;
          }
        }
      }
  	
    }
  	cout << time << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<std::queue<int>> queues(n);
	for (auto i = 0; i < m; ++i) {
		int type, second_info; std::cin >> type >> second_info;
		int min = INT_MAX;
		switch (type) {
		case 0:
			std::cout << queues[second_info - 1].front() << '\n';
			queues[second_info - 1].pop();
			break;
		case 1:
			for (auto j = 0; j < queues.size(); ++j) {
				min = std::min(min, (int)queues[j].size());
			}
			for (auto& queue : queues) {
				if (queue.size() == min) {
					queue.push(second_info);
					break;
				}
			}
			break;
		default: throw 0;
		}
	}
}


Measured memory_bytes: 3180
#include <iostream>
#include <stdio.h>

using namespace std;

int n;
int a[500005];
int lf[500005 / 2];
int rt[500005 / 2];
int count = 0;

void merge(int l, int mid, int r) {
    int n1 = mid - l;
    int n2 = r - mid;
    for (int i = 0; i < n1; i++) {
        lf[i] = a[l + i];
        rt[i] = a[mid + i];
    }
    for (int i = 0; i < n2 - n1; i++) {
        rt[n1 + i] = a[mid + n1 + i];
    }
    lf[n1] = 2000000000;
    rt[n2] = 2000000000;
    int i = 0;
    int j = 0;
    for (int k = l; k < r; k++) {
        count++;
        if (lf[i] <= rt[j]) {
            a[k] = lf[i];
            i++;
        } else {
            a[k] = rt[j];
            j++;
        }
    }
}

void mergeSort(int l, int r) {
    if (l + 1 < r) {
        int mid = (l + r) / 2;
        mergeSort(l, mid);
        mergeSort(mid, r);
        merge(l, mid, r);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    mergeSort(0, n);
    for (int i = 0; i < n; i++) {
        if (i) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n%d\n", count);
    return 0;
}

Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int a,b;
    cin>>a>>b;
    cout<<6-(a+b);
}

Measured memory_bytes: 256
n, r, t = gets.split.map &:to_i
pace = n.times.map { gets.to_i }
ans = 0
cnt = [0] * r
pos = [0] * n
t.times do |time|
	n.times { |i| pos[i] = (pos[i] + pace[i]) % r }

	if time != 0
		num = [0] * r
		pos.each { |i| num[i] += 1 }
		r.times do |i|
			if cnt[i] < num[i]
				ans += num[i] - cnt[i]
				cnt[i] = num[i]
			end
		end
	else
		ans += n
	end
end
puts ans



Measured memory_bytes: 14696
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

using namespace std;

void re(int& x);

template<class T, class... Ts> void re(T& t, Ts&... ts);

void pr(long long x);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

typedef long long ll;

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

int n, x;
long long tgt = 0;

struct ex {
    int l, r, b;
} exam[110000];

long long score(const ex& a, long long h) {
    long long sc = a.l * 1ll * min(h, (ll)a.b);
    sc += a.r * 1ll * max(0LL, h-a.b);
    return sc;
}

bool check(long long hrs) {
    int full = hrs / x;
    int rem = hrs % x; 

    long long sc = 0;
    rep(i,0,full) sc += score(exam[i], x);
    long long best = sc;

    rep(i,full,n) best = max(best, sc + score(exam[i], rem));
    
    if (full < n) {
        sc += score(exam[full], x);
        rep(i,0,full) best = max(best, sc - score(exam[i], x) + score(exam[i],rem));
    }
    
    return best >= tgt;
}

void solve()
{
    re(n,x);
    rep(i,0,n) re(exam[i].b, exam[i].l, exam[i].r);

    rep(i,0,n) tgt += exam[i].l * 1ll * exam[i].b;

    sort(exam, exam+n, [](const ex& a, const ex& b) {
        return score(a,x) > score(b,x);
    });

    long long st = 0, ed = n*1ll*x;
    while (st < ed) {
        long long md = (st+ed)/2;
        if (check(md)) ed = md;
        else st = md+1;
    } 

    ps(st);
}

int main() {

    solve();
}

void re(int& x) { scanf("%d", &x); }

template<class T, class... Ts> void re(T& t, Ts&... ts) { 
    re(t); re(ts...); 
}

void pr(long long x) { printf("%lld", x); }

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}



Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main() {
    int n;
    map<int, int> m;
    cin >> n;

    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (m[a] > 0) {
            cout << "NO" << endl;
            return 0;
        }
        m[a]++;
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <cstring>
using namespace std; 

void solve(){
  int n; 
  cin >>n; 
  int a[n][3]; 
  for(int i=0; i<n; i++){
    cin >> a[i][0] >> a[i][1] >> a[i][2]; 
  }
  int dp[n][3]; 
  dp[0][0]=a[0][0] , dp[0][1] = a[0][1], dp[0][2] = a[0][2];
  for(int i=1; i<n; i++){
    dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]); 
    dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]); 
    dp[i][2] = a[i][2] + max(dp[i-1][1], dp[i-1][0]);  
  }
  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n"; 
}

int main(){
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
 return 0;
}

Measured memory_bytes: 5488
N = int(input())
Li = list(map(int, input().split()))
count = 0
lnum = 0
mnum = 0
nnum = 0

for l in Li:
    mnum = lnum
    for m in Li[lnum:N]:
        if l == m:
            mnum += 1
            continue
        for n in Li[mnum:N]:
            if m != n and l != n:
                d = [l, m, n]
                d.sort()
                if d[2] < (d[0] + d[1]):
                    count += 1

        mnum += 1

    lnum += 1

print(count)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define f first 
#define s second
#define ll long long
vector<int> v(10000007);
void sieve(){
    for(int i = 1 ; i <= 10000007 ; i++){
         v[i] = i;
    }
    for(int i = 2 ; i <= 10000007 ; i++){
         if(v[i] == i){
              for(int j = 2*i ; j <= 10000007 ;j+=i){
                   v[j] = min(v[j] , i);
              }
         }
    }
}
int32_t main(){
     int n;
     cin>>n;
     sieve();
     long long ans = 1;
     //cout<<"hello"<<endl;
     for(int i = 2 ; i <= n ; i++){
        
         int temp = i;
         int prev = v[temp];
         long long cnt = 1;
         long long tempo = 1;
           while(temp%v[temp] == 0 && temp > 1){
                 temp = temp/v[temp];
                 if(temp == 1)break;
                 int newt = v[temp];
                 if(newt == prev)cnt++;
                 else{
                      tempo = tempo*(cnt+1);
                      cnt = 1;
                      if(temp == 1)break;
                 }
                 prev = newt;
           }
          
           tempo = tempo*(cnt+1);
           ans += i*tempo;
     }
     cout<<ans<<endl;
}

Measured memory_bytes: 42224
N, K = gets.split.map &:to_i
MOD = 10**9+7

ans = 1
(K..N).each{|i|
  l = (i - 1) * i / 2
  r = l + (N - i + 1) * i
  ans += r - l + 1
  ans %= MOD
}
p ans

Measured memory_bytes: 14368
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int getDigitSum(int x);

int getAbs(int x);

int getMin(vector<int> v);

int main(){
    int x, y;
    cin >> x >> y;

    if(x + y >= 10) cout << "error\n";
    else cout << (x + y) << endl;
    return 0;
}

int getDigitSum(int x){
    int res = 0;
    while(x > 0){
        res += x % 10;
        x /= 10;
    }
    return res;
}

int getAbs(int x){
    return (x > 0)? x : -x;
}

int getMin(vector<int> v){
    int res = 40000;
    for(int i = 0; i < v.size(); i++){
        res = min(res, v[i]);
    }
    return res;
}

Measured memory_bytes: 256
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

typedef long long llong;
using namespace std;



int main() {
	char iptNum[1100];
	int sum = 0;

	while (1) {
		fgets(iptNum, 1100, stdin);
		if (iptNum[0] == 48)break;
		sum = 0;
		for (int i = 0;48<= iptNum[i]&&iptNum[i]<=57 ; i++)sum += iptNum[i] -= 48;
		cout << sum << '\n';
	}

	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)	for(ll i=(a); i<(b); i++)
#define REP(i,n)	FOR(i,0,(n))
typedef pair< ll, ll >	cp2;
typedef pair< ll, cp2 >	cp3;
const ll mod = 1000000007;
bool debug = false;


int N;
int A[1123];
int ans;

int main(){
	
	while( cin>>N, N ){
		ans = mod;
		REP( i, N ) cin>>A[i];
		sort( A, A+N );
		REP( i, N-1 ) ans = min( ans, A[i+1]-A[i] );
		if( debug ) cout<<"@ ";
		cout<<ans<<endl;
	}
	
	
	return 0;
}


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

using namespace std;

#define FOR(i,l,r) for (int i=(l); i<(r); ++i)
#define sz(x) (int)(x).size()
#define print(x) cout << (x) << endl
#define dbg(x) cout << (#x) << ' ' << (x) << endl
#define all(x) (x).begin(), (x).end()

typedef string str;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

/* ------ END OF TEMPLATE ------ */

const int maxn = 1e5 + 5;

int n, m, u, v, ret, dp[maxn];
vector<int> adj[maxn];

int rec(int u) {
    int &ret = dp[u];
    if (ret != -1) return ret;
    else ret = 0;
    for (int &v : adj[u])
        ret = max(ret, rec(v)+1);
    return ret;
}

int main() {
    scanf("%i%i",&n,&m);
    memset(dp, -1, sizeof dp);
    for (int i=0; i<m; i++) {
        scanf("%i%i",&u,&v);
        adj[u].push_back(v);
    }
    for (int i=1; i<=n; i++)
        ret = max(ret, rec(i));
    printf("%i\n",ret);
}

Measured memory_bytes: 11636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    string n; cin>>n;
    ll sum=0;
    rep(i,0,n.size()){
        sum+=n[i]-'0';
    }
    if(((stoi)(n))%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
/* 
 * I made this version of code of the solution based on #1381094.
 * Thank you very much.
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

struct Card {
    char suit[2];
    int rank;
    int idx;
};

int n;
Card cards[100000];

inline void swap(Card& a, Card& b) {
    Card tmp = a;
    a = b;
    b = tmp;
}

inline int partition(int p, int r) {
    int i = p - 1;
    for (int j = p, x = cards[r].rank; j < r; ++j) {
        if (cards[j].rank <= x) {
            swap(cards[j], cards[++i]);
        }
    }
    swap(cards[r], cards[++i]);
    return i;
}

void quicksort(int p, int r) {
    if (p < r) {
        int q = partition(p, r);
        quicksort(p, q - 1);
        quicksort(q + 1, r);
    }
}

int main(void) {

    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        scanf("%s", cards[i].suit);
        scanf("%d", &cards[i].rank);
        cards[i].idx = i;
    }

    quicksort(0, n - 1);

    bool stable = true;
    for (int i = 1; i < n; ++i) {
        if (cards[i - 1].rank == cards[i].rank
                && cards[i - 1].idx > cards[i].idx) {
            stable = false;
            break;
        }
    }

    printf("%s\n", stable ? "Stable" : "Not stable");
    for (int i = 0; i < n; ++i) {
        printf("%c %d\n", cards[i].suit[0], cards[i].rank);
    }

    return 0;
}

Measured memory_bytes: 2372
a,b=input().split()
a_int=int(a)
b_int=int(b)
n1=int(a*b_int)
n2=int(b*a_int)
if a_int==b_int:
    print(n1)
if a_int<b_int:
    print(n1)
if a_int>b_int:
    print(n2)

Measured memory_bytes: 3060
import Data.List

main = interact $ unlines . map (show' . patrol . map words) . splitBy (== "0 0") . lines
 where show' p = if p then "OK" else "NG"

patrol = all even . map length . group . sort . concat . (["1","2"]:)

splitBy p xs
 | null xs = []
 | p (head xs) = splitBy p (tail xs)
 | otherwise = (takeWhile (not.p) xs : splitBy p (dropWhile (not.p) xs))

Measured memory_bytes: 4188
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

struct UnionFind {
    vector<int> data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

itn N, K, L;

void solve() {
    UnionFind uf1(N);
    FOR(K) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf1.unite(a, b);
    }
    UnionFind uf2(N);
    FOR(L) {
        itn a, b;
        cin >> a >> b;
        a--;
        b--;
        uf2.unite(a, b);
    }
    map<pi, int> m;
    FOR(N) {
        m[{uf1.find(i), uf2.find(i)}]++;
    }
    FOR(N) {
        cout << m[{uf1.find(i), uf2.find(i)}] << " ";
    }
    cout << endl;
}

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

    cin >> N >> K >> L;


    solve();
    return 0;
}


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

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

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;

int main() {
    int N; cin >> N;
    switch (N % 10) {
        case 3:
            cout << "bon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;
        default:
            cout << "hon";
            break;
    }
}

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

long long a,b;

long long GYS(long long x,long long y){
	if(x%y==0)
		return y;
	else{
		return GYS(y,x%y);
	}
}

int main(){
	
	cin>>a>>b;
	long long s;
	if(a>b)
		s=GYS(a,b);
	else
		s=GYS(a,b);
	
	cout<<a*b/s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()


class SegTree:
    X_unit = 0

    def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)


def orr(x, y):
    return x | y


def main():
    N = int(input())
    S = input()
    S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S)))
    Q = int(input())
    seg = SegTree(N, orr)
    seg.build(S)
    for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:])))


if __name__ == '__main__':
    main()

Measured memory_bytes: 136644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = nm[0];
        int M = nm[1];

        var Bulbs = Enumerable.Range(0, M).Select(n => Console.ReadLine())
            .Select(line => line.Split(' ').Select(s => int.Parse(s)).ToArray())
            .Select(arr => new { k = arr[0], sList = arr.Skip(1).Select(num => num-1).ToList() })
            .ToList();

        int[] pList = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var BulbsEx = Bulbs.Select((b, idx) => new { P = pList[idx], k = b.k, sList = b.sList });

        var max = 0;
        for(int i = 0; i < N; i++)
        {
            max |= (1 << i);
        }

        var ans = 0;

        for(int i = 0; i <= max; i++)
        {
            if(BulbsEx.All(b => b.sList.Count(n => ((i & (1 << n)) != 0)) % 2 == b.P))
            {
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}

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

int main()
{
    int i,j,m,n,k;
    cin>>n>>m>>k;
    int flag=0;
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            if(i*m+j*n-2*i*j==k)
            {
                flag=1;
                break;
            }
        }
        if(flag) break;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
k=int(input())
ans=[[i for i in range(1,10)]]
d=9
while d<k:
    ans.append([])
    for i in ans[-2]:
        x=str(i)
        z=int(x[-1])
        ans[-1].append(x+str(z))
        if z<=8:
            ans[-1].append(x+str(z+1))
        if z>=1:
            ans[-1].append(x+str(z-1))
    d+=len(ans[-1])
l=len(ans[-1])
v=sorted([int(i) for i in ans[-1]])

print(v[k-(d-l)-1])

Measured memory_bytes: 23512
def m(L,R):
 global c
 T=[];i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:T+=[L[i]];i+=1
  else:T+=[R[j]];j+=1
  c+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s])+[1e9],d(A[s:])+[1e9]) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 63660
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	long long int a[200000] = {};
	
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	sort(a, a + N);
	
	long long int max1 = 0;
	long long int max2 = 0;
	
	for(int i = N - 1; i > 0; i--){
		if(a[i] == a[i - 1]){
			max2 = max1;
			max1 = a[i];
			if(max2 > 0){
				break;
			}
			i--;
		}
	}
	
	long long int ans = max1 * max2;
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 1792
n = int(input())
ans = 0
red = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:-x[1])
blue = sorted([list(map(int, input().split())) for _ in range(n)])
for i in red:
	for num, j in enumerate(blue):
		if i[0] < j[0] and i[1] < j[1]:
			ans += 1
			del blue[num]
			break
print(ans)

Measured memory_bytes: 3064
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n").map(Number); 

var N = Arr[0];

var getMaxProfit = (num,array) => {
    var minR = array[1];
    var maxR = array[2] - array[1];
    
    for(let i =2; i <= num; i++){
        maxR = (maxR<(array[i]-minR)) ? (array[i]-minR) : maxR;
        minR = (minR < array[i]) ? minR : array[i];
    }
    
    return maxR;
}

console.log(getMaxProfit(N,Arr));


Measured memory_bytes: 40668
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=998244353;

//for(i=0; i<N; i++) cin >> a[i];




int main(void) {
  ll i, j, k;
  
  ll l, r, d;
  ll c=0;
  cin >> l >> r  >> d;
  for(i=l; i<=r; i++) {
    c+=(i%d==0);
  }
  pt(c);
  
  
  
}
 
 




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

typedef long long ll;
typedef pair<int,int> P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i = 1;i <= (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);

int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    int a[n];rep(i,n)cin>>a[i];
    vec ans(n);
    int mid=n/2;
    if(n%2==0){
        for(int i=0;i<mid;i++){int tmp=n-2*i;ans[i]=a[tmp-1];}
        int cnt=0;
        for(int i=mid;i<n;i++){int tmp=1+2*cnt;ans[i]=a[tmp-1];cnt++;}
    }
    else{
        for(int i=0;i<=mid;i++){int tmp=n-2*i;ans[i]=a[tmp-1];}
        int cnt=1;
        for(int i=mid+1;i<n;i++){int tmp=2*cnt;ans[i]=a[tmp-1];cnt++;}
    }
    rep(i,n)cout<<ans[i]<<" ";
    cout<<endl;
}



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

#define EPS (1e-7)
// #define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

const ll INF = ll(1e18) + 1;

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    ll left = -INF, right = INF;
    while (left + 1 < right)
    {
        ll mid = (left + right) / 2;
        ll total = 0;

        rep(i, n)
        {
            if (a[i] < 0)
            {
                int l = -1, r = n;
                while (l + 1 < r)
                {
                    int c = (l + r) / 2;
                    if (a[i] * a[c] < mid)
                        r = c;
                    else
                        l = c;
                }
                total += n - r;
            }
            else
            {
                int l = -1, r = n;
                while (l + 1 < r)
                {
                    int c = (l + r) / 2;
                    if (a[i] * a[c] < mid)
                        l = c;
                    else
                        r = c;
                }
                total += r;
            }
            if (a[i] * a[i] < mid)
                total--;
        }
        total /= 2;
        if (total < k)
        {
            left = mid;
        }
        else
        {
            right = mid;
        }
    }

    cout << left << endl;
    return 0;
}


Measured memory_bytes: 1792
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def solve():
  n = int(input())
  s = [input() for _ in range(n)]
  march = [0]*5
  for i in range(n):
    if s[i][0] == "M":
      march[0] += 1
    elif s[i][0] == "A":
      march[1] += 1
    elif s[i][0] == "R":
      march[2] += 1
    elif s[i][0] == "C":
      march[3] += 1
    elif s[i][0] == "H":
      march[4] += 1
  ans = 0
  for i in range(3):
    for j in range(3):
      for k in range(3):
        if i < j+1 and j<k+1:
          ans += march[i]*march[j+1]*march[k+2]
  print(ans)
solve()

Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define G(x, i) get<i>(x)
#define BITL(x, i) ((x) << (i))
#define BITR(x, i) ((x) >> (i))

using namespace std;

typedef tuple<int, int> i2;
typedef tuple<int, int, int> i3;
typedef tuple<int, int, int, int> i4;
typedef vector<int> vi;
typedef vector<i2> vi2;
typedef vector<i3> vi3;
typedef vector<vi> v2i;
typedef long long ll;
typedef tuple<ll, ll> l2;
typedef tuple<ll, ll> l3;
typedef vector<ll> vl;
typedef vector<l2> vl2;
typedef unsigned long long ull;

int main() {
  int a, b;
  cin >> a >> b;
  int res = -1;
  for (int i = 1; i < 2000; ++i) {
    if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      res = i;
      break;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num, i = 1;
        while (true) {
            num = Integer.parseInt(br.readLine());
            if (num == 0) break;
            System.out.println("Case "+i+": "+num);
            i++;
        }
    }
}

Measured memory_bytes: 31460
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

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

	int32_t N = S.size();
	int32_t res0 = 0, res1 = 0;
	for (int32_t i = 0; i < N; i++) {
		char c = i % 2 == 0 ? '0' : '1';
		if (S[i] != c)
			res0++;
		c = i % 2 == 0 ? '1' : '0';
		if (S[i] != c)
			res1++;
	}

	cout << min(res0, res1) << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";

int main() {
  ll a,b,x; cin>>a>>b>>x;
  ll l,r;
  r=b/x+1;
  l=(a-1)/x+1;
  if(a==0){l=0;}
  cout<<r-l;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fs first
#define sc second
using namespace std;
typedef double D;
typedef pair<D,D> pdd;
typedef vector<D> vd;
const D EPS = 1e-8;
const D PI = acos(-1);

int n,k;
pdd p[2000];
vector<pdd> v;
int max_r[2000], max_l[2000];
D dp1[1501][1501],dp2[1501][1501];

inline void modify(D &seta){
  if(seta>PI)seta-=2*PI;
  if(seta<-PI)seta+=2*PI;
}

inline bool in_upper(const D &seta){
  return (EPS<seta && seta<PI-EPS);
}

inline bool comp(const pdd &a, const pdd &b){
  return abs(a.fs-b.fs)<EPS?a.sc+EPS<b.sc:a.fs<b.fs;
}

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

  cin >> n >> k;
  rep(i,n){
    D x,y,r;
    cin >> x >> y >> r;
    complex<D> c(x,y);
    D d = abs(c), s = arg(c), a = sqrt(d*d-r*r);
    D ds = acos( (d*d + a*a - r*r)/(2*d*a) );
    
    D start = s-ds, end = s+ds;
    modify(start); modify(end);
    pdd tmp = pdd(in_upper(start)?start:0, in_upper(end)?end:PI);
    if(tmp.fs<EPS && PI-EPS<tmp.sc)continue;
    v.push_back(tmp);
  }

  sort(v.begin(),v.end(),comp);

  rep(i,v.size())rep(j,v.size()){
    if(i==j)continue;
    if(v[j].fs-EPS<v[i].fs && v[i].sc<v[j].sc+EPS){
      v.erase(v.begin()+i);
      i--;
      break;
    }
  }

  int m = v.size();
  rep(i,m){
    pdd dummy(v[i].sc,0);
    max_l[i] = upper_bound(v.begin(),v.end(),dummy,comp) - v.begin();
    max_r[i] = max_l[i]-1;
  }
  
  rep(i,m){
    rep(j,k+1)dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j]);
    rep(j,k)dp1[max_l[i]][j+1] = max(dp1[max_l[i]][j+1],
				     max(dp1[i][j], dp2[i][j]) + v[i].sc-v[i].fs);
    if(max_r[i]!=i){
      rep(j,k)dp2[max_r[i]][j+1] = max(dp2[max_r[i]][j+1],
				       max(dp1[i][j], dp2[i][j]) + v[max_r[i]].fs-v[i].fs);
    }
  }

  D ans = 0;
  rep(i,k+1)ans = max(ans, dp1[m][i]);
  cout << fixed << setprecision(10) << ans/PI << "\n";
}

Measured memory_bytes: 34672
#include <stdio.h> 


int main(){ 
    int h, w; 
    int i, j; 
    while(1){ 
        scanf("%d %d ", &h, &w); 
        if(h==0&&w==0)break; 
        for(i=0;i<h;i++){ 
            for(j=0;j<w;j++){ 
                if(i==0||i==h-1||j==0||j==w-1){ 
                    printf("#"); 
                }else{ 
                    printf("."); 
                } 
            } 
            printf("\n"); 
        } 
        printf("\n"); 
    } 


    return 0; 
}


Measured memory_bytes: 2040
import java.util.*;
import java.util.ArrayList;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();
        int max = 0;
        int sum = 0;
        int a = 0;
        int x = 1;
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(0);

        for(int i=0; i<N; i++){
            if(i!=N-1){
                if(S.charAt(i)=='0' && S.charAt(i+1)=='1'){
                    sum += 1;
                    a += 1;
                    list.add(i + 1);
                }
                else{
                    sum += 1;
                }
                if(a==K && S.charAt(i)=='1' && S.charAt(i+1)=='0'){
                    max = Math.max(max, sum);
                    sum -= list.get(x) - list.get(x - 1);
                    x += 1;
                    a -= 1;
                }
            }
            else if(i==N-1){
                sum += 1;
                max = Math.max(max, sum);
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 26596
#include<stdio.h>

int main()
{
	double  x1, y1, x2, y2, x3, y3, xp, yp;
	double d1, d2, d3, xa, xb, xc, ya, yb, yc;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp)!=EOF)
	{
		xa = x1 - xp;
		xb = x2 - xp;
		xc = x3 - xp;
		ya = y1 - yp;
		yb = y2 - yp;
		yc = y3 - yp;
		d1 = xa * yb - ya * xb;
		d2 = xb * yc - yb * xc;
		d3 = xc * ya - yc * xa;
		if(d1 * d2 > 0 && d3 * d2 > 0 && d1 * d3 > 0) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 612