akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
 
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
 
    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
            for (int i = 0; i <= m; ++i) {
                for (int j = 0; j <= n; ++j) {
                    if (i * n + j * m - 2 * i * j == k) {
                        out.println("Yes");
                        return;
                    }
                }
            }
            out.println("No");
        }
 
    }
 
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
    }
}

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

int main(void){
  int g,b,r,n,temp;
  cin >> g >> b >> r >> n;
  int ans = 0;
  for(int i = 0; i != 3001; i++){
    for(int j = 0; j != 3001; j++){
      temp = n - (i * g) - (j * b);
      if(temp >= 0 && temp % r == 0){
        //cout << i << j << temp << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

let toTuple xs =
    match xs with
    | [| a ; b |] -> (a, b)
    | _           -> failwith "invalid arguments"

let readIntTuple () =
    Console.ReadLine ()
    |> fun s -> s.Split(' ')
    |> Array.map int
    |> toTuple

type Graph = list<int> array
type Queries = Dictionary<int,int>

let dfsFactory (G: Graph) (Q: Queries) (A: inref<int array>) =
    let rec dfs p p' acc =
        let acc' = acc + Q.Item p

        A.[p] <- acc'

        for child in G.[p] do
            if child <> p' then dfs child p acc'

        ()

    dfs

[<EntryPoint>]
let main argv =
    let N, Q = readIntTuple ()

    let edges = seq { for _ in 1 .. N - 1 -> readIntTuple () }
                |> Seq.map (fun (a, b) -> (a - 1, b - 1))

    let queries' = seq { for _ in 1 .. Q -> readIntTuple () }
                   |> Seq.map (fun (p, q) -> (p - 1, q))

    let G = [| for _ in 1 .. N -> [] |]

    for a, b in edges do
        G.[a] <- b :: G.[a]
        G.[b] <- a :: G.[b]

    let queries = new Queries ()

    for p in 0 .. N - 1 do
        queries.Add (p, 0)

    for p, q in queries' do
        queries.Item p <- queries.Item p + q

    let A = [| 1 .. N |]

    let dfs = dfsFactory G queries &A

    dfs 0 -1 0

    A
    |> Seq.map string
    |> String.concat " "
    |> printfn "%s"

    0


Measured memory_bytes: 92492
S = input()
if len(S) % 2 == 1:
    S = S[:-1]
else:
    S = S[:-2]
while True:
    if S[0 : int(len(S) / 2)] == S[int(len(S) / 2) : len(S)]:
        print(len(S))
        break
    else:
        S = S[:-2]

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
    int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
	    printf("a < b\n");
		}
	else if(a>b){
	    printf("a > b\n");
	}
	else{
	    printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 2532
while True :
    n=int(input())
    if n==0 :
        break
    sum=1
    ans=0
    for i in range(1,n+1):
        sum=sum*i
        while True:
            if sum%10==0:
                ans+=1
                sum=sum//10
            else:break
       
    print(ans)


Measured memory_bytes: 5632
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

string str;

int main()
{
  while(cin >>str){
    int ans1 = 0;
    int ans2 = 0;
  for(int i = 0;i <str.size()-2;i++){
    if(str[i] =='J'&&str[i+1] =='O'&&str[i+2] =='I')
      ans1++;
    if(str[i] =='I'&&str[i+1]=='O'&&str[i+2] =='I')
      ans2++;
  }
  cout <<ans1<<endl;
  cout <<ans2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();
    System.out.println(Math.max(0, a - 2 * b));

  }

  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: 21460
n,k = map(int,input().split())
num_list = []
for _ in range(n):
    num_list .append(list(map(int,input().split())))
num_list.sort()
cnt = 0
ans = 0

for num in num_list:
    if cnt < k:
        cnt += num[1]
        ans  = num[0]
    else:
        break
print(ans)

Measured memory_bytes: 27872
fun main() = Thread(null, ::abc168c, "", 128 * 1024 * 1024).start()

@OptIn(ExperimentalStdlibApi::class)
fun abc168c() {
    val (a, b, h, m) = readLine()!!.split(' ').map { it.toDouble() }

    val answer = Math.sqrt(
        (a * a) + (b * b) - (2 * a * b * Math.cos(
            Math.toRadians(
                Math.abs(((h / 12) * 360 + (m / 60 / 12) * 360) - (m / 60) * 360)
            )
        ))
    )

    println(answer)
}


Measured memory_bytes: 36904
#include<stdio.h>
int main(){
  int a[3];
  int i,j,min;

  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<3;i++){
    for(j=i+1;j<3;j++){
      if(1<=a[i] && a[i]<=10000){
        if(a[i]>a[j]){
          min=a[i];
          a[i]=a[j];
          a[j]=min;
        }
      }
    }
  }
 
   printf("%d ",a[0]);
printf("%d " ,a[1]);
printf("%d\n", a[2]);
 
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
// #define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

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

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

ll c[3][3];

int main(){
	FAST;

	rep(i,3) {
		rep(j,3) cin >> c[i][j];
	}

	ll a[3];
	ll b[3];

	a[0] = 0;
	b[0] = c[0][0]-a[0];
	b[1] = c[0][1]-a[0];
	b[2] = c[0][2]-a[0];
	a[1] = c[1][2]-b[2];
	a[2] = c[2][1]-b[1];

	rep(i,3) {
		rep(j,3) {
			if (a[i]+b[j] != c[i][j]) {
				cout << "No\n";
				return 0;
			}
		}
	}
	
	cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<int> a(n + 2);
	LL sum = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		sum += abs(a[i - 1] - a[i]);
	}
	sum += abs(a[n] - a[0]);

	for (int i = 1; i <= n; ++i) {
		LL x = sum;
		x -= abs(a[i - 1] - a[i]);
		x -= abs(a[i + 1] - a[i]);
		x += abs(a[i - 1] - a[i + 1]);
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 1664
from functools import lru_cache
N = int(input())

@lru_cache(maxsize=None)
def isprime(x):
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True

@lru_cache(maxsize=None)
def ispow(a, b):
    while a % b == 0:
        a //= b
    return a == 1

prime_cache = [2, 3]

def primeiter():
    global prime_cache
    for p in prime_cache:
        yield p
    x = prime_cache[-1] + 1
    while True:
        if isprime(x):
            prime_cache.append(x)
            yield x
        x += 1

done = set()
while N > 1:
    ds = [N]
    d = 2
    while d * d <= N:
        if N % d == 0:
            if not d in done:
                ds.append(d)
            d2 = N // d
            if d2 != d and not d2 in done:
                ds.append(d2)
        d += 1
    ds.sort()
    z = -1
    for d in ds:
        if isprime(d):
            z = d
            break
        for p in primeiter():
            if d < p:
                break
            if ispow(d, p):
                z = d
                break
        if z > 0:
            break
    if z < 0:
        break
    N //= z
    done.add(z)
print(len(done))

Measured memory_bytes: 9628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//みんな天才すぎでしょ

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), X = getint();
	int B[100000], L[100000], U[100000];
	rep(i, N) {
		B[i] = getint();
		L[i] = getint();
		U[i] = getint();
	}
	pair<ll, int> S[100000];
	rep(i, N) {
		S[i].first = 1ll * X * U[i] - 1ll * B[i] * (U[i] - L[i]);
		S[i].second = i;
	}
	sort(S, S + N, greater<pair<ll, int>>());

	ll taka = 0;
	ll ao = 0;	
	rep(i, N) {
		int k = S[i].second;
		ao += 1ll * B[k] * L[k];
	}
	int doko = 0;
	rep(i, N) {
		doko = i;
		int k = S[i].second;
		taka += 1ll * X * U[k] - 1ll * B[k] * (U[k] - L[k]);
		if (taka >= ao) break;
	}

	if (taka == ao) {
		co(1ll * (doko + 1) * X);
		return 0;
	}

	ll ans = 1ll * (doko + 1) * X;
	int Umin = 200000;
	ll saishou = 1e18;
	rep(i, doko + 1) {
		int k = S[i].second;
		Umin = min(Umin, U[k]);

		ll kari = -(taka - ao + 1ll * B[k] * (U[k] - L[k]) - 1ll * X * U[k]);
		saishou = min(saishou, (kari + L[k] - 1) / L[k]);
	}
	ans -= (taka - ao) / Umin;
	ans = min(ans, 1ll * doko * X + saishou);

	ll tmp = ao - taka;
	int t = S[doko].second;
	tmp += 1ll * X * U[t] - 1ll * B[t] * (U[t] - L[t]);
	saishou = 1e18;
	for (int i = doko + 1; i < N; i++) {
		int k = S[i].second;

		ll kari = (tmp + 1ll * B[k] * (U[k] - L[k]) + U[k] - 1) / U[k];
		kari = min(kari, (tmp + L[k] - 1) / L[k]);

		saishou = min(saishou, kari);
	}

	ans = min(ans, 1ll * doko * X + saishou);

	co(ans);

	Would you please return 0;
}

Measured memory_bytes: 3072
package main

import (
	"fmt"
)

func main() {
	nm := scanInts(2)
	n, m := nm[0], nm[1]
	edges := make(map[int64][]int64)
	for _ = range iter(0, m) {
		ab := scanInts(2)
		edges[ab[0]] = append(edges[ab[0]], ab[1])
		edges[ab[1]] = append(edges[ab[1]], ab[0])
	}
	fmt.Println(solve(n, m, edges))
}

type color bool

const (
	blue  = true
	green = false
)

type elm struct {
	node  int64
	color color
}

func solve(n, m int64, edges map[int64][]int64) int64 {
	visited := make(map[int64]bool)
	ans := int64(0)
	for i := range iter(1, n+1) {
		if visited[i] {
			continue
		}
		blueGreen := make(map[color]map[int64]bool)
		blueGreen[blue] = make(map[int64]bool)
		blueGreen[green] = make(map[int64]bool)
		complete := false
		lv := make(map[int64]bool)
		edc := int64(0)
		stack := []elm{elm{node: i, color: blue}}
		blueGreen[blue][i] = true
		for len(stack) > 0 {
			l := len(stack)
			x := stack[l-1]
			stack = stack[:l-1]
			if lv[x.node] {
				continue
			}
			lv[x.node] = true
			visited[x.node] = true
			for _, nxt := range edges[x.node] {
				if blueGreen[x.color][nxt] {
					complete = true
				}
				nxtClr := !x.color
				blueGreen[nxtClr][nxt] = true
				stack = append(stack, elm{node: nxt, color: nxtClr})
			}
			edc += int64(len(edges[x.node]))
		}
		z := int64(len(lv))
		if complete {
			ans += z*(z-1)/2 - edc/2
		} else {
			ans += int64(len(blueGreen[blue])*len(blueGreen[green])) - edc/2
		}
	}
	return ans
}

func scanInts(length int64) []int64 {
	ints := make([]int64, length)
	for i := range iter(0, length) {
		var x int64
		_, _ = fmt.Scan(&x)
		ints[i] = x
	}
	return ints
}

func iter(l int64, r int64) chan int64 {
	var i int64 = l
	c := make(chan int64)
	go func() {
		for i < r {
			c <- i
			i += 1
		}
		close(c)
	}()
	return c
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int M1,D1,M2,D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (M1 != M2) cout << "1" << endl;
    else cout << "0" << endl;
}



Measured memory_bytes: 256
S = [i for i in list(input())]
N = len(S)-1

res = 0
for bit in range(2**N):
    f = []
    for i in range(N):
        f.append(S[i])
        if bit & (2**i): f.append('+')
        else: f.append('')
    f.append(S[-1])
    f = ''.join(f)
    res += eval(f)

print(res)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
  int a=1, b=0, c;

  while(a!=10||b!=0)
    {
      b++;
      c=a*b;
      printf("%dx%d=%d\n", a,b,c);
      if(b==9){
	a++;
	b=0;}
    }
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
const int SIZE = 1<<20;
struct RMQ{
	int seg[SIZE*2];
	void update(int k,int x){
		k += SIZE-1;
		seg[k]=x;
		while(k){
			k = (k-1)/2;
			seg[k]=min(seg[k*2+1],seg[k*2+2]);
		}
	}
	int query(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return INF;
		else if(a<=l&&r<=b)return seg[k];
		else return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
	}
	int query(int a,int b){
		return query(a,b,0,0,SIZE);
	}
}seg;

int N;
int a[200100];
int search_R(int i){
	int l = i,r = N;
	while(r-l>1){
		int mid = (l+r)/2;
		if(seg.query(i,mid+1)<a[i])r=mid;
		else l=mid;
	}
	return l;
}
int search_L(int i){
	int l = -1,r = i;
	while(r-l>1){
		int mid = (l+r)/2;
		if(seg.query(mid,i+1)<a[i])l=mid;
		else r=mid;
	}
	return r;
}
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
		seg.update(i,a[i]);
	}
	ll ans = 0ll;
	for(int i=0;i<N;i++){
		int L = search_L(i);
		int R = search_R(i);
		ans += (ll)(i-L+1)*(ll)(R-i+1)*(ll)a[i];
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  for (int i = 0; i < (1 << (s.size() - 1)); ++i) {
    st = {s[0]};
    int t = s[0] - '0';
    for (int j = 0; j < s.size() - 1; ++j) {
      if (i & (1 << j))
        t += s[j + 1] - '0', st = st + "+" + s[j + 1];
      else
        t -= s[j + 1] - '0', st = st + "-" + s[j + 1];
    }
    if (t == 7) {
      st = st + "=7";
      break;
    }
  }

  cout << st << endl;
  return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    map<int, int> MP;
    MP[A]++, MP[B]++, MP[C]++;
    if (MP[A] == 1) cout << A << endl;
    else if (MP[B] == 1) cout << B << endl;
    else cout << C << endl;
    return 0;
}

Measured memory_bytes: 256
#E A, B, C = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars

n = S.size
res = Array.new(n, 0)

# Set cnts from R
cnt = 0  # count of R
0.upto(n-1).each do |i|
  if S[i] == 'R'
    cnt += 1
    next
  end

  # L is Found. index is i
  res[i]   += cnt / 2        # RRRL -> 1 (3/2)
  res[i-1] += (cnt + 1) / 2  # RRRL -> 2 ((3+1)/2)
  cnt = 0
end

# Set cnts from L
cnt = 0  # count of L
(n-1).downto(0).each do |i|
  if S[i] == 'L'
    cnt += 1
    next
  end
  
  # R is found. index is i
  res[i]   += cnt / 2       # RLLL -> 1 (3/2)
  res[i+1] += (cnt + 1) / 2 # RLLL -> 2 ((3+1)/2)
  cnt = 0
end

print res.join(" ")

Measured memory_bytes: 10620
#include<bits/stdc++.h>
#define MAXN 2005
#define M 1000000007
using namespace std;
long long fac[MAXN],inv[MAXN],ans[MAXN];
long long qpow(long long a,long long b)
{
    long long t=1,y=a;
    while(b)
    {
        if(b&1)
            t=t*y%M;
        y=y*y%M;
        b/=2;
    }
    return t;
}
void init()
{
    fac[0]=fac[1]=1;
    for(long long i=2;i<MAXN;i++)
        fac[i]=(fac[i-1]*i)%M;
    inv[MAXN-1]=qpow(fac[MAXN-1],M-2);
    for(long long i=MAXN-2;i>=0;i--)
        inv[i]=inv[i+1]*(i+1)%M;
}
int main()
{
    init();
    long long n,k;
    cin>>n>>k;
    long long t=min(k,n-k+1);
    for(long long i=1;i<=t;i++)
    {
        long long t1=fac[n-k+1]*inv[i]%M*inv[n-k+1-i]%M;
        long long t2=fac[k-1]*inv[i-1]%M*inv[k-i]%M;
        ans[i]=t1*t2%M;
    }
    for(long long i=1;i<=t;i++)
        cout<<ans[i]<<endl;
    for(long long i=t+1;i<=k;i++)
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

ans = 0
sum = {} # sum[x] == (l + a[l] = x なる l の個数)
# 0 <= l < r < n なる (l,r) の全探索
for r in range(n):
  ans += sum.get(r - a[r], 0)
  sum[r + a[r]] = sum.get(r + a[r], 0) + 1
  
  # for l in range(r):
    # if r - l == a[l] + a[r]:
    # if r - a[r] == l + a[l]:
      # ans += 1
print(ans)


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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long



using namespace std;
// #define PI 3.14159265358979323846
// cout << fixed << setprecision(20);


string getStr(const long long a) {
    switch(a) {
    case (0): return "z";
    case (1) : return "a";
    case (2) : return "b";
    case (3) : return "c";
    case (4) : return "d";
    case (5) : return "e";
    case (6) : return "f";
    case (7) : return "g";
    case (8) : return "h";
    case (9) : return "i";
    case (10): return "j";
    case (11): return "k";
    case (12): return "l";
    case (13): return "m";
    case (14): return "n";
    case (15): return "o";
    case (16): return "p";
    case (17): return "q";
    case (18): return "r";
    case (19): return "s";
    case (20): return "t";
    case (21): return "u";
    case (22): return "v";
    case (23): return "w";
    case (24): return "x";
    case (25): return "y";
    }
}

int main(int, const char**)
{
    long long N = 0;
    cin >> N;
  	
    // 26の何乗かを計算する
    string name;
    while (N != 0) {
        name = getStr(N % 26) + name;
      	if (N%26 == 0) {
        	N /= 26;
        	N--;
        } else
        {
        	N /= 26;
        }
    }
    cout << name << endl;

    return 0;
}



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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

const int inf = (1<<28);
const ll infl = (1LL<<60);
const int mod = 1e9+7;

int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll c = a + b;
    ll ans = (n / c) * a + min(n % c, a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]

tree = [[] for _ in range(N)]

for e in E:
    tree[e[0] - 1].append(e[1] - 1)
    tree[e[1] - 1].append(e[0] - 1)

visited = [0 for _ in range(N)]
visited[0] = 1

order = [None for _ in range(N)]
od = 0
order[0] = 0

parent = [0 for _ in range(N)]
parent[0] = -1

stack = [0]

while stack:
    node = stack.pop()
    for adj in tree[node]:
        if not visited[adj]:
            visited[adj] = 1
            od += 1
            order[od] = adj
            parent[adj] = node
            stack.append(adj)

dp = [[1, 1] for _ in range(N)]

for node in order[::-1]:
    for adj in tree[node]:
        if parent[adj] == node:
            dp[node][0] *= dp[adj][0] + dp[adj][1]
            dp[node][0] %= MOD
            dp[node][1] *= dp[adj][0]
            dp[node][1] %= MOD

print((dp[0][0] + dp[0][1]) % MOD)

Measured memory_bytes: 54376
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int k = Integer.parseInt(str[2]);
    for(int i=a; i<=b; i++) {
      if(i<a+k)
        System.out.println(i);
      else if(i>b-k)
        System.out.println(i);
    }
  }
}

Measured memory_bytes: 33400
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
   string s ;
   cin >> s ;
   size_t n = s.length() ;
   for(int i = 0 ; i < n ; i++){
      if(s[i] == ','){
          cout << " " ;
      }else{
          cout << s[i] ;
      }
   }
   cout << endl;
   return 0 ;
}

Measured memory_bytes: 3636
A = {}

for i in range(int(input().strip())):
  s, p_s = input().strip().split(' ')
  if s not in A: A[s] = []
  A[s].append((int(p_s), i + 1))

for s, ls in sorted(A.items()):
  for p, i in sorted(ls, reverse=True):
    print(i)

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

int main() {

  char d[5] = { '.', ',', '!', '?', ' ' };

  int m[10] = { 5, 3, 3, 3, 3,  3,  4,  3,  4 };
  int h[10] = { 0, 0, 3, 6, 9, 12, 15, 19, 22 };

  long long int n;
  cin >> n;

  for ( long long int i = 0; i < n; i++ ) {

    string in;
    cin >> in;

    long long int a = -1;
    long long int b = -1;
    char c;

    for ( long long int j = 0; j < in.size(); j++ ) {

      if ( in[j] == '0' ) {
	if ( a == -1 ) continue;
	b %= m[a-1];
	if ( a == 1 ) {
	  c = d[b];
	}else {
	  c = 'a' + h[a-1] + b;
	}
	cout << c;
	a = -1;
	b = -1;
      }else {
	a = in[j] - '0';
	b++;
      }

    }

    cout << endl;

  }

  return 0;

}

Measured memory_bytes: 1200
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define LEN 100000
#define min(a,b) (((a)<(b)) ? (a) : (b))

typedef struct{
  char name[100];
  int t;
}p;

p q[LEN];
int head=0,tail=0,n;

void enqueue(p x){
  int next=(tail+1)%LEN;

  if(head==next){
    printf("Queue overflow!\n");
    exit(2);
  }

  q[tail]=x;
  tail=next;
}
p dequeue(void){
  p x;

  if(head==tail){
    printf("Queue is empty!\n");
    exit(3);
  }

  x=q[head];
  head=(head+1)%LEN;
  return x;
}

int main(){
  int i,qn,c,time=0;
  p u;

  scanf("%d%d",&n,&qn);

  for(i=1;i<=n;i++){
    scanf("%s%d",q[i].name,&q[i].t);
    enqueue(q[i]);
  }

  while(head!=tail){
    u=dequeue();                  //処理するものを取り出す
       c=min(qn,u.t);                //ｑｍｓと処理するものを比較
    u.t-=c;                      //処理するものを比較して値が小さかったほうで引く
    time+=c;                     //経過時間を計算
    if(u.t>0) enqueue(u);        //処理が終了していないものはもう１度、キューを行う
    else{
      printf("%s %d\n",u.name,time);
    }
  }


  return 0;
}


Measured memory_bytes: 11956
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

int n;
string str[15];
int e[15][15];
int dp[(1<<15)][15];

void solve(){
	rep(i,15) rep(j,15) e[i][j] = INF;
	rep(i,(1<<15)) rep(j,15) dp[i][j] = INF;
	
	rep(i,n) cin >> str[i];
	while(true){
		bool end = true;
		rep(i,n) for(int j = i+1; j < n; j++){
			if(str[i].size() > str[j].size()){
				swap(str[i],str[j]);
				end = false;
			}
		}
		if(end) break;
	}
	
	while(true){
		bool end = true;
		rep(i,n){
			for(int j = i+1; j < n; j++){
				rep(k,str[j].size()){
					bool ok = true;
					if(k+str[i].size()-1 >= str[j].size()) break;
					rep(l,str[i].size()){
						if(str[i][l] != str[j][k+l]){
							ok = false;
							break;
						}
					}
					if(ok){
						for(int l = i; l < n-1; l++) str[l] = str[l+1];
						end = false;
						n--;
						break;
					}
				}
				if(!end) break;
			}
			if(!end) break;
		}
		if(end) break;
	}
	
	rep(i,n) rep(j,n){
		if(i == j) continue;
		int cnt = 0;
		for(int k = 1; k <= 20; k++){
			bool ok = true;
			if(str[i].size() < k || str[j].size() < k) break;
			rep(l,k){
				if(str[i][str[i].size()-k+l] != str[j][l]){
					ok = false;
					break;
				}
			}
			if(ok) cnt = k;
		}
		e[i][j] = str[j].size()-cnt;
	}
	vector<int> fl;
	rep(i,(1<<n)){
		int t = i;
		fl.clear();
		for(int j = 0;;j++){
			if(t == 0) break;
			if(t&1) fl.push_back(j);
			t >>= 1;
		}
		if(fl.size() == 0) continue;
		if(fl.size() == 1){
			dp[i][fl[0]] = str[fl[0]].size();
			continue;
		}
		rep(j,fl.size()){
			int f = fl[j];
			rep(k,fl.size()) if(f != fl[k]) dp[i][f] = min(dp[i][f],dp[i-(1<<f)][fl[k]]+e[fl[k]][f]);
		}
	}
	int ans = INF;
	rep(i,n) ans = min(ans,dp[(1<<n)-1][i]);
	cout << ans << endl;
}

int main(){
	while(true){
		cin >> n;
		if(n == 0) break;
		solve();
	}
}

Measured memory_bytes: 3152
X, Y = [int(i) for i in input().split()]

ans = "No"
for i in range(101):
    if ans != "No":
        break
    for j in range(101):
        if i+j != X:
            continue
        if i*2 + j*4 == Y:
            ans = "Yes"
            break
print(ans)

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


int main()
{
    ll a, b;
    cin >> a >> b;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9){
        cout << a * b << endl;
    }else cout << -1 << endl;



}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
//#define x first
//#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
const int MAX_N = 2e5 + 5;
/*const double r = 20.0 - 5.0 * acos(-1.0);
int sx, sy, ex, ey, n;
int tx, ty, cnt;
struct Node{
    int x, y;
    bool operator < (const Node& rhs) const {
        return (x+y) < (rhs.x+rhs.y);
    }
} node[MAX_N];*/
char s[MAX_N];
int cnt[26];


