akhauriyash/Code-Regression huggingface dataset:
public class Main {

  private static void solve() {
    int n = ni();
    int k = ni();

    int mod = (int) 1e9 + 7;

    long[] a = new long[k + 1];
    long ret = 0;
    for (int g = k; g >= 1; g--) {
      // 公約数がg以上のものの組み合わせの数
      a[g] = pow(k / g, n, mod);
      for (int j = g; (j += g) <= k;) {
        a[g] += mod - a[j];
        a[g] %= mod;
      }
      ret += a[g] * g % mod;
      ret %= mod;
    }
    System.out.println(ret);
  }

  public static long pow(long a, long n, long mod) {
    // a %= mod;
    long ret = 1;
    int x = 63 - Long.numberOfLeadingZeros(n);
    for (; x >= 0; x--) {
      ret = ret * ret % mod;
      if (n << 63 - x < 0)
        ret = ret * a % mod;
    }
    return ret;
  }


  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M, 0);
    vector<int> L(M-1, 0);
    for (int i = 0; i < M; i++) cin >> X[i];
    sort(X.begin(), X.end());
    for (int i = 0; i < M - 1; i++) L[i] = X[i+1] - X[i];
    sort(L.begin(), L.end(), greater<int>());
    int sum = 0;
    for (int i = 0; i < M-1 && i < N - 1; i++) sum += L[i];
    cout << X[M-1] - X[0] - sum << endl;
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 double n;
 cin>>n;
 double d = 3.14*2*n;
 cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 3800
