akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		sc.close();
		String ans = "";
		if("Sunny".equals(s)) {
			ans = "Cloudy";
		} else if("Cloudy".equals(s)) {
			ans = "Rainy";
		} else {
			ans = "Sunny"; 
		}
		out.println(ans);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  // 累積和
  vector<int> white_s(n+1, 0);
  vector<int> red_s(n+1, 0);
  for (int i = 0; i < n; i++) {
    char c = s.at(i);
    if (c == 'W') {
      white_s.at(i+1) = white_s.at(i) + 1;
      red_s.at(i+1)   = red_s.at(i);
    } else {
      white_s.at(i+1) = white_s.at(i);
      red_s.at(i+1)   = red_s.at(i) + 1;
    }
  }

  // n=8
  // c= W R W W|R W R R
  //   0 1 2 3 4 5 6 7 8
  int ans = n;
  for (int i = 0; i < n+1; i++) {
    int left_w = white_s.at(i);
    int right_r = red_s.at(n) - red_s.at(i);
    int op_count = max(left_w, right_r);
    ans = min(ans, op_count);
  }

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


Measured memory_bytes: 5196
/* Life is all about calculated risks.
    But man am I bad at math. */

#include <bits/stdc++.h> 
#define ll long long int
#define INF (ll)1e12
#define MOD 1000000007

#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;

using namespace std;

ll n;
ll a[200100];

ll sum = 0;
vector<ll> h(200100,0);

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

    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        cin>>a[i];
        h[a[i]]++;
    }

    for(ll i=1; i<=n; i++)
    {
        sum += (h[i]*(h[i]-1))/2;
    }

    for(ll k=1; k<=n; k++)
    {
        ll ans = sum - (h[a[k]]*(h[a[k]]-1))/2 + ((h[a[k]]-1)*(h[a[k]]-2))/2;
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 5760
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {
	
	public static int dfs(final int ns, int cur_station, int bit, final int nl, int[][] adj_list, int[][] next){
		
		int max_next_path = Integer.MAX_VALUE;
		int max_next_station = Integer.MAX_VALUE;
		int max_cost = 0;
		
		//System.out.println(cur_station + " " + Integer.toBinaryString(bit));
		
		for(int i = 0; i < nl; i++){
			if((bit & (1 << i)) != 0){
				continue;
			}
			
			final int node1 = adj_list[i][0];
			final int node2 = adj_list[i][1];
			final int cost  = adj_list[i][2];
			
			int next_station = -1;
			if(node1 == cur_station){
				next_station = node2;
			}else if(node2 == cur_station){
				next_station = node1;
			}else{
				continue;
			}
			
			int ret = dfs(ns, next_station, bit | (1 << i), nl, adj_list, next) + cost;
			
			if(ret >= max_cost){
				if(ret > max_cost){
					max_next_path = i;
					max_cost = ret;
					max_next_station = next_station;
					//next[bit] = max_next_path;
				}else if(next_station < max_next_station){
					max_next_path = i;
					//next[bit] = max_next_path;
				}
			}
		}
		
		if(max_next_path != Integer.MAX_VALUE){
			next[cur_station][bit] = max_next_path;
		}
		
		return max_cost;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] memo_paths = new int[10][1 << 20];
		
		while (true) {
			final int ns = sc.nextInt();
			final int nl = sc.nextInt();
			
			if(ns == 0 && nl == 0){
				break;
			}
			
			int[][] adj_list = new int[nl][3];
			
			for(int i = 0; i < nl; i++){
				for(int j = 0; j < 3; j++){
					adj_list[i][j] = j < 2 ? sc.nextInt() - 1 : sc.nextInt();
				}
			}
			for(int i = 0; i < ns; i++){
				//System.out.println(ns + " " + i);
				Arrays.fill(memo_paths[i], -1);
			}
			
			int max_start = -1;
			int max_cost = 0;
			for(int start = 0; start < ns; start++){
				
				final int cost = dfs(ns, start, 0, nl, adj_list, memo_paths);
				//System.out.println(Arrays.toString(next_path));
			
				if(cost > max_cost){
					max_start = start;
					max_cost = cost;
				}
			}
			
			System.out.println(max_cost);
			boolean first = true;
			int cur_pos = max_start;
			int bit = 0;
			
			do{
				if(first){
					first = false;
					System.out.print((cur_pos + 1));
				}else{
					System.out.print(" " + (cur_pos + 1));
				}
				
				final int next = memo_paths[cur_pos][bit];
				
				//sc.next();
				
				if(next == -1){
					break;
				}else{
					cur_pos = adj_list[next][0] == cur_pos ? adj_list[next][1] : adj_list[next][0];
					bit |= 1 << next;
				}
			}while(true);
			System.out.println();
			
		}

	}

}

