akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n;
    cin>>n;
    ll i,j;
    ll a[n];
    for(i=0;i<n;i++)cin>>a[i];
    string print[3];
    print[0]="pairwise coprime";
    print[1]="setwise coprime";
    print[2]="not coprime";

    mll m;
    ll g=0;
    for(i=0;i<n;i++)
    {
        g=gcd(g,a[i]);
        // cout<<a[i]<<" ";
        for(j=2;j*j<=a[i];j++)
        {
            if(a[i]%j==0)
            {
                m[j]++;
                // cout<<j<<" ";
                while(a[i]%j==0)
                {
                    a[i]/=j;
                }
            }
        }
        if(a[i]>1)
        {
            // cout<<a[i]<<" ";
            m[a[i]]++;
        }
        // cout<<"\n";
    }
    
    ll f=0;
    for(auto it:m)
    {
        if(it.second>1)
        {
           f=1;
           break; 
        }
    }
    if(!f)
    {
        cout<<print[0];
        return;
    }
    if(g==1)
    {
        cout<<print[1];
        return;
    }
    cout<<print[2];

    
}



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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 16212
def input_number():
    return int(input())

def is_odd(number):
    if number % 2 == 1:
        return True
    else:
        return False

def is_8(number):
    fraction_of_the_number = 0
    for i in range(1, int(number**0.5) + 1, 2):
        if number % i == 0:
            fraction_of_the_number += 2
    if fraction_of_the_number == 8 and is_odd(number):
        return True
    else:
        return False

def main():
    n = input_number()
    answer = 0
    for i in range(1, n+1, 2):
        if is_8(i):
            answer += 1
    print(answer)

main()

Measured memory_bytes: 3188
#include <iostream>

int main()
{
    long long int x,r,d;
    std::cin>>r>>d>>x;
    for (int i=0; i<10; i++)
    {
        long long int tmp=x*r-d;
        x=tmp;
        std::cout<<x<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    vector<ll> sum(n);
    rep(i, n) sum[i] = a[i] + b[i];
    sort(all(sum)); reverse(all(sum));

    ll ans = 0;
    rep(i, n) ans -= b[i];
    rep(i, n) {
        if (i % 2 == 0) ans += sum[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.io._
import java.util.StringTokenizer

import scala.reflect.ClassTag

object Main {
  def main(args: Array[String]): Unit = {
    try {
      val (in, out) =
        if (isOnlineJudge) {
          (
            new FastScanner(new InputStreamReader(System.in)),
            new PrintWriter(System.out)
          )
        } else {
          (
            new FastScanner(new FileReader(new File("src/resource/problem.in"))),
            new PrintWriter(new File("src/resource/problem.out"))
          )
        }
      new Abc152(in, out).solve()
      out.flush()
      out.close()
    } catch {
      case e: IOException => e.printStackTrace()
    }
  }

  private[this] val isOnlineJudge = true

  class FastScanner(val streamReader: InputStreamReader) {
    private[this] val reader = new BufferedReader(streamReader, 32768)
    private[this] var tokenizer: StringTokenizer = _

    @inline private[this] final def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = Integer.parseInt(next())

    def nextLong(): Long = java.lang.Long.parseLong(next())

    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()

    def nl(): Long = nextLong()

    def nc(): Char = nextChar()

    def ns(): String = next()

    def ns(n: Int): Array[Char] = ns().toCharArray

    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)

    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }

    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }

    def nal(n: Int): Array[Long] = map(n)(_ => nl())

    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while (i < N) {
      f(i);
      i += 1
    }
  }

  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while (i >= offset) {
      f(i);
      i -= 1
    }
  }

  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from)(f)
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class Abc152(fScanner: Main.FastScanner, out: java.io.PrintWriter) {

  import Main._
  import fScanner._

  def solve(): Unit = {
    if(ni() == ni()) out.println("Yes") else out.println("No")
  }
}