#include <stdio.h>
#include <string.h>
#define maxn 200010
int x[maxn],y[maxn];
int main (void)
{
    memset(x,0,sizeof(x));
    memset(y,0,sizeof(y));
    int n,m;
    scanf("%d%d",&n,&m);
    int a,b;
    while(m--)
    {
        scanf("%d%d",&a,&b);
        if(a==1)
            x[b]=1;
        if(b==n)
            y[a]=1;
    }
    //  1 1   1 n   2步？
    for(int i=1;i<=n;i++)
    {
        if(x[i]&&y[i])
        {
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 1664
use std::fs;
use std::io::{stdin, Read};
use std::iter::FromIterator;

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let mut g = vec![vec![]; n];
    for _ in 0..(n + m - 1) {
        let (a, b): (usize, usize) = parse!(it, 2);
        g[a - 1].push(b - 1);
    }
    let mut seen = vec![false; n];
    let mut parents = vec![0; n];
    for i in 0..n {
        if !seen[i] {
            dfs(&g, i, &mut parents, &mut seen);
        }
    }
    for p in parents {
        println!("{}", p);
    }
}

fn dfs(g: &Vec<Vec<usize>>, u: usize, parents: &mut Vec<usize>, seen: &mut Vec<bool>) {
    if !seen[u] {
        seen[u] = true;
        for &v in &g[u] {
            dfs(g, v, parents, seen);
        }
        for &v in &g[u] {
            if parents[v] == 0 {
                parents[v] = u + 1;
            }
        }
    }
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 19324
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int H, W;
string field[30];

bool check(int y, int x){
	if(y < 0 || y >= H || x < 0 || x >= W){
		return false;
	}
	return true;
}

void shoot(int y, int x, char dir){
	if(dir == '^'){
		while(true){
			y--;
			if(!check(y, x)){
				break;
			}
			if(field[y][x] == '*'){
				field[y][x] = '.';
				break;
			}
			if(field[y][x] == '#'){
				break;
			}
		}
	}else if(dir == 'v'){
		while(true){
			y++;
			if(!check(y, x)){
				break;
			}
			if(field[y][x] == '*'){
				field[y][x] = '.';
				break;
			}
			if(field[y][x] == '#'){
				break;
			}
		}
	}else if(dir == '<'){
		while(true){
			x--;
			if(!check(y, x)){
				break;
			}
			if(field[y][x] == '*'){
				field[y][x] = '.';
				break;
			}
			if(field[y][x] == '#'){
				break;
			}
		}
	}else if(dir == '>'){
		while(true){
			x++;
			if(!check(y, x)){
				break;
			}
			if(field[y][x] == '*'){
				field[y][x] = '.';
				break;
			}
			if(field[y][x] == '#'){
				break;
			}
		}
	}
}

int main(){
	
	int T;
	cin >> T;
	
	for(int loop = 0; loop < T; loop++){
		
		if(loop != 0){
			cout << endl;
		}
		
		cin >> H >> W;
		
		for(int i = 0; i < H; i++){
			cin >> field[i];
		}
		
		char dir;
		int pos_x, pos_y;
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(field[i][j] == '^' || field[i][j] == 'v' || field[i][j] == '<' || field[i][j] == '>'){
					dir = field[i][j];
					pos_y = i;
					pos_x = j;
				}
			}
		}
		
		
		int hoge;
		cin >> hoge;
		
		string ord;
		
		cin >> ord;
		
		for(int i = 0; i < hoge; i++){
			if(ord[i] == 'U'){
				dir = '^';
				if(check(pos_y - 1, pos_x)){
					if(field[pos_y - 1][pos_x] == '.'){
						field[pos_y][pos_x] = '.';
						pos_y -= 1;
					}
				}
			}
			if(ord[i] == 'D'){
				dir = 'v';
				if(check(pos_y + 1, pos_x)){
					if(field[pos_y + 1][pos_x] == '.'){
						field[pos_y][pos_x] = '.';
						pos_y += 1;
					}
				}
			}
			if(ord[i] == 'L'){
				dir = '<';
				if(check(pos_y, pos_x - 1)){
					if(field[pos_y][pos_x - 1] == '.'){
						field[pos_y][pos_x] = '.';
						pos_x -= 1;
					}
				}
			}
			if(ord[i] == 'R'){
				dir = '>';
				if(check(pos_y, pos_x + 1)){
					if(field[pos_y][pos_x + 1] == '.'){
						field[pos_y][pos_x] = '.';
						pos_x += 1;
					}
				}
			}
			if(ord[i] == 'S'){
				shoot(pos_y, pos_x, dir);
			}
			
		}
		
		field[pos_y][pos_x] = dir;
		
		for(int i = 0; i < H; i++){
			cout << field[i] << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char s[100010],t[100010];
int ss[100010],tt[100010];
int lens,lent,q;
int main(){
	int i,j;
	scanf("%s%s",s,t);
	lens=strlen(s);lent=strlen(t);
	scanf("%d",&q);
	for(i=1;i<=lens;++i){
		ss[i]=ss[i-1]+s[i-1]-'A'+1;
	}
	for(i=1;i<=lent;++i){
		tt[i]=tt[i-1]+t[i-1]-'A'+1;
	}
	int x,y,xx,yy;
	for(i=1;i<=q;++i){
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		int xxx=ss[y]-ss[x-1],yyy=tt[yy]-tt[xx-1];
		if(xxx%3==yyy%3)  printf("YES\n");
		else  printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1536
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n,m;
  cin>>n>>m;
  if(n==1 && m==1){
    cout<<1<<endl;
  }else if(n==1){
    cout<<m-2<<endl;
  }else if(m==1){
    cout<<n-2<<endl;
  }else{
    cout<<(m-2)*(n-2)<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a,k;
	int bl[200005];
	cin>>a>>k;
	if (a==k)
	{
		cout<<"0";
		return 0;
	}
	for (int i=0;i<a;i++)
	{
		cin>>bl[i];
	}
	sort(bl,bl+a);
	long long ans=0;
	for (int i=0;i<=a-1-k;i++)
	{
		ans+=bl[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n >= 64) {
			System.out.println(64);
		} else if (n >= 32) {
			System.out.println(32);
		} else if (n >= 16) {
			System.out.println(16);
		} else if (n >= 8) {
			System.out.println(8);
		} else if (n >= 4) {
			System.out.println(4);
		} else if (n >= 2) {
			System.out.println(2);
		} else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,i,j;
    cin>>a;
    double coin[a];
    for(i=0;i<a;i++)
    cin>>coin[i];
    double chance[a+1];
    double tmp[a+1];
    for(i=0;i<a+1;i++){
        chance[i]=0;
        tmp[i]=0;
    }
    chance[0]=1-coin[0];
    chance[1]=coin[0];
    for(i=0;i<a-1;i++){
        for(j=0;j<a+1;j++){
            tmp[j]=tmp[j]+chance[j]*(1-coin[i+1]);
            if(j!=a)
            tmp[j+1]=tmp[j+1]+chance[j]*coin[i+1];
        }
        for(j=0;j<a+1;j++){
            chance[j]=tmp[j];
            tmp[j]=0;
        }
    }
    double nm=0;
    for(i=0;i<a+1;i++){
        if(i>a/2)
        nm = nm + chance[i];
    }
    cout<<std::setprecision(9)<<nm<<endl;
    return 0;
}


Measured memory_bytes: 384
def divisors(n)
  res = []
  lim = Math.sqrt(n)
  i = 1
  while i <= lim
    if n % i == 0
      res.push(i)
      res.push(n / i)
    end
    i += 1
  end
  res.uniq.sort
end

def max_accept(divs, xs)
  divs.reverse_each.find { |d|
    xs.count { |x| x % d != 0 } <= 1
  }
end

def solve(a)
  [
    max_accept(divisors(a[0]), a),
    max_accept(divisors(a[1]), a)
  ].max
end

def main
  n = gets.to_i
  a = gets.split.map(&:to_i)

  p solve(a)
end

main


Measured memory_bytes: 8580
/*
 * ID: ITP1_8_B
 * Problem: Sums of numbers
 */

#include <stdio.h>
#define MAX_DIGIT 1000

int main(void)
{
    while (1) {
        char number[MAX_DIGIT + 2];
        fgets(number, sizeof(number), stdin);
        
        if (number[0] == '0')
            return 0;

        int sum = 0;
        int i;
        for (i = 0; i < MAX_DIGIT; i++) {
            if (number[i] == '\n')
                break;
            sum += number[i] - '0';
        }

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

    return 0;
}



Measured memory_bytes: 2108
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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()
{
	int N;
	cin >> N;

	int total = 0;

	int cntA = 0;
	int cntB = 0;
	int cntAB = 0;

	rep(i, N)
	{
		string s;
		cin >> s;

		rep(j, s.size() - 1)
		{
			if(s[j] == 'A' && s[j + 1] == 'B') total++;
		}

		if (s.front() == 'B' && s.back() == 'A')
		{
			cntAB++;
		}
		else if (s.front() == 'B')
		{
			cntB++;
		}
		else if (s.back() == 'A')
		{
			cntA++;
		}
	}

	total += min(cntA, cntB);
	if (cntAB > 0)
	{
		total += cntAB - 1;
		if(cntA > 0 || cntB > 0) total += 1;
	}
	

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <functional>
#include <map>
#include <cmath>
using namespace std;

long long N, M, S, T, a[200009], b[200009], c[200009], dist[200009], dp1[200009], dp2[200009], mod = 1000000007;
vector<pair<long long, long long>>x[200009]; vector<int> y[200009], z[200009];
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>Q;
bool used1[200009];

int main() {
	cin >> N >> M >> S >> T;
	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		x[a[i]].push_back(make_pair(b[i], c[i]));
		x[b[i]].push_back(make_pair(a[i], c[i]));
	}
	for (int i = 1; i <= N; i++) dist[i] = (1LL << 60);
	Q.push(make_pair(0, S)); dist[S] = 0;
	while (!Q.empty()) {
		pair<long long, long long>a1 = Q.top(); Q.pop();
		for (int i = 0; i < x[a1.second].size(); i++) {
			long long to = x[a1.second][i].first, cost = x[a1.second][i].second;
			if (dist[to] > dist[a1.second] + cost) {
				dist[to] = dist[a1.second] + cost;
				Q.push(make_pair(dist[to], to));
			}
		}
	}
	queue<int>R; R.push(T);
	while (!R.empty()) {
		int pos = R.front(); R.pop();
		for (int i = 0; i < x[pos].size(); i++) {
			long long to = x[pos][i].first, cost = x[pos][i].second;
			if (dist[to] == dist[pos] - cost) {
				if (used1[to] == false) { used1[to] = true; R.push(to); }
				y[to].push_back(pos);
				z[pos].push_back(to);
			}
		}
	}
	

	vector<pair<long long, long long>>A;
	for (int i = 1; i <= N; i++) A.push_back(make_pair(dist[i], i));
	sort(A.begin(), A.end());
	dp1[S] = 1;
	for (int i = 0; i < A.size(); i++) {
		int pos = A[i].second;
		for (int j = 0; j < y[pos].size(); j++) {
			dp1[y[pos][j]] += dp1[pos];
			dp1[y[pos][j]] %= mod;
		}
	}
	dp2[T] = 1;
	for (int i = A.size() - 1; i >= 0; i--) {
		int pos = A[i].second;
		for (int j = 0; j < z[pos].size(); j++) {
			dp2[z[pos][j]] += dp2[pos];
			dp2[z[pos][j]] %= mod;
		}
	}
	long long ret = dp1[T] * dp1[T]; ret %= mod;
	for (int i = 1; i <= N; i++) {
		if (dist[i] * 2LL == dist[T]) {
			long long E = dp1[i] * dp2[i]; E %= mod; E *= E; E %= mod;
			ret -= E; ret += mod; ret %= mod;
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < y[i].size(); j++) {
			int to = y[i][j];
			if (dist[i] * 2LL < dist[T] && dist[T] < dist[to] * 2LL) {
				long long E = dp1[i] * dp2[to]; E %= mod; E *= E; E %= mod;
				ret -= E; ret += mod; ret %= mod;
			}
		}
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;

int main() {
    double s1, s2; cin >> s1 >> s2;
    if (s1 > s2) swap(s1, s2);
    double ans = -1;
    double ds = s2 - s1;
    if (ds < 180) {
        ans = (s1+s2)/2;
    }
    else {
        ds = 360 - ds;
        ans = s1 - ds/2;
        if (ans < 0) ans += 360;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3276
import sys

n, m, *ab = map(int, sys.stdin.read().split())
ab = list(zip(*[iter(ab)] * 2))

root = list(range(n+1)); root[0] = None
height = [0] * (n + 1); height[0] = None
size = [1] * (n + 1); size[0] = None

sys.setrecursionlimit(10 ** 9)
def find_root(v):
    u = root[v]
    if u == v:
        return u
    w = find_root(u)
    root[v] = w
    return w

def unite(v, u):
    rv = find_root(v)
    ru = find_root(u)
    if rv == ru:
        return
    if height[v] >= height[u]:
        root[ru] = rv
        height[rv] = max(height[rv], height[ru] + 1)
        size[rv] += size[ru]
    else:
        root[rv] = ru
        size[ru] += size[rv]

def is_alone(v, rv, sv):
    return v == rv and sv == 1

def main():
    res = [0] * m
    for i in range(1, m):
        a, b = ab[m-i]
        ra = find_root(a)
        rb = find_root(b)
        sa = size[ra]
        sb = size[rb]
        
        bl_a = is_alone(a, ra, sa)
        bl_b = is_alone(b, rb, sb)

        if bl_a & bl_b:
            res[i] = res[i-1] + 1
        elif bl_a ^ bl_b:
            res[i] = res[i-1] + sa * sb
        else:
            if ra == rb:
                res[i] = res[i-1]
            else:
                res[i] = res[i-1] + sa * sb
        
        unite(a, b)

    all_pairs = n * (n - 1) // 2
    for i in res[::-1]:
        yield all_pairs - i
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 34952
n = int(input())
ABList = [list(map(int, input().split())) for _ in range(n)]
ABList.sort(key=lambda x: x[1])
sum_A = 0
ans = "Yes"
for i in range(n):
    sum_A += ABList[i][0]
    if sum_A > ABList[i][1]:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 53600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
 int k;
  cin >> k;
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[k-1] << endl;
}


Measured memory_bytes: 256
A,B,K = map(int, input().split())
k = [A, B]
for i in range(K):
    if i % 2 == 0:
        j = 0
        m = 1
    else:
        j = 1
        m = 0
    c = k[j]
    if c % 2:
        c = c - 1
    c = c / 2
    k[j] = c
    k[m] += c
print(int(k[0]),int(k[1]))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int n;
	cin >> n;
	ll t[1000], a[1000];
	rep(i, n) cin >> t[i] >> a[i];

	for(int i = 1; i < n; i++) {
		ll nt = (t[i-1] - 1) / t[i] + 1;
		ll na = (a[i-1] - 1) / a[i] + 1;
		ll n = max(nt, na);
		t[i] *= n;
		a[i] *= n;
	}
	cout << t[n-1] + a[n-1] << endl;
}


Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
#define exist_in(list, value) (list.end() != std::find(all(list),value))
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }
//template<class T> bool exist_in(const T& c, const typename T::value_type& v) {	return (c.end() != std::find(c.begin(), c.end(), v));}

/*****/

void Main()
{
	char x, y;
	cin >> x >> y;
	if (x == y)
		cout << "=";
	if (x > y)
		cout << ">";
	if (x < y)
		cout << "<";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
max = a.max
h = Hash.new(0)
app = Hash.new(0)

a.each do |i|
  app[i] += 1
end
a.each do |j|
  if app[j] == 1 || app[j] != "done"
    for k in 2..(max/j)
      h[j*k] += 1
    end
    app[j] = "done" if app[j] > 1
  end
end
ans = 0
for l in 0..(n-1)
  if h[a[l]] == 0 && app[a[l]] == 1
    ans += 1
  end
end
puts ans

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

int main()
{
    int N, D;
    cin >> N >> D;
    int X, Y;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> X >> Y;
        if (sqrt(pow(X, 2) + pow(Y, 2)) <= D) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

struct node {
  int end, depth;
  node *child[26];
  node(int d) {
    end = 0;
    depth = d;
    for (int i = 0; i < 26; i++) {
      child[i] = NULL;
    }
  }
  void insert(int key) {
    node *x = new node(depth + 1);
    child[key] = x;
  }
};

int main() {
  int n;
  ll ans = 0LL;
  node head = node(0);
  head.depth = 0;
  string s;
  vector<pair<int, string> > v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    reverse(s.begin(), s.end());
    v.push_back({s.length(), s});
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    node *x = &head;
    vector<int> f[26];
    for (int j = 0; j < 26; j++) {
      f[j].resize(v[i].first);
      for (int k = v[i].first - 1; k >= 0; k--) {
        if (v[i].second[k] == 'a' + j || k != v[i].first - 1 && f[j][k + 1]) {
          f[j][k] = 1;
        }
      }
    }
    for (int j = 0; j < v[i].first; j++) {
      int flag = 0;
      if (x->end == 1) {
        ans++;
      }
      for (int k = 0; k < 26; k++) {
        if (x->child[k] != NULL && v[i].second[j] == 'a' + k) {
          flag = 1;
        } else if (x->child[k] != NULL && x->child[k]->end == 1 && f[k][j]) {
          ans++;
        }
      }
      if (flag) {
        x = x->child[v[i].second[j] - 'a'];
      } else {
        x->insert(v[i].second[j] - 'a');
        x = x->child[v[i].second[j] - 'a'];
      }
      if (j == v[i].first - 1) {
        x->end = 1;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  vector<int> vec ={A+C,A+D,B+C,B+D};
  sort(vec.begin(),vec.end());
  
  cout << vec.at(0) << endl;
}


Measured memory_bytes: 256
s = int(input())

def collatz(x):
    if x % 2 == 0:
        return x / 2
    else:
        return x * 3 + 1

v = [s]
for i in range(2, 1000001):
    v.append(collatz(v[-1]))
    d = set(v)
    if len(v) != len(d):
        print(i)
        exit()

Measured memory_bytes: 38512
# -*- coding: utf-8 -*-
K = int(input())

# lcm & gcd not math library
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

from functools import reduce
def gcd_multi(num_list):
    return reduce(gcd, num_list)

ans = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i == j and j == k:
                dup_num = 1
            elif i == j or j == k:
                dup_num = 3
            else:
                dup_num = 6
            ans += gcd_multi([i, j, k]) * dup_num

print(ans)

Measured memory_bytes: 9620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 4000005
vector<int> fenwick(maxn,0);
void update(int b,int c){
  int temp = b+1;
  while(temp<=fenwick.size()){
    fenwick[temp] += c;
    temp += temp & (-temp);
  }
}
int getsum(int a,int b){
  int temp = b+1;
  int total = 0;
  while(temp!=0){
    total += fenwick[temp];
    temp -= temp & (-temp);
  }
  int idk = a;
  while(idk!=0){
    total -= fenwick[idk];
    idk -= idk & (-idk);
  }
  return total;
}
int32_t main() {
  int no_of_input;
  vector<int> vect1;
  int input;
  cin >> no_of_input;
  for(int i=0;i<no_of_input;i++){
    cin >> input;
    vect1.push_back(input);
  }
  sort(vect1.begin(),vect1.end());
  unordered_map<int,int> map1;
  vector<int> sums;
  for(int i=0;i<no_of_input;i++){
    for(int j=i+1;j<no_of_input;j++){
      sums.push_back(vect1[i]+vect1[j]);
    }
  }
  sort(sums.begin(),sums.end());
  //preprocess first 2
  update(0,1);
  int ans = 0;
  /*for(auto k:sums){
    cout << k << " ";
  }
  cout << endl;*/
  for(int i=2;i<no_of_input;i++){
    int pos = lower_bound(sums.begin(),sums.end(),vect1[i]+1)-sums.begin();
    
      ans += getsum(pos,maxn-1);
    
    
    for(int j=0;j<i;j++){
      int temp = vect1[i]+vect1[j];
      int k = lower_bound(sums.begin(),sums.end(),temp)-sums.begin();
      update(k,1);
    }
  }
  cout << ans;
  
}

Measured memory_bytes: 49788
PROGRAM hundredTo105
      IMPLICIT NONE
      integer(8) :: x
      integer(8) :: h,i,piyo(1:5),c
      
      read*,x
      
      !number of 100
      h = x / 100
      
      x = x - h * 100
      
      i = 5
      piyo = [1,2,3,4,5]
      c = 0
      do while( .true. )
        x = x - piyo(i)
          if( x > 0)then
            c = c + 1
          else if( x==0 )then
            c = c + 1
            exit
          else
            x = x + piyo(i)
            i = i - 1
          end if
      end do
      
      if( c>h )then
        print'(i0)',0
      else
        print'(i0)',1
      end if
      
      
      
      END PROGRAM

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#include<bitset>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;

int main(){
    int n;
    int a[21] = {};
    int cnt =0;
    cin >> n;
    LP(i,n)cin >> a[i];
    for(int i=1;i<n-1;i++){
if(a[i] > a[i-1] && a[i] < a[i+1])cnt++;
else if(a[i] < a[i-1] && a[i] > a[i+1])cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

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

    string S;
    cin >> S;

    int size = S.length()-1;
    int res = 0;
    for (int i = 0; i < S.length()/2; i++) {
        if (S[i] != S[size])
            res++;
        size--;
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    map<string,set<int> > m;
    string s;
    while(cin>>s)
    {
        int p;
        cin>>p;
        m[s].insert(p);
    }
    for(map<string,set<int> >::iterator it = m.begin();it!=m.end();it++)
    {
        cout<<(it->first)<<endl;
        bool first = true;
        for(set<int>::iterator it2 = it->second.begin();it2 != it->second.end();it2++)
        {
            cout<<(first?"":" ")<<(*it2);
            first=false;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1228
#include <bits/stdc++.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>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
//using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  Graph G(N);
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> ans(N, -1);
  queue<int> que;
  ans[0] = 0;
  que.push(0);
  while (!que.empty())
  {
    int v = que.front();
    que.pop();
    for (auto nv : G[v])
    {
      if (ans[nv] == -1)
      {
        ans[nv] = v;
        que.push(nv);
      }
    }
  }

  bool can = true;
  for (int i = 1; i < N; i++)
  {
    if (ans[i] == -1)
      can = false;
  }
  for (auto &it : ans)
    cerr << it << endl;
  if (can)
  {
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++)
      cout << ans[i] + 1 << endl;
  }
  else
    cout << "No" << endl;
  return 0;
}

// DFS 1に向かうように矢印を向けるから1を根として探索していき親に向けて道しるべを向ければよい


Measured memory_bytes: 10196
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef pair<int,int>P;

struct cor
{
    int x,y,z;
    bool operator<(const cor& c) const {
        if(x != c.x){
            return x < c.x;
        }else if(y != c.y){
            return y < c.y;
        }else{
            return z < c.z;
        }
    }
};

const int MAX_N = 100005;

ll a,b,c,n;
map<cor,int> mp;

int solve(int u,int v,int w)
{
    int pl = 0;
    if(u == 0 || mp[(cor){u-1,v,w}]){
        pl--;
    }else{
        pl++;
    }
    if(u == a-1 || mp[(cor){u+1,v,w}]){
        pl--;
    }else{
        pl++;
    }
    if(v == 0 || mp[(cor){u,v-1,w}]){
        pl--;
    }else{
        pl++;
    }
    if(v == b-1 || mp[(cor){u,v+1,w}]){
        pl--;
    }else{
        pl++;
    }
    if(w == 0 || mp[(cor){u,v,w-1}]){
        pl--;
    }else{
        pl++;
    }
    if(w == c-1 || mp[(cor){u,v,w+1}]){
        pl--;
    }else{
        pl++;
    }
    mp[(cor){u,v,w}]++;
    return pl;
}

int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&n);
    ll res =  2*(a*b+b*c+c*a);
	rep(i,n){
        int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
        res += solve(u,v,w);
	}
    cout << res << "\n";
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s, t = "";
    cin >> s;

    for (int i = 0; i < s.size(); i += 2)
    {
        t += s[i];
    }
    cout << t << endl;
    return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int a, b, c, d, e, n, m, k;
string s, t, r;
char c1, c2, c3;

int A[200005];
int B[200005];
int C[200005];

ll F[10000005];

int main() {
	for (ll i=1 ; i*i<10000005 ; i++) {
		//printf("%d\n", i);
		for (ll j=i ; j*i<10000005 ; j++) {
			//if (j%1000000 == 0) cout <<j*i<<endl;
			F[i*j]++;
			if (j>i) F[i*j]++;
		}
	}
	int n;
	cin >>n;
	ll sol = 0;
	for (int i=1 ; i<=n ; i++) {
		//cout <<F[i]<<endl;
		sol += F[i]*i;
	}
	cout <<sol<<endl;
	return 0;
}

Measured memory_bytes: 81764
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    int K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N ; i++) {
        std::cin >> h.at(i);
    }
    int count=0;
    for (int i = 0; i < N; i++)
    {
        if (h[i] >= K)
        {
            count++;  
        }
        
    }
    cout << count ;
}


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

int a[105];

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

    int ans = 0;
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            a[i+1] = 9999;
            ans++;
        }
    }

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

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

int main()
{
	int n;
    cin >> n;
    
    unordered_set<string> s;
    for(int i=0;i<n;i++)
    {
string p;
    cin>>p;
    s.insert(p);
    }
    
    cout << s.size() <<endl;
    
	return 0;
}

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

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

    static class EPayment {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            char[] a = s.next().toCharArray();
            long[][] dp = new long[a.length][2];
            dp[a.length - 1][0] = a[a.length - 1] - '0';
            dp[a.length - 1][1] = 1 + 10 - (a[a.length - 1] - '0');
            for (int i = a.length - 2; i >= 0; i--) {
                dp[i][0] = Math.min(dp[i + 1][0], dp[i + 1][1]) + a[i] - '0';
                dp[i][1] = Math.min(dp[i + 1][0], dp[i + 1][1] - 2) + 1 + 10 - (a[i] - '0');
            }
            w.println(Math.min(dp[0][0], dp[0][1]));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 69332
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  string s;
  cin>>s;
  int ans = 1;
  char ch = s[0];
  for(int i=1;i<n;i++){
  	if(s[i]!=ch){
    	ch = s[i];
      	ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
	char s[1001] = { '\0' };
	int l = 0;
	scanf("%s", s);
	while(s[l+1] != 0){
		l++;
	}
	if(s[l] == 's'){
		printf("%ses\n", s);
	} else {
		printf("%ss\n", s);
	}
	return 0;
}


Measured memory_bytes: 1732
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i8,
        l: i8,
        s: [String; n],
    }

    let mut s: Vec<String> = s;

    s.sort();
    let joined = s.join("");

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


Measured memory_bytes: 4352
Public Class Program
  Shared Sub Main()
    Dim md As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim m As Integer = md(0)
    Dim d As Integer = md(1)
    ' d1 >= 2, d10 >= 2, d1 * d10 = m のため、積の日は4月から存在する '
    Dim ans As Integer = 0
    If m > 3 Then
      For i As Integer = 4 To m
        If d > 21 Then
          For j As Integer = 22 To d
            If Integer.Parse(j.ToString().Substring(1, 1)) > 1 Then
              Dim d10 As Integer = Integer.Parse(j.ToString().Substring(0, 1))
              Dim d1 As Integer = Integer.Parse(j.ToString().Substring(1, 1))
              If d1 * d10 = i Then ans += 1
            End If
          Next
        End If
      Next
    End If
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
	public static int[] num = new int[100000];
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); // 要素の個数
		//int[] num = new int[n]; // 個数のリスト

		for (int i = 0; i < n; i++) {
			num[i] = scan.nextInt();
		}
		int partition_num = Partition(0,n-1);
		for (int i = 0; i < partition_num; i++) {
			System.out.print(num[i] + " ");
		}
		System.out.print("["+num[partition_num]+"]");
		for (int i = partition_num+1; i < n ; i++) {
			System.out.print(" " + num[i]);
		}
		System.out.println();
	}

	public static int  Partition(int p, int r){
		int x =num[r];
		int i = p -1;
		for(int j = p; j<r;j++){
			if(num[j] <= x){
				i = i +1;
				int tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}
			
		}
		int tmp = num[i +1];
		num[i+1] = num[r];
		num[r]=tmp;
		return i + 1;
}

}



Measured memory_bytes: 71236
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    ll res = 0;
    string ope = "";
    int rr = 0, pp = 0, ss = 0;
    rep(i, T.size()) {
        if(T[i] == 'r') {
            if(i - K >= 0 && ope[i - K] == 'p') {
                ope += 'a';
            } else {
                ope += 'p';
                pp = 1 - pp;
                res += P;
            }
        } else if(T[i] == 's') {
            if(i - K >= 0 && ope[i - K] == 'r') {
                ope += 'a';
            } else {
                ope += 'r';
                rr = 1 - rr;
                res += R;
            }
        } else if(T[i] == 'p') {
            if(i - K >= 0 && ope[i - K] == 's') {
                ope += 'a';
            } else {
                ope += 's';
                ss = 1 - ss;
                res += S;
            }
        }
    }
    // cout << ope << endl;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, S, mod = 998244353;
    cin >> N >> S;
    vector<int> A(N+1);
    REP(i, N) cin >> A[i+1];
    vector< vector<int> > dp(N+1, vector<int>(S+5, 0));
    REP(i, N+1)
        dp[i][0] = 1;
    FOR(i, 1, N) {
        FOR(s, 0, S) {
            if(s - A[i] >= 0)
                dp[i][s] += dp[i-1][s] + dp[i-1][s - A[i]];
            else
                dp[i][s] += dp[i-1][s];
            
            dp[i][s] %= mod;
        }
    }

    // FOR(i, 1, N) {
    //     FOR(s, 0, S) cerr << dp[i][s] << " ";
    //     cerr << endl;
    // }
    int ans = 0;
    FOR(i, 1, N) {
        ans += dp[i][S];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 38640