Measured memory_bytes: 85388
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <list>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ld eps = (ld)1 / 1e10;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
set<string> st;

int main()
{
    fast_io;
    ll q, i;
    string a;
    cin >> q;
    while (q--)
    {
        cin >> a;
        st.insert(a);
    }
    cout << st.size();
    return 0;
}


Measured memory_bytes: 19276
n,l = map(int,input().split())
aji_list = []
for i in range(n):
    aji_list.append(l+i)
    
if l >= 0:
    print(sum(aji_list[1:]))
    
else:
    if 0 in aji_list:
        print(sum(aji_list))
    else:
        print(sum(aji_list[0:-1]))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	long double a, b; cin>>a>>b;
  cout<<(ll)(a*b+0.001)<<endl;
    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0,f=1;
	char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int q=998244353;
inline int Plus(int x,int y) {return x+y>=q?(x+y-q):(x+y);}
inline int Sub(int x,int y) {return x<y?(x-y+q):(x-y);}
inline int Multi(int x,int y) {return 1ll*x*y%q;}
inline int& Pe(int &x,int y) {return x=Plus(x,y);}
inline int& Se(int &x,int y) {return x=Sub(x,y);}
inline int& Me(int &x,int y) {return x=1ll*x*y%q;}
const int maxn=2e5+10;
int n,s[maxn],b[maxn],bs=0,f[maxn];
char str[maxn];
namespace mat {
	int pw[maxn];
	void init() {
		pw[0]=1;
		for (int i=1;i<maxn;++i) pw[i]=Multi(pw[i-1],2);
	}
	int __initer__=(init(),0);
}
int get(int d) {
	int ret(0);
	for (int i=1;i<=d;++i) if (s[i]==1) Pe(ret,mat::pw[d-i]);
	static int a[maxn];
	for (int i=1;i<=d;++i) a[i]=s[i];
	for (int i=d+1;i<=n;++i) {
		a[i]=(a[i-d]^1);
		if (a[i]<s[i]) return Pe(ret,1);
		if (a[i]>s[i]) return ret;
	}
	return Pe(ret,1);
}
int main() {
	n=read();
	scanf("%s",str+1);
	for (int i=1;i<=n;++i) s[i]=str[i]-'0';
	for (int i=1;i<=n;++i) if (n%i==0 && ((n/i)&1)) b[++bs]=i;
	for (int i=1;i<=bs;++i) {
		int x=b[i];
		f[x]=get(x);
	}
	for (int i=1;i<=bs;++i) {
		int x=b[i];
		for (int j=1;j<i;++j) if (x%b[j]==0) Se(f[x],f[b[j]]);
	}
	int ans(0);
	for (int i=1;i<=bs;++i) {
		int x=b[i];
		Pe(ans,Multi(2*x,f[x]));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#define MAX 500000
#define INFTY 1000000000

int count;

void merge(int A[], int left, int mid, int right){
  int i, j , k, n1, n2;
  int L[MAX/2+2], R[MAX/2+2];
 
  n1 = mid - left;
  n2 = right - mid;

  for(i=0; i<n1; i++){
    L[i] = A[left+i];
  }
  for(i=0; i<n2; i++){
    R[i] = A[mid+i];
  }

  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;

  for(k=left; k<right; k++){
    count++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    } else{ 
      A[k] = R[j];
      j = j + 1;
    }
  }

}

void mergeSort(int A[], int left,int  right){
  int mid=0;

  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int i, n;
  int A[MAX];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  mergeSort(A, 0, n);
  
  for(i=0; i<n; i++){
    printf("%d", A[i]);
    if(i==n-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 4508
from collections import deque

s = list(str(input()))
q = int(input())
flag = True  # trueの時は反転が偶数回
deq = deque(s)
info = []
for i in range(q):
    info.append(list(input().split()))

for j in info:
    if j[0] == '1':
        if flag:
            flag = False
        else:
            flag = True
    else:
        if j[1] == '1' and flag:
            deq.appendleft(j[2])
        elif j[1] == '1' and (not flag):
            deq.append(j[2])
        elif j[1] == '2' and flag:
            deq.append(j[2])
        else:
            deq.appendleft(j[2])

if not flag:
    deq = reversed(deq)
deq = "".join(deq)
print(deq)

Measured memory_bytes: 36212
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, x;

	cin >> n >> m >> x;
	vector<int> c(n);
	int ans = INF2;
	rep(i, 0, n) {
		cin >> c[i];
		rep(j, 0, m) {
			cin >> a[i][j];
		}
	}
	
	rep(s, 0, 1 << n) {
		int cost = 0;
		vector<int> d(m);
		rep(i, 0, n) {
			if (s >> i & 1) {
				cost += c[i];
				rep(j, 0, m) {
					d[j] += a[i][j];
				}

			}
		}

		bool ok = true;

		rep(i, 0, m) {
			if (d[i] < x) {
				ok = false;
			}
		}
		if (ok)ans = min(ans, cost);

	}
	if (ans == INF2) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}

}
	

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> 
map<T, Int> factorize(T x){
  map<T, Int> res;
  for(Int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, Int> dict(const vector<T> &v){
  map<T, Int> res;
  for(Int i=0;i<(Int)v.size();i++)
    res[v[i]]=i;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> v;
  for(Int i=1;i*i<=n;i++){
    if(n%i) continue;
    v.emplace_back(i);
    if(i!=1) v.emplace_back(n/i);
  }
  v=compress(v);
  auto m=factorize(n);
  cout<<m.size()<<" "<<v.size()<<endl;
  return 0;
}



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

#define sz size()

string MakeTable(int n){
  int i,j;
  string p = "001";
  while(p.sz<=n)p += "10";
  i = 3;
  while(i*i<n){
    for(j=3*i;j<n;j+=2*i)p[j]='0';
    do{i+=2;}while(p[i]-'1');
  }
  return p;
}

int main(){
  string p;
  int n,ans;

  while(1){
    cin >> n;
    if(!n)break;

    p = MakeTable(n);

    if(p[n-2]=='1')ans = 1;
    else ans = 0;

    for(int i=3;i<=n/2;i+=2){
      if(p[i]=='1' && p[n-i]=='1')ans++;
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 3004
#include <iostream>

using namespace std;

int main() {
    int A, B, K;
    int divisors_found = 0;

    cin >> A >> B >> K;
    int divisor = min(A, B) + 1;
    
    while (divisors_found < K) {
        divisor--;
        if (A % divisor == 0  && B % divisor == 0)
            divisors_found++;
    }

    cout << divisor << endl;

    return 0;
}

Measured memory_bytes: 3612
from decimal import *
getcontext().prec = 100

s = int(input())
s_sqrt = Decimal(s).sqrt()
int_sqrt = int(s_sqrt)
if int_sqrt ** 2 == s:
    print(0,0,int_sqrt,0,0,int_sqrt)
else:
    a = s - int_sqrt ** 2
    b = (int_sqrt+1) ** 2 - s
    if a <= b:
        print(0,1,a,int_sqrt+1,int_sqrt,0)
    else:
        print(0,0,int_sqrt+1,b,1,int_sqrt+1)

Measured memory_bytes: 5588
#include<bits/stdc++.h>
#define ll long long
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

void solve() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    
    int ans = (H - h) * (W - w);
    print(ans);
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

int N, M;
string s;
VVI edge;

VI visited;
VI reach;

void dfs1(int v) {
  if (visited[v]) { return; }
  visited[v] = 1;
  int a = 0; int b = 0;
  for (int vv: edge[v]) {
    if (!reach[vv]) { continue; }
    if (s[vv] == 'A') { a = 1; }
    if (s[vv] == 'B') { b = 1; }
    dfs1(vv);
  }
  if (!a || !b) {
    reach[v] = 0;
    for (int vv: edge[v]) {
      if (!reach[vv]) { continue; }
      visited[vv] = 0;
      dfs1(vv);
    }
  }
}
signed main() {
  cin >> N >> M >> s;
  edge = VVI(N);
  REP (i, M) {
    int a, b;
    cin >> a >> b; a--; b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  visited = VI(N, 0);
  reach = VI(N, 1);
  REP (i, N) {
    if (!visited[i]) { dfs1(i); }
  }
  REP (i, N) {
    if (reach[i]) {
      cout << "Yes" << endl; return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 198400
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		if(s.charAt(s.length()-1)=='s') {
			s+="es";
		}
		else
			s+="s";
		System.out.println(s);
	}
}

Measured memory_bytes: 38452
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let tfrom: Vec<char> = get!(String).chars().collect();
    let tto: Vec<char> = get!(String).chars().collect();
    let mut from = vec![0; 26];
    let mut to = vec![0; 26];
    for i in 0..tfrom.len() {
        from[(tfrom[i] as i32 - 97) as usize] += 1;
        to[(tto[i] as i32 - 97) as usize] += 1;
    }
    //eprintln!("{:?}", from);
    //eprintln!("{:?}", to);
    from.sort();
    to.sort();
    for i in 0..from.len() {
        if from[i] != to[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

ll n;

int main()
{
  cin >> n;

  ll res = (1LL+n)*n/2;

  cout << res-n << endl;

  return 0;
}


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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

//快读（可去）
/**/
inline int read(){
	int S=0,W=1;
	char CH=getchar();
	while(CH<='0' || CH>'9'){
		if(CH=='-')W=-1;
		CH=getchar();
	}
	while(CH>='0' && CH<='9')S=S*10+CH-'0',CH=getchar();
	return S*W;
}

int n;
int a[2*100005];
ll ans=0;
ll sum=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//n=read();
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(int l=0,r=0,b=0;l<n;l++){
		while(r<n && (b&a[r])==0){
			b|=a[r++];
		}
		ans+=r-l;
		b^=a[l];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
N = int( input())
A = [ int( input()) for _ in range(N)]
ans1 = 0
A.sort()
nowL = A[0]
nowR = A[0]
for i in range(1,N):
    if i%4 == 3:
        ans1 += nowL - A[(i//4)*2+1]
        nowL = A[(i//4)*2+1]
    elif i%4 == 0:
        ans1 += nowR - A[(i//4)*2]
        nowR = A[(i//4)*2]
    elif i%4 == 1:
        ans1 += A[- (i//4)*2-1] - nowL
        nowL = A[-(i//4)*2 - 1]
    else:
        ans1 += A[- (i//4)*2 - 2] - nowR
        nowR = A[-(i//4)*2 - 2]
A = A[::-1]
ans2 = 0
nowL = A[0]
nowR = A[0]
for i in range(1,N):
    if i%4 == 1:
        ans2 += nowL - A[-(i//4)*2-1]
        nowL = A[-(i//4)*2-1]
    elif i%4 == 2:
        ans2 += nowR - A[-(i//4)*2-2]
        nowR = A[-(i//4)*2-2]
    elif i%4 == 3:
        ans2 += A[(i//4)*2+1] - nowL
        nowL = A[(i//4)*2+1]
    else:
        ans2 += A[(i//4)*2] - nowR
        nowR = A[(i//4)*2]

print( max(ans1, ans2))

Measured memory_bytes: 7916
n = int(input())

if n % 1000 == 0:
    tmp = int(n / 1000)
    c = int(tmp*1000-n)
    print(c)
else:
    tmp =int(n / 1000)
    tmp2 = int(1000*(tmp+1))
    c = int(tmp2 -n)
    print(c)

Measured memory_bytes: 9172
#include<stdio.h>
int main(void) {
	char a[1200];
	int i = 0;
	while (1) {
		scanf("%c", &a[i]);
		if (a[i] == '\n') break;
		i++;
	}
	for (i = 0; a[i] != '\n'; i++) {
		if ('A' <= a[i] && a[i] <= 'Z') a[i] += 'a' - 'A';
		else if ('a' <= a[i] && a[i] <= 'z') a[i] += 'A' - 'a';
		putchar(a[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a=0,i;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='C')
            a=1;
        if(s[i]=='F'&&a==1)
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
       cout << "a > b" << endl;
    else if (a < b)
       cout << "a < b" <<endl;
    else if (a == b)
       cout << "a == b" << endl;
     
    return 0;
}


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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ull n,k,ans,temp;
	cin >> n >>k;
	n=n%k;
	cout << min(n,k-n) << endl;
	/*if(n%k==0)
		cout << 0 << endl;
	else if(n<k)
		cout << min(n,k-n) << endl;
	else
	{
		while(true)
		{
			n=abs(n-k);
			if(n<k)
				break;
		}
		cout << min(n,k-n) << endl;
	}*/
}

Measured memory_bytes: 256
#include <stdio.h>


int main()
{
    int n,d,x,a[100],i,j,c=0;

    scanf("%d",&n);
    scanf("%d %d",&d,&x);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=0;i<n;i++){
        for(j=1;j<=d;j+=a[i]){
            c++;
        }
    }
        
    printf("%d\n",c+x);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, a, b, c;
vector<int>l;
const int INF = 1e9;
int brute_force(int k,int A,int B,int C) {
	if (k == n) {
		if (A == 0 || B == 0 || C == 0)return INF;
		return abs(a - A) + abs(b - B) + abs(c - C);
	}
	int ans = INF;
	ans = min(ans, brute_force(k + 1, A + l[k], B, C) + (A == 0 ? 0 : 10));
	ans = min(ans, brute_force(k + 1, A, B + l[k], C) + (B == 0 ? 0 : 10));
	ans = min(ans, brute_force(k + 1, A, B, C + l[k]) + (C == 0 ? 0 : 10));
	ans = min(ans, brute_force(k + 1, A, B, C));
	return ans;
}
int main() {
	cin >> n >> a >> b >> c;
	l = vector<int>(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	cout << brute_force(0, 0, 0, 0);
	return 0;
}

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

typedef long long ll;
const int MOD = 1000000007;
int N;

vector<int> G[200004];

bool dfs(int p, int cnt){
  if(cnt > 2){
    return false;
  }
  if(p == N-1){
    return true;
  }
  for(auto x: G[p]){
    if(dfs(x, cnt+1) == true){
      return true;
    }
  }
  return false;
}

int main(){
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
  }
  if(dfs(0,0)){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 8576
N = int(input())
li_a =list(map(int, input().split()))
li_b =list(map(int, input().split()))
li_c =list(map(int, input().split()))

before = -99
points = 0
for i in li_a:
      points += li_b[i - 1]
      if before + 1 == i:
            points += li_c[i - 2]
      before = i
print(points)

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n,ans=0,memo=0,ab=0;
    cin >> n;
    vector<ll> W(n);
    
    rep(i,n) {
        cin >> W[i];
        ans+=W[i];
    }
    
    ab=ans;

    rep(i,n){
        ans-=W[i];
        memo+=W[i];
        if(ab >= abs(ans - memo))
            ab = abs(ans - memo);
    }

    cout << ab << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    long n = s.Length;
		long answer = long.MaxValue;
    long[] nums = new long[n];

    for(int i = 0; i < n; i++)
    {
      nums[i] = s[i] - '0';
    }

    for(int i = 0; i < n-2; i++)
    {
      answer = Math.Min(answer, Math.Abs(753-nums[i]*100-nums[i+1]*10-nums[i+2]));
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13140
import java.util.*;

public class Main{

    public static void main(String[] args)throws Exception {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long i = 100;
        long count = 0;
        while(i < x){
            count++;
            i*=1.01;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35820
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

string S;

int main() {
	cin >> S;
	bool is_bad=false;
	for (int i = 0; i < 3; i++)
	{
		if (S[i] == S[i + 1])
			is_bad = true;
	}

	string ans;
	if (is_bad)
		ans = "Bad";
	else
		ans = "Good";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
	ll N;
	vector<ll> V, C;
	cin >> N;

	rep(i, 0, N){
		ll temp;
		cin >> temp;
		V.push_back(temp);
	}
	rep(i, 0, N){
		ll temp;
		cin >> temp;
		C.push_back(temp);
	}
	ll sum = 0;
	rep(i, 0, N){
		ll dif = V[i] - C[i];
		if (dif > 0){
			sum += dif;
		}
	}
	cout << sum << endl;
	return 0;
}


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

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

Measured memory_bytes: 256
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

#a = list(map(int, input().split()))


n,w = list(map(int, input().split()))
a = list(map(int, input().split()))

a.sort()

for i in range(min(w,n)):
    a[n-1-i]=0
print(sum(a))

Measured memory_bytes: 113872
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n;
	ll a[101];
	ll max=0;
	ll min=0;

	cin>>n;

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

	for(ll i=0; i<n; ++i){
		sort(a, a + n, greater<ll>());
		max=a[0];
		min=a[n-1];
	}
	cout<<max-min<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  int test[n][n][2];
  rep(i,n){
    cin>>a[i];
    rep(j,a[i]){cin>>test[i][j][0]>>test[i][j][1];}}
  int k=0;
  rep(l,(1<<n)){
    bool ans=true;
    map<int,int> s;
    rep(i,n){
      if(l&(1<<i)){s[i]=1;}}
    for(auto x:s){
      int i=x.first;
        rep(j,a[i]){
          if(test[i][j][1]==1&&!(s.count(test[i][j][0]-1))){ans=false;}
          else if(test[i][j][1]==0&&s.count(test[i][j][0]-1)){ans=false;}
        }}
    int q=s.size();
    if(ans){k=max(k,q);}}
  cout<<k<<endl;
}

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

using namespace std;

using ll=long long;
// Rolling Hash
struct RHash {
    const ll R = 843823891, iR = 1040004855;
    const ll M = 1637348371;
    vector<ll> a;
    vector<ll> pw;
    vector<ll> ipw;

    RHash() {
        assert(mul(R, iR) == 1);
        a.resize(256);
        iota(a.begin(), a.end(), 42);
        const int N = 1'000'006;
        pw.resize(N); ipw.resize(N);
        pw[0] = 1; ipw[0] = 1;
        for (int i = 1; i < N; i++) {
            pw[i] = mul(pw[i-1], R);
            ipw[i] = mul(ipw[i-1], iR);
        }
    }

    inline ll add(ll x, ll y) {
        return (x+y) %M;
    }
    inline ll sub(ll x, ll y) {
        return (x-y + M) %M;
    }
    inline ll mul(ll x, ll y) {
        return (x*y) %M;
    }

    vector<ll> get_hash(const string& s) {
        int n = s.size();
        vector<ll> sum(n+1);
        sum[0] = 0;
        for (int i = 0; i < n; i++) {
            sum[i+1] = add(sum[i], mul(pw[i], a[s[i]]));
        }
        return sum;
    }
    // s[l..r)
    ll get_sub(const vector<ll>& sum, int l, int r) {
        return mul(sub(sum[r], sum[l]), ipw[l]);
    }
} r;

// when range [l, r), has property P~notP, want last P.
// when return l-1, means not found.
template <typename T>
T bs_last(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = l + (r-l)/2;
        if (f(mid)) {
            l = mid + 1;
        }else {
            r = mid;
        }
    }
    return r-1;
}
void solve() {
    int n; cin >> n;
    string s; cin >> s;
    auto hsh = r.get_hash(s);
    int res = bs_last<int>(1, n/2+1, [&](int i){
        map<ll, set<int>> mp;
        for (int j = 0; j+i <= n; j++) {
            mp[r.get_sub(hsh,j,j+i)].insert(j);
        }
        for (auto& p: mp) {
            auto& st = p.second;
            if (st.size()>=2) {
                if (*st.rbegin() - *st.begin() >= i) {
                    return true;
                }
            }
        }
        return false;
    });
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 16640
N = int(input())
A = [ord(a) - 97 for a in input()]
NN = 19
BIT=[[0]*(2**NN+1) for _ in range(26)]
 
def addbit(t, i, x):
    while i <= 2**NN:
        BIT[t][i] += x
        i += i & (-i)

def getsum(t, i):
    ret = 0
    while i != 0:
        ret += BIT[t][i]
        i -= i&(-i)
    return ret

for i, a in enumerate(A):
    BIT[a][i+1] += 1

for t in range(26):
    B = [0] * (2**NN+1)
    for i in range(1<<NN):
        B[i+1] = B[i] + BIT[t][i]
    for i in range(1<<NN):
        BIT[t][i] = B[i] - B[i - (i & (-i))]

Q = int(input())
for _ in range(Q):
    a, b, c = input().rstrip().split()
    if a == "1":
        b = int(b)
        c = ord(c) - 97
        t = A[b-1]
        addbit(t, b+1, -1)
        addbit(c, b+1, 1)
        A[b-1] = c
    else:
        b, c = int(b), int(c)
        s = 0
        for t in range(26):
            s += 1 if getsum(t, c+1) - getsum(t, b) else 0
        print(s)

Measured memory_bytes: 228208
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cassert>
#include<iomanip>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define PI 3.14159265358979
#define MAX 45
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long double ld;
int n,m;
ld p[MAX];
ld area[MAX][MAX][MAX];//area[start point][last point][new point] := the area
ld dp[MAX][MAX][MAX];//dp[start point][last point][the number] := maximum area

double getArea(int i,int j)
{
  assert(i < n && j < n);
  return sin((p[j]-p[i])*2*PI)/2.0;//S = (b*c*sinA)/2,in this case, b = c = 1
}

void init_area()
{
  rep(i,n)//start point
    {
      REP(j,i,n)//last point
	{
	  REP(k,j,n)//new point
	    {
	      area[i][j][k] = getArea(i,j)+getArea(j,k)+getArea(k,i);
	    }
	}
    }
}

int main()
{
  while(cin >> n >> m,n|m)
    {
      rep(i,n)cin >> p[i];

      init_area();

      rep(i,MAX)rep(j,MAX)rep(k,MAX)dp[i][j][k] = -inf;
      rep(i,MAX)rep(j,MAX)dp[i][j][2] = 0;
      ld ans = -inf;
      rep(sp,n)
	{
	  //for(int cnt=m-1;cnt>=2;cnt--)
	  REP(cnt,2,m)
	    {
	      REP(lp,sp+1,n)
		{
		  REP(np,lp+1,n)
		    {
		      //if(cnt+1 == 4)cout <<" in? " << "dp["<<sp<<"]["<<lp<<"]["<<cnt<<"]" << endl;
		      if(dp[sp][lp][cnt] == -inf)continue;
		      //if(cnt+1 == 4)cout <<" in! " << dp[sp][lp][cnt] << endl;
		      dp[sp][np][cnt+1] = max(dp[sp][np][cnt+1],
					      dp[sp][lp][cnt]+area[sp][lp][np]);
	
		     
		      if(cnt+1 <= m)
			ans = max(ans,dp[sp][np][cnt+1]);  
		    }
		}
	    }
	}
      //rep(i,n)rep(j,n)cout << "dp["<<i<<"]["<<j<<"]["<<3<<"] = "<< dp[i][j][3] << endl;
      cout << setiosflags(ios::fixed) << setprecision(6) << ans << endl;
      //cout <<" ::: " <<  dp[0][3][4] << endl;
      //cout <<" ::: " <<  dp[1][3][3] << endl;
    }
  return 0;
}

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

int main(){
    int r, g, b, num;
    cin >> r >> g >> b;
    num = 100 * r + 10 * g + b;
    if(num % 4 == 0 && num != 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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


using namespace std;
const int maxn=1e5+5;
inline LL quickread()
{
	LL X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
int main()
{
    int h,w,m;
    cin>>h>>w>>m;
    set<int>  s[h+1];
    LL a[h+5];
    LL b[w+5];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for(int i=0;i<m;i++)
    {
        LL h1,w1;
        h1=quickread();
        w1=quickread();
        s[h1].insert(w1);
        a[h1]++;
        b[w1]++;
    }
    int maxtmp=0;
    set<int> set_h;
    int ans=0;
    for(int i=1;i<=h;i++)
    {
        if(a[i]>=maxtmp)
            maxtmp=a[i];
    }
    ans+=maxtmp;
    for(int i=1;i<=h;i++)
    {
        if(a[i]==maxtmp)
           set_h.insert(i);
    }
    maxtmp=0;
    set<int> set_w;
    for(int i=1;i<=w;i++)
    {
        if(b[i]>=maxtmp)
            maxtmp=b[i];
    }
    ans+=maxtmp;
    for(int i=1;i<=w;i++)
    {
        if(b[i]==maxtmp)
           set_w.insert(i);
    }
    set<int> :: iterator it=set_h.begin();
    int flag=0;
    while(it!=set_h.end())
    {
        set<int> :: iterator it2=set_w.begin();
        while(it2!=set_w.end())
        {
            if(s[*it].count(*it2)==0)
            {
                flag=1;
                break;
            }
            it2++;
        }
        if(flag)
        {
            break;
        }
        it++;
    }
    if(flag)
        cout<<ans<<endl;
    else
        cout<<ans-1<<endl;
}


Measured memory_bytes: 64424
A,B,K=map(int,input().strip().split(" "))
c=[]

if(A==B and K>=1):
    print(A)
    quit()
elif(A==B and K==0):
    quit()

if(B<=K):
    for i in range(A,B+1):
        print(i)
    quit()

else:

    if(K>B):
        K=B

    for i in range(K):
        if(A+i<=B):
            print(A+i)
        c.append(A+i)


    if(B-K<=0):
        quit()


    for i in range(B-K+1,B+1):
        if(i not in c and i<=B and i>=A):
            print(i)


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T INF = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T, typename U> istream& operator>>(istream& in, pair<T, U>& a) { cin >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }

int ceil(int a, int b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

class UnionFind { private: vector<int> par; vector<int> rnk; int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); } public: UnionFind(int size) { par.resize(size); rnk.resize(size); REP(i, size) par[i] = i, rnk[i] = 0; } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } } bool same(int x, int y) { return find(x) == find(y); } };

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

#define int i64
int h[27];
signed main() {
  int n;
  string s;
  cin >> n >> s;
  int m = 1000000007;
  REP(i, n) {
    h[s[i] - 'a'] += 1;
  }
  int a = 1;
  REP(i, 26) {
    a = a * (h[i] + 1) % m;
  }
  a = (a - 1 + m) % m;
  cout << a << endl;
}

Measured memory_bytes: 512
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<string>
#include<algorithm> 
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define INF 100000000000
#define LL long long
using namespace std;
map<LL, LL> m;
long long N, M, K,Q, ans, A, B, ss[100001],a[100000], b[100000];

string s;

int main() {
	cin >> N>>Q;
	cin >> s;
	for (int i = 0; i < Q; i++) {
		cin >> a[i]>>b[i];
	}
	ss[0] = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A'&&s[i+1] == 'C') {
			ss[i+1]++;
		}
		ss[i+1] = ss[i+1] + ss[i];
	}
	ss[s.size()] = ss[N - 1];
	for (int i = 0; i < Q; i++) {
		cout << ss[b[i]-1]-ss[a[i]-1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3456
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split();
        int[] a = new int[n];
        for(int i = 0; i < n; i++)
        {
            a[i] = int.Parse(s[i])-1;
        }
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] == -1) continue;
            int like = a[i];
            if (a[like] == i)
            {
                ans++;
                a[like] = -1;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 9688
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
    int n;
    static int new_ok[100010];
    scanf("%d", &n);
    rep (i, n)
    {
	int a, b;
	scanf("%d%d", &a, &b);
	++new_ok[min(b, n + 1)];
	--new_ok[min(a - 1, n + 1)];
    }
    ++new_ok[n + 1];

    int res = -3, ok = 0;
    for (int i = n + 1; i > 0; --i)
    {
	if (new_ok[i])
	    ok += new_ok[i];
	if (ok >= i)
	{
	    res = i - 1;
	    break;
	}
    }
    printf("%d\n", res);
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    int[] p = new int[n];
    int[] ans = new int[n];
    for(int i=0;i<n;i++){
      s[i]=sc.next();
      p[i]=sc.nextInt();
    } 
    String[] res = check1(s);
    for(int i=0;i<res.length;i++){
      ArrayList<Integer> intList = new ArrayList<Integer>();
      ArrayList<Integer> intList1 = new ArrayList<Integer>();
      for(int j=0;j<n;j++){
        if(res[i].equals(s[j])){
          intList.add(p[j]);
          intList1.add(j);
        }
      }
      Collections.sort(intList, Collections.reverseOrder());
      for(int m=0;m<intList.size();m++){
      	for(int l=0;l<intList.size();l++){
        	if(p[intList1.get(l)]==intList.get(m)){
          	System.out.println(intList1.get(l)+1);
            }
        }
      }
    }   
  }  
 
  static String[] check1(String[] s){
    Set<String> linkedHashSet = new LinkedHashSet<String>();
    for (int i=0;i<s.length; i++) {
      linkedHashSet.add(s[i]);
    }
    Object[] s_after = linkedHashSet.toArray();
    Arrays.sort(s_after); 
    String[] str = new String[s_after.length];
    for(int i=0;i<s_after.length;i++){
      str[i] = s_after[i].toString();
    }    
    return str;
  }

}

Measured memory_bytes: 35940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
int main(){

  int n,m,x,ans=100000000,memo; cin>>n>>m>>x;
  
  int c[n]; int a[n][m]; int p[m];
  rep(i,n){
    cin>>c[i];
    rep(k,m){cin>>a[i][k];}
  }
  
  bool ok;
  

    // {0, 1, ..., n-1} の部分集合の全探索
  for(int bit=0;bit<(1<<n);++bit){
    memo=0;
    rep(k,m)p[k]=0;
    ok=true;
    
    vector<int> S;
    for (int i=0;i<n;++i){
        if(bit&(1<<i)){ // 列挙に i が含まれるか
            S.push_back(i);
        }
    }
    
    for(int i:S){
      memo+=c[i];
      rep(k,m) p[k]+=a[i][k];
     // cout<<memo;
    }
     // cout<<endl;
    
    rep(i,m){
      if(p[i]<x)ok=false;
    }
    
    //cout<<endl;
    
    //if(memo<ans)ans=memo;
    if(ok)ans=min(ans,memo);
  }
  


  if(ans==100000000){cout<<-1;return 0;}
  
  cout<<ans<<endl;
  
  
}


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

struct Node {
	int key;
	struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * find(Node *u, int k) {
	while(u != NIL && k != u->key) {
		if(k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	char com[16];
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		scanf("%s",com);
		if(com[0] == 'f') {
			scanf("%d",&x);
			Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		} else if(!strcmp(com,"insert")) {
			scanf("%d",&x);
			insert(x);
		} else if(!strcmp(com,"print")) {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
find 12
insert 17
insert 25
find 16
print
*/


Measured memory_bytes: 20540