Measured memory_bytes: 25524
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int x;
    int y;
    int z;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        y = sc.nextInt();
        z = sc.nextInt();
        sc.close(); 

        // 解答処理
        solve();
    }
    
    private void solve() {
        int tmp = x;
        x = y;
        y = tmp;

        tmp = x;
        x = z;
        z = tmp;
        System.out.println(x + " " + y + " " + z);
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int f(vi &v)
{
	int n = v.size();
	vector<vi> dp(3, vi(n + 1, -1));
	dp[1][0] = 0;
	REP(p, n)REP(a, 3)
	{
		if (dp[a][p] == -1) continue;
		chmax(dp[0][p + 1], dp[a][p]);
		if (a != 2 && p < n - 1)
		{
			if(v[p + 1] > 1) chmax(dp[2][p + 1], dp[a][p] + v[p]);
			else chmax(dp[1][p + 2], dp[a][p] + v[p]);
		}
		if (a == 2 && p < n - 1)
		{
			if (v[p + 1] > 1) chmax(dp[2][p + 1], dp[a][p] + v[p] - 1);
			else chmax(dp[1][p + 2], dp[a][p] + v[p] - 1);
		}
		if (a == 0)
		{
			chmax(dp[1][p + 1], dp[a][p] + v[p]);
			if(v[p] > 1) chmax(dp[0][p + 1], dp[a][p] + v[p] - 1);
		}
	}
	int res = max(dp[0][n], dp[1][n]);
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	string s; cin >> s;
	vi v;
	int tmp = 0;
	int ans = 0;
	REP(i, n)
	{
		if (s[i] == '0' && (i == 0 || s[i - 1] == '0'))
		{
			ans += f(v);
			v.clear();
			tmp = 0;
		}
		else if (s[i] == '0')
		{
			v.push_back(tmp);
			tmp = 0;
		}
		else tmp++;
	}
	if (tmp > 0) v.push_back(tmp);
	ans += f(v);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1172
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      int w = sc.nextInt();
      int i=0;
      while(i<S.length()){
        System.out.print(S.charAt(i));
        i+=w;
      }
    }
}

Measured memory_bytes: 36240
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;

int z(const string &s) {
  int n = s.size();
  vector<int> ret(n, 0);
  ret[0] = n;
  int i = 1, j = 0;
  int val_max = 0;
  while (i < n) {
    while (i + j < n && s[j] == s[i + j])
      j++;
    ret[i] = j; // s[0,j-1] = s[i,i+j-1] && s[j] != s[i+j]
    val_max = max(min(ret[i], i), val_max);

    if (j == 0) {
      i++;
      continue;
    }

    // j > 0
    int k = 1;
    while (i + k < n && k + ret[k] < j) {
      ret[i + k] = ret[k];
      val_max = max(min(ret[i + k], i + k), val_max);
      k++;
    }
    i += k;
    j -= k;
  }
  return val_max;
}

int main(int argc, char const *argv[]) {
  string s;
  int n;
  cin >> n >> s;
  int ret = 0;
  for (int i = 0; i < n; i++) {
    ret = max(ret, z(s.substr(i)));
    // cout << z(s.substr(i)) << s.substr(i) << endl;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x + r <= W){
		if (y + r <= H){
			if (x>0){
				if (y>0){ cout << "Yes"<<endl; return 0; }
			}
		}
	}
	cout << "No"<<endl; return 0;
}



Measured memory_bytes: 3084
use proconio::*;