int main()
{
#ifdef ANONYM
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    clock_t rtime = clock();
#endif

    /*scanf("%d%d%d%d%d", &sx, &sy, &ex, &ey, &n);
    node[cnt++] = (Node){sx, sy};
    node[cnt++] = (Node){ex, ey};
    REP(i, 0, n) {
        scanf("%d%d", &tx, &ty);
        if(tx+ty>sx+sy && tx+ty<ex+ey) node[cnt++] = (Node){tx, ty};
    }
    sort(node, node+cnt);*/
    scanf("%s", s);
    int len = strlen(s);
    LL ans = 1; cnt[s[0]-'a']++;
    REP(i, 1, len) {
        REP(j, 0, 26) {
            if((s[i]-'a') != j) ans += cnt[j];
        }
        cnt[s[i]-'a']++;
    }
    cout << ans << endl;


#ifdef ANONYM
    debug("time: %d\n", (int)(clock() - rtime));
#endif
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int h, w; cin >> h >> w;
	pair<char,int> ans;
	for(int i = 1; i <= h; i++) {
		for(int j = 0; j < w; j++) {
			string s; cin >> s;
			if(s == "snuke") {
				ans = make_pair('A' + j, i);
			}
		}
	}
	cout << ans.first << ans.second << endl;
		
	return 0;                                              
}
	