fn main() {
    input! {
        _n: u32,
        k: usize,
        s: String
    };
    let mut ans = String::new();
    for (index, c) in s.chars().enumerate() {
        if index == k - 1 {
            ans.push_str(&c.to_ascii_lowercase().to_string());
        } else {
            ans.push_str(&c.to_string());
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
package main

import (
	"fmt"
)

func main() {
	var s string
	var count int
	fmt.Scan(&s)


	for i := 0; i < len(s); i++ {
        // "1"と'1'の違いとは
		if s[i] == '1' {
			count++
		}
	}
	// for _, character := range s {
	// 	fmt.Println(character)
	// 	if character == '1' {
	// 		count++
	// 	}
	// }

	fmt.Println(count)
}


Measured memory_bytes: 512
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    li a,b;
    char c;
    cin>>a>>c>>b;
    cout<<((c=='+')?a+b:a-b)<<endl;

    return 0;
}


Measured memory_bytes: 256
# ABC054c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
l = [set() for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    l[a].add(b)
    l[b].add(a)

visited = [False]*(n+1)


def dfs(i, cnt):
    #print(i, cnt)
    if (cnt == n):
        return 1
    ans = 0
    for j in l[i]:
        if (visited[j]):
            continue
        visited[j] = True
        ans += dfs(j, cnt + 1)
        visited[j] = False
    return ans


visited[1] = True
print(dfs(1, 1))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int a[1000005];
int del=0;
int main()
{
	int n,c=0,x;
	cin>>n;
	while(c<n)
	{
		cin>>x;
		if(x <= 100000)
		{
			a[x]++;
		}
		else
		{
			del++;
		}
		c++;
	}
	for(int i=1;i<=100000;i++)
	{
		if(a[i] != 0)
		{
			if(a[i] > i)
			{
				del=del+a[i]-i;
			}
			else if(a[i] < i)
			{
				del=del+a[i];
			}
		}
	}
	cout<<del<<endl;
	return 0;
}

Measured memory_bytes: 384
from collections import Counter

class UnionFind():
  def __init__(self,n):
    self.parents=[-1]*n
  
  def find(self,x):
    if self.parents[x]<0:
      return x
    
    self.parents[x]=self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
    
    self.parents[x]+=self.parents[y]
    self.parents[y]=x
    
N,K,L=map(int,input().split())
uf_road=UnionFind(N+1)
uf_train=UnionFind(N+1)

for _ in range(K):
  p,q=map(int,input().split())
  uf_road.union(p,q)

for _ in range(L):
  s,t=map(int,input().split())
  uf_train.union(s,t)
  
union_sets=[(uf_road.find(i),uf_train.find(i)) for i in range(1,N+1)]
counts=Counter(union_sets)
ans=[counts[union_set] for union_set in union_sets]

print(' '.join(str(a) for a in ans))

Measured memory_bytes: 57508
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

signed main(){
  ll a,b,k; cin>>a>>b>>k;
  bool flg = true;
  if(a>=k){
    a = a-k;
    k = 0;
    flg = false;
  }else{
    k = k-a;
    a = 0;
  }
  
  if(flg){
    ll z = 0;
    b = max(b-k,z);
  }
  cout << a SP b << endl;

  return 0;
}


Measured memory_bytes: 256
w,h = map(int, input().split())
n = int(input())
p = list(map(int, input().split()))
u = m = cnt = 0
for i in range(n):
    if p[i] == 0:
        u += 1
    else:
        m += 1
    if u <= w-2:
        if u == m:
            cnt += 1
    elif w <= u <= w+h-3:
        if u == m+2:
            cnt += 1
    elif h+h-1 <= u:
        if u == m+4:
            cnt += 1
print(cnt)



Measured memory_bytes: 5596
N, M, Q = map(int, input().split())

j = 0
S = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    S[L][R] += 1
for i in range(1, N + 1):
    for j in range(1, N + 1):
        S[i][j] += S[i][j - 1]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        S[i][j] += S[i - 1][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(S[q][q] + S[p - 1][p - 1] - S[p - 1][q] - S[q][p - 1])


Measured memory_bytes: 58072
#include <stdio.h>
#include <algorithm>
using namespace std;

int n, ls[300];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < 2*n; i++) scanf("%d", ls+i);
    sort(ls, ls+2*n);
    int ans = 0;
    for (int i = 0; i < n; i++) ans += ls[i*2];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;r;end

function main()
	ss = readline() |> chomp
	tt = readline() |> chomp
	s = Int[Int(ss[i])-96 for i in 1:length(ss)]
	t = Int[Int(tt[i])-96 for i in 1:length(tt)]
	n = length(s)
	d = Dict{Int,Array{Int,1}}()
	dp = -ones(Int,n+1,26)
	for i in 1:n
		if haskey(d,s[i])
			push!(d[s[i]],i)
		else
			d[s[i]] = Int[i]
		end
	end
	for i in 1:n
		push!(d[s[i]],n+i)
	end
	for i in 1:n
		for j in keys(d)
			dp[i,j]=d[j][bsearch(d[j],i)]
		end
	end
	k = 0
	now = 0
	for i in 1:length(t)
		if dp[now+1,t[i]]<0
			k = -1
			break
		else
			now = dp[now+1,t[i]]
			if now>=n
				k += n
				now = now%n
			end
		end
	end
	println(k==-1?-1:k+now)
end

main()

Measured memory_bytes: 199884
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  set<int> s;
  rep(i, N) {
    s.insert(A[i]);
  }

  if (len(s) == N)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define NUM_MAX 50

enum type {
    TYPE_WHITE = '.',
    TYPE_BLACK = '#',
};

struct point2d {
    int x;
    int y;
};

int main(void) {
    int as, bs;
    static char amap[NUM_MAX*2+1][NUM_MAX*2+1];
    static char bmap[NUM_MAX*2+1][NUM_MAX*2+1];
    // assume that as >= bs
    get_int2(&as, &bs);
    int flag = 0;
    int i, j;
    for(i = 0; i < as; i++) {
        get_str(amap[i], as);
    }
    for(i = 0; i < bs; i++) {
        get_str(bmap[i], bs);
    }

    int k1, k2;
    for(i = 0; i < as; i++) {
        for(j = 0; j < as; j++) {
            int ok = 1;
            for(k1 = 0; k1 < bs; k1++) {
                for(k2 = 0; k2 < bs; k2++) {
                    struct point2d ap = {i+k1, j+k2};
                    ok &= (amap[ap.x][ap.y] == bmap[k1][k2]);
                }
            }
            if(ok) { flag = 1; goto finish; }
        }
    }
finish:
    printf("%s\n", flag ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 128
require 'prime'

MAX = 100_000

# Eratosthenes Sieve
is_prime = {}
Prime.each(MAX) do |p|
  is_prime[p] = true
end

# 2017-like?
# cumulative sums
cs = Array.new(MAX) { |i| is_prime[i] && is_prime[(i + 1) / 2] ? 1 : 0 }
       .inject([0]) { |a, n| a << a.last + n }

# query
q = gets.to_i
q.times do
  l, r = gets.split.map(&:to_i)
  # [l,r) = l...r
  p cs[r + 1] - cs[l]
end


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

#define dcm(x) cerr << #x << ": " << x << endl;

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
    //clock_t start = clock();
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a, b, h; cin >> a >> b >> h;
    cout <<  (a+b)*h/2 << endl;
    //clock_t stop = clock();
    //cout << (double)(stop-start)/CLOCKS_PER_SEC << " (s)" << endl;
    return 0;
}









Measured memory_bytes: 256
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    ans = a[0]+sum(b)
    sub = ans
    for i in range(1, n):
        sub += a[i]
        sub -= b[i-1]
        if ans < sub:
            ans = sub
    print(ans)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i, 0, n - 1)cin >> a[i];
	rep(i, 0, n - 1)cin >> b[i];
	rep(i, 0, n - 2)cin >> c[i];

	int ans = 0;
	rep(i, 0, n - 1)
	{
		ans += b[a[i] - 1];
	}
	rep(i, 1, n - 1)
	{
		if (a[i] == a[i - 1] + 1)ans += c[a[i - 1] - 1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a[100] ,number ,b;
	
	scanf("%d" ,&number);
	
	for(b = 0; b < number;++b){
		scanf("%d" ,&a[b]);
	}
	
	for(b = number - 1; b > 0;--b){
		printf("%d " ,a[b]);
		}
		printf("%d\n" ,a[0]);
	return 0;
}

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

//C++のヘッダ
#include <string> //文字のやりくりに必要
#include <iostream> //コンソール入出力命令使用に必要
using namespace std; //この名前空間で上のコンソール入出力を使用する


int main(void)
{
	int n;
	int maxdig;
	int dig1,dig2;

	cin >> n;

	dig1 = n % 10;
	dig2 = (n % 100) / 10;
	maxdig = n / 100;

	if (dig2 > maxdig){
		cout << (maxdig + 1) * 111 << endl;
	}
	else if (dig2 == maxdig&&dig1 > maxdig){
		cout << (maxdig + 1) * 111 << endl;
	}
	else{
		cout << maxdig * 111 << endl;
	}

	return 0;
}



Measured memory_bytes: 764
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a, b, c = geta(int)

    print("win" if sum([a, b, c]) <= 21 else "bust")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
h,w = gets.chomp.split(" ").map(&:to_i)
s = h.times.map{gets.chomp}
map = [[-1,0],[0,-1],[0,1],[1,0]]
flg = true
for i in 0..h-1
  for j in 0..w-1
    if s[i][j] == "#"
      adj = false
      map.each do |d|
        k = i+d[0]
        l = j+d[1]
        if 0 <= k && k < h && 0 <= l && l < w
          if s[k][l] == "#"
            adj = true
          end
        end
      end
      if !adj
        flg = false
      end
    end
  end
end
puts flg ? "Yes" : "No"

Measured memory_bytes: 14308
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()
    val S = rd.readString()

    val cnt = S.count { it == 'R' }
    val swap = S.slice(0 until cnt).count{ it == 'W' }

    val ans = swap
    println(ans)
}


//val rd = debug.Reader("abc", "174", "d", "sample-3")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


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

int main(){
	int n,count=0;
	string s;
	cin >> n;
	cin >> s;
	if(n%2 != 0){
		cout << "No" << endl;
	}else if(n%2 == 0){
		for(int i=0;i<n/2;i++){
			if(s.at(i) == s.at(i + n/2)){
				count++;
			}
		}
	    if(count == n/2){
		cout << "Yes" << endl;
	    }else{
		cout << "No" << endl;
	    }
	}

}

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

ll pow (ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return res;
}

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

  ll n;
  cin >> n;
  ll ans = pow ((ll)10, n) + pow ((ll)8, n) - (ll)2 * pow ((ll)9, n);
  ans = (ans + (ll)3 * mod) % mod;

  cout << ans << '\n';
}


Measured memory_bytes: 3644
#include <stdio.h>
int main(int argc, char *argv[])
{  char a[35];
    int i,j,t=1;
    gets(a);
    for(i=0;i<strlen(a);i++)
    {
        for(j=i+1;j<strlen(a);j++)
         if(a[i]==a[j])
         {  t=0;
            printf("no");
            break;
         }
        if(t==0)break;
    }

    if(t)
    printf("yes");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
ll a,b,dp[N],n,m,ans=-1;
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		for(int j=m-a;j>=0;j--)
			dp[j+a]=max(dp[j+a],dp[j]+b);
	}
	for(int i=0;i<=m;i++)ans=max(ans,dp[i]);
	cout<<ans;
	return 0;
}
/*
3 8
3 30
4 50
5 60
*/

Measured memory_bytes: 1024
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
  string a,b;cin>>a>>b;
  string str=a+b, ans="No";
  int num=atoi(str.c_str());
  for(int i=1;i<=10000;i++){
    if(num==(i*i)){ans="Yes"; break;}
    if(num<(i*i)) break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

namespace abc159B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int N = S.Length;
            string[] A = new string[N];
            for(int i = 0; i < N; i++)
            {
                A[i] = S.Substring(i, 1);
            }
            int X = 0;
            for(int i = 0; i < N/2; i++)
            {
                if (A[i] != A[N - 1 - i])
                    X += 1;
            }
            for (int i = 0; i < ((N - 1) / 2) / 2; i++)
            {
                if (A[i] != A[((N - 1) / 2) - 1 - i])
                    X += 1;
            }
            for(int i = (N + 3) / 2 - 1; i < (N- ((N + 3) / 2))/2; i++)
            {
                if (A[i] != A[N - 1 - i])
                    X += 1;
            }
            if (X == 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
def calc(a):
    b = []
    for i in a:
        v = 0
        if i.isnumeric():
            b.append(int(i))
        else:
            if i == '+':
                for _ in range(2):
                    v += b.pop()
                b.append(v)
            elif i == '-':
                for _ in range(2):
                    if _ == 0:
                        v -= b.pop()
                    else:
                        v += b.pop()
                b.append(v)
            elif i == '*':
                for _ in range(2):
                    if _ == 0:
                        v += b.pop()
                    else:
                        v *= b.pop()
                b.append(v)
    return b


if __name__ == '__main__':
    l = input().split()
    print(calc(l)[0])


Measured memory_bytes: 5600
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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

int main() {
    int n,k;
    int a[200010];
    int b[200010];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<=n;i++){
        b[i]=0;
    }
    for(int i=0;i<n;i++){
        b[a[i]]++;
    }
    sort(b,b+n+1,greater<int>());
    int sum=0;
    for(int i=0;i<k;i++){
        sum+=b[i];
        //cout<<b[i]<<endl;
    }
    cout<<n-sum<<endl;
    return 0;
}

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

const int M = 1e9 + 7;
template <int MOD=1000000007>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }

  friend Modular inverse(Modular b, long long m = MOD) {
    long long u = 0, v = 1, a = b.value;
    while (a != 0) {
      long long t = m / a;
      m -= t * a; swap(a, m);
      u -= t * v; swap(u, v);
    }
    return Modular(u);
  }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};
using mint = Modular<M>;

int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  
  int n; 
  cin >> n;
  mint sum = 0;
  vector<int> a(n);

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  
  mint ans = 0;   
  for (int i = 0; i < n; ++i) {
    ans += (sum-a[i])*a[i];
  }
  
  ans /= 2;
  cout << ans << '\n';
}


Measured memory_bytes: 3984
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    ll x = 0, y = 0, z = 0;
    int N;
    cin >> N;
    for (int i = 0;i < N;i++) {
    	ll q;
    	cin >> q;
    	if (q % 4 == 0) z++;
    	else if (q % 2 == 0) y++;
    	else x++;
    }
    if (z >= x) cout << "Yes" << endl;
    else if (z + 1 == x && y == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int N=5010;

int n,a,b;
int p[N],f[N];

main(){
    #define task "Rotation"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);

    n=in,a=in,b=in;
    forinc(i,1,n) p[i]=in;
    p[n+1]=n+1, n++;
    reset(f,127);
    f[0]=0;
    forinc(i,1,n){
        int cntx=0,cnty=0;
        fordec(j,i-1,0){
            if(p[j]<p[i]) f[i]=min(f[i],f[j]+cntx*b+cnty*a);
            if(p[j]<p[i]) cntx++; else cnty++;
        }
    }
    cout<<f[n];
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N;
	cin >> N;
	cout << (N*N*N) << endl;
	
	return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll n;
ll a[100005];
ll mxx=-1;
int main(){
  bool b=true;
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> a[i];
    if(a[i]-mxx>0){
        --a[i];
    }
    if(a[i]-mxx<0){
        b=false;
    }
    mxx=max(mxx,a[i]);
  }
  if(b){
    cout << "Yes";
  }else{
   cout << "No";
  }
  return 0;
}


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

    int X[100];
int main(){
    int N, K;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> X[i];
    }
    int ans =0;
    for(int i=0; i<N; i++){
        ans += 2*min(X[i], K-X[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  long n, k;
  cin.scan(n, k);

  long w = n / k;
  writeln(min(n - w * k, abs(n - (w + 1) * k)));
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    int a=0,b=0,c=0;
    Scanner s=new Scanner(System.in);
    a=s.nextInt();
    b=s.nextInt();
    c=s.nextInt();
    
    if(c-1<=a+b){
      System.out.println(b+c);
    }else{
      System.out.println(a+b+1+b);
    }
  }
}
    

Measured memory_bytes: 21844
object Main extends App {
  val sc = new FastScanner(System.in)
  val k = sc.nextInt()
  val s = sc.next().length

  val mod = 1000000007

  def plus(a: Long, b: Long): Long = (a + b) % mod
  def times(a: Long, b: Long): Long = (a * b) % mod

  def pow(a: Long, n: Int, res: Long = 1): Long = {
    if (n == 0) {
      res
    } else if ((n&1) == 0) {
      pow(times(a,a), n >> 1, res)
    } else {
      pow(times(a,a), n >> 1, times(res,a))
    }
  }

  def inv(a: Long): Long = pow(a, mod-2)

  def initFactTable(n: Int): IndexedSeq[Long] = {
    (1 to n).scanLeft(1L)(times(_,_))
  }

  val fact = initFactTable(s+k)

  def initInvFactTable(n: Int): IndexedSeq[Long] = {
    (1 to n).scanRight(inv(fact(n)))(times(_,_))
  }

  val invFact = initInvFactTable(s+k)

  def comb(n: Int, k: Int): Long = {
    times(times(fact(n), invFact(k)), invFact(n-k))
  }

  val pow25 = (0 until k).scanLeft(1L){ case (res, _) => times(res, 25)}
  val pow26 = (0 until k).scanLeft(1L){ case (res, _) => times(res, 26)}

  val ans = (s to s+k).map{ i =>
    times(times(comb(i-1, s-1), pow25(i-s)), pow26(s+k-i))
  }.reduceLeft(plus)

  println(ans)
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 310296
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int cmp(pair<int,int> a,pair<int,int> b){
	return a.second < b.second;
}

int main(){
	int n,a,b,now;
	while(cin >> n && n){
		bool flag = false;
		vector<pair<int,int> > p;
		rep(i,n){
			cin >> a >> b;
			p.push_back(make_pair(a,b));
		}
		sort(p.begin(),p.end(),cmp);
		now = 0;
		rep(i,n){
			now += p[i].first;
			//cout << p[i].first << " " << p[i].second << " b(" << now-p[i].first << ")" << " a(" << now << ")" << endl;
			if(now>p[i].second)flag = true;
		}
		if(!flag)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,M;

int main(){
    cin >> N >> M;
    ll x = N-2;
    ll y = M-2;
    if(x < 0) x = 1;
    if(y < 0) y = 1;
    ll ans = x * y;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;
ll C[100005];
ll A[100005];
ll inv(ll K, ll M) {
  ll A = M - 2;
  ll ret = 1;
  ll D = K;
  while (A > 0) {
    if (A % 2 == 1) {
      ret = (ret * D) % M;
    }
    D = (D * D) % M;
    A /= 2;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  sort(A, A+N);
  ll S = 0;
  ll M = 1000000007LL;
  C[K-1] = 1;
  ll I = inv(N+1-K, M);
  for (ll i=K; i<=N; i++) {
    C[i] = (C[i-1] * i) % M;
    C[i] = (C[i] * inv(i-(K-1), M)) % M;
  }
  for (ll i=0; i<N; i++) {
    ll m = (C[i] - C[N-1-i]) % M;
    m = (m + M) % M;
    ll d = (m * A[i]) % M;
    d = (d + M) % M;
    S = (S + d) % M;
  }
  cout << S << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

set<int> xset;
vector<pair<int, pair<int, int>>> v;
int main()
{
  int n, Q;
  cin >> n >> Q;
  REP(i, n)
  {
    int s, t, x;
    cin >> s >> t >> x;
    v.push_back(make_pair(s - x, make_pair(1, x)));
    v.push_back(make_pair(t - x, make_pair(-1, x)));
  }

  sort(v.begin(), v.end());
  int index = 0;
  REP(i, Q)
  {
    int q;
    cin >> q;
    while (v[index].first <= q && index < v.size())
    {
      auto vi = v[index];
      if (vi.second.first == 1)
      {
        xset.insert(vi.second.second);
      }
      else
      {
        xset.erase(vi.second.second);
      }
      index++;
    }
    if (xset.empty())
    {
      cout << -1 << endl;
    }
    else
    {
      cout << *xset.begin() << endl;
    }
  }
}


Measured memory_bytes: 16108
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

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

		HashSet<Long> answers = new HashSet<Long>();
		List<Long> list1 = getDivisors(n);
		list1.remove(0);
		for (long k : list1) {
			long n2 = n;
			while ((n2 % k) == 0 && n2 > 1) {
				n2 /= k;
			}
			if (n2 == 1 || n2 % k == 1) {
				answers.add(k);
			}
		}

		List<Long> list2 = getDivisors(n - 1);
		list2.remove(0);
		for (long k : list2) {
			answers.add(k);
		}

		System.out.print(answers.size());
	}

	public static List<Long> getDivisors(long number) {
		List<Long> list1 = new ArrayList<Long>();
		for (long i = 1; i < (long) Math.sqrt(number) + 1; i++) {
			if (number % i == 0) {
				list1.add(i);
			}
		}

		List<Long> list2 = new ArrayList<Long>();
		for (long i : list1) {
			long divisor = number / i;
			if (divisor != i) {
				list2.add(divisor);
			}
		}

		Collections.reverse(list2);
		list1.addAll(list2);
		return list1;
	}
}

Measured memory_bytes: 22612