Measured memory_bytes: 256
using System;


    class Program
    {     
        static void Main(string[] args)
        {
            string[] line1 = Console.ReadLine().Split(' ');
            int k = int.Parse(line1[0]);
            int t = int.Parse(line1[1]);
            int[] a = new int[t];
            string[] line2 = Console.ReadLine().Split(' ');
            int max = 0;
            for (int i = 0; i < t; i++)
            {
                a[i] = int.Parse(line2[i]);
                if (max < a[i])
                    max = a[i];
            }                       
            int result = k - 1 - (k - max)*2;
            Console.Write(result > 0 ? result : 0);
        }
    }



Measured memory_bytes: 2648
import java.util.*;
import java.math.*;
import java.lang.*;
import java.io.*;

public class Main{
  public static void main(String args[]) throws IOException{
    Scanner s=new Scanner(System.in);
   
    
    
    String ss=s.next();
    ArrayList<String>l=new ArrayList<String>();
    l.add("SAT");
    l.add("FRI");
    l.add("THU");
    l.add("WED");
          l.add("TUE");
    l.add("MON");
    l.add("SUN");
    
    System.out.println(l.indexOf(ss)+1);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
#include<vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    string ans = "APPROVED";
    rep(i,N) {
        if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
            ans = "DENIED";
            break;
        }
    }

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

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

int main() {
  int N;
  string S;

  int J = 0;

  cin >> N;

  for ( int i = 0; i < N; i++){
    cin >> S;
    if( S == "Y"){
      J = 1;
      break;
    }
  }
  if ( J == 1){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long h, w, k;
char c[10][10];
int check (int bith, int bitw){
	int br=h*w;
	for (int i=0; i<h; i++){
		for (int j=0; j<w; j++){
			if (c[i][j]=='.' or (1<<i)&bith or (1<<j)&bitw)
				br--;
		}
	}
	if (br==k) return 1;
	else return 0;
} int ans=0;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> h >> w >> k;
for (int i=0; i<h; i++)
	for (int j=0; j<w; j++)
		cin >> c[i][j];
for (int i=0; i<(1<<h); i++){
	for (int j=0; j<(1<<w); j++){
		ans += check(i, j);
	}
} cout << ans << endl;
return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;

ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> num(k + 1, 0);
	//num[k] = 1;
	//all_gcd がkとなるものは1つ
	for (ll i = k; i >= 1; i--) {
		num[i] = modpow(k / i, n);
		for (int j = i * 2; j <= k; j += i)
			num[i] -= num[j];
	}
	ll ans = 0;
	for (int i = 1; i <= k; i++) {
		ans += i * num[i] % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n, m;
int cnt[100005];
int p[100001];
ll ans = 0;

int main() {
	std::cin >> n >> m;
	std::cin >> p[0];
	--p[0];
	REP(i, 1, m) {
		std::cin >> p[i];
		--p[i];
		++cnt[std::min(p[i - 1], p[i])], --cnt[std::max(p[i - 1], p[i])];
	}

	REP(i, 1, n - 1)cnt[i] += cnt[i - 1];

	rep(i, n - 1) {
		int a, b, c;
		std::cin >> a >> b >> c;
		ans += std::min((ll)a * cnt[i], (ll)b * cnt[i] + c);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1940
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(ll a,ll b,ll ar,ll br){
  return ar+(br-ar+b)%b*modinv(a,b)%b*a;
}
ll garner2(ll a,ll b,ll ar,ll br){
  ar%=a;
  br%=b;
  ll ret=ar+  ( ((br-ar)%b)*(moddiv(1,a,b)%b)%b +b )%b *a;
  return ret;
}

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





int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (val0==1)continue;
      if (val1==1)continue;
      if (gcd(val0,val1)==1){
        ll ans0=garner2(val0,val1,1,0)-1;
        ll ans1=garner2(val0,val1,0,1)-1;
        //ans0%=val0*val1;
        //ans1%=val0*val1;
        if (ans0>1)
          ans=min(ans,ans0);
        if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }


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

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

#define PX(p) (p.first)
#define PY(p) (p.second)
typedef pair <int, int> p2i;

const int MAXN = 3 * 100000 + 5;

int N, W, H, ans;
p2i pnts[MAXN];

class SegTree
{
public:
    int mx[MAXN * 4];
    int lz[MAXN * 4];

    inline int LC(int x)
    {
        return (x << 1);
    }
    inline int RC(int x)
    {
        return (x << 1) | 1 ;
    }

    void reset()
    {
        memset(mx, 0x00, sizeof mx);
        memset(lz, 0x00, sizeof lz);
    }
    void Pushup(int x)
    {
        mx[x] = max(mx[LC(x)], mx[RC(x)]) + lz[x];
    }

    void Modify(int CL, int CR, int CV, int L = 1, int R = ::N, int x = 1)
    {
        if(CL <= L && R <= CR)
        {
            mx[x] += CV, lz[x] += CV;
            return;
        }

        int mid = (L + R) >> 1 ;

        if(CL <= mid)
            Modify(CL, CR, CV, L, mid, LC(x));
        if(mid < CR)
            Modify(CL, CR, CV, mid + 1, R, RC(x));
        Pushup(x);
    }
}ST;

p2i stk1[MAXN], stk2[MAXN];
void solve()
{
    sort(&pnts[1], &pnts[N+1]);
    ST.reset();

    int topa(0), topb(0);

    int MID = H / 2;

    for(int i = 1; i <= N - 1; i++)
    {
        int nxt = i - 1;
        if(pnts[i].second <= MID)
        {
            while(topa && stk1[topa].second < pnts[i].second)
            {
                ST.Modify(stk1[topa].first, nxt, stk1[topa].second - pnts[i].second);
                nxt = stk1[topa].first - 1;
                topa--;
            }
            if(nxt != i - 1)
                stk1[++topa] = make_pair(nxt+1, pnts[i].second);
        }
        else
        {
            while(topb && pnts[i].second < stk2[topb].second)
            {
                ST.Modify(stk2[topb].first, nxt, pnts[i].second - stk2[topb].second);
                nxt = stk2[topb].first - 1;
                topb--;
            }
            if(nxt != i - 1)
                stk2[++topb] = make_pair(nxt+1, pnts[i].second);
        }

        stk1[++topa] = make_pair(i, 0);
        stk2[++topb] = make_pair(i, H);

        ST.Modify(i, i, H - pnts[i].first);
        ans = max(ans, ST.mx[1] + pnts[i+1].first);
    }
}

int main()
{
    int u, v;
    cin >> W >> H >> N ;

    for(int i = 1; i <= N; i++)
        cin >> u >> v , pnts[i] = (make_pair(u, v));
    pnts[++N] = (make_pair(0, 0));
    pnts[++N] = (make_pair(W, H));

    solve();

    for(int i = 1; i <= N; i++)
        swap(pnts[i].first, pnts[i].second);
    swap(W, H);

    solve();

    cout << (ans << 1) << endl ;
    return 0;
}


Measured memory_bytes: 15616
import sys
sys.setrecursionlimit(10 ** 7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    l = input()
    li = [l[i] for i in range(len(l))]

    u = len(set(li))
    c = li.count(li[0])

    if u == 2 and c == 2:
        print("Yes")
    else:
        print("No")

solve()

Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>


using std::string;
using std::vector;


void solve() {
    // input
    int n;
    scanf("%d", &n);
    vector<int> list(n);
    for (int i = 0; i < n; i++){
        int v;
        scanf("%d", &v);
        list[i] = v;
    }

    // sort
    int swaped = 0;
    for(int i = 0; i < list.size(); i++){
        int minIndex = i;
        for(int j = i + 1; j < list.size(); j++){
            if(list[j] < list[minIndex]){
               minIndex = j;
            }
        }
        if(i != minIndex) {
            std::swap(list[i], list[minIndex]);
            swaped++;
        }
    }
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n%d\n", swaped);
    
}

int main() {
    
    solve();
    
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
const int num = 100001;
vector <int> adj[num];
int vis[num],level[num];
void dfs(int cur)
{
	vis[cur] = 1;
	for(int i=0;i<adj[cur].size();i++)
	{
		int child = adj[cur][i];
		if(!vis[child])
		{
			dfs(child);
		}
		level[cur] = max(level[cur],1+level[child]);
	}
}
int main()
{
	int n,m,x,y;
	cin >> n >> m;
	for(int i=0;i<m;i++)
		cin >> x >> y,adj[x].push_back(y);
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
			dfs(i);
	}
	int ans = 0;
	for(int i=1;i<=n;i++)
		ans = max(ans,level[i]);
	cout << ans << "\n";
}
	


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

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

signed main() {
	cout.precision(16);
	double ans = 0;
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		int j;
		for (j = 0; i * pow(2., j) < k; ++j);
		ans += pow(2, -j) / n;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N;
    cin >> N;
    
    // calculation
    if (N == 3 || N == 5 || N == 7) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long N,p;
  scanf("%ld",&N);
  int flag[N+1];
  long ans = 0;

  for(int i = 0;i < N+1;i++) flag[i] = 0;
  for(int i = 1;i < N+1;i++){
    scanf("%ld",&p);
    if(i == p) flag[i-1] = 1;
  }

  for(int i = 0;i < N;i++){
    if(flag[i]){
      ans++;
      flag[i+1] = 0;
    }
  }

  printf("%ld\n",ans);

  return 0;
}

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

int main() {
  char c;
  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}


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

int main() {
  
  int A,B;
  cin >> A >> B;
  
  if ( 6 - ( A + B ) == 3 ){
    cout << 3 << endl;
  }else if ( 6 - ( A + B ) == 2 ){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256