akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt(), q = scanner.nextInt();
			int[][] x = new int[n + 1][n + 1], c = new int[n + 1][n + 1];
			IntStream.range(0, n + 1).forEach(i -> Arrays.fill(x[i], 0));
			IntStream.range(0, m).forEach(i -> x[scanner.nextInt()][scanner.nextInt()]++);
			Arrays.fill(c[0], 0);
			IntStream.rangeClosed(1, n).forEach(i -> c[i][0] = 0);
			IntStream.rangeClosed(1, n)
					.forEach(i -> IntStream.rangeClosed(1, n).forEach(j -> c[i][j] = c[i][j - 1] + x[i][j]));
			IntStream.range(0, q).forEach(i -> {
				int l = scanner.nextInt(), r = scanner.nextInt();
				System.out.println(IntStream.rangeClosed(l, r).map(j -> c[j][r] - c[j][l - 1]).sum());
			});
		}
	}
}


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

int main() {
  uint64_t N, K;
  cin >> N >> K;
  vector<uint64_t> v(N);
  for (uint64_t i = 0LL; i < N; i++) {
    uint64_t x;
    cin >> x;
    v.at(i) = x;
  }
  vector<uint64_t> va(N), vb(N);
  for (uint64_t i = 0LL; i< N; i++) {
    uint64_t cnt = 0LL;
    for (uint64_t j = 0; j < N; j++) {
      if (v.at(i) > v.at(j)) cnt++;
    }
    va.at(i) = cnt;
  }
  for (uint64_t i = 0LL; i < N; i++) {
    uint64_t cnt = 0LL;
    for (uint64_t j = i; j < N; j++) {
      if (v.at(i) > v.at(j)) cnt++;
    }
    vb.at(i) = cnt;
  }
  uint64_t a = 0LL, b = 0LL;
  for (uint64_t i = 0LL; i < N; i++) {
    a += va.at(i);
    b += vb.at(i);
  }
    uint64_t c = ((a * (((K * (K-1)) / 2)% 1000000007)) % 1000000007LL + (b * K) % 1000000007LL ) % 1000000007LL;
    cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<int> deqa;
    std::deque<int> deqb;
    int n,a,m,b;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a;
        deqa.emplace_back(a);
    }
    cin >> m;
    for (int j=0;j<m;j++) {
        cin >> b;
        deqb.emplace_back(b);
    }
    if (std::lexicographical_compare(deqa.begin(),deqa.end(),deqb.begin(),deqb.end())==true) {
        cout << "1" << endl;
    } else {
        cout << "0" << endl;
    }

}



Measured memory_bytes: 3164
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  if (a==1) a+=13;
  if (b==1) b+=13;
  if (a > b) cout << "Alice" << endl;
  else if (a < b) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int K, N;
    cin >> N >> K;
    vector<double> probs;
    int input[N];
    for (int i = 0; i < N; i++)
    {
        cin >> input[i];
    }
    probs.emplace_back(0);
    for (int i = 1; i <= 1000; i++)
    {
        probs.emplace_back((double)(1 + i) / 2.0);
    }
    double prev = 0.0;
    double current_max = -1;
    for (int l = 0; l < K; l++)
    {
        prev += probs[input[l]];
        current_max = max(prev, current_max);
    }
    for (int left = 1; left <= N - K; left++)
    {
        prev = prev - probs[input[left - 1]] + probs[input[left + K - 1]];
        current_max = max(prev, current_max);
    }
    cout << fixed << setprecision(10) << current_max << endl;
}


Measured memory_bytes: 1024
#include <cstdio>

int main()
{
    char N[10];
    scanf("%s", N);

    int ans = 0;
    for (int i = 0; i < 4; ++i) {
        if (N[i] == '2') ++ans;
    }

    printf("%d\n", ans);
    return 0;
}


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

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}


int main(void){
    char buf[100];

    my_gets(buf,100,stdin);
    switch (buf[0])
    {
        case 'A':
            puts("T");
            break;
        case 'T':
            puts("A");
            break;
        case 'C':
            puts("G");
            break;
        case 'G':
            puts("C");
            break;
        default:
            break;
    }

    return 0;
}

Measured memory_bytes: 128
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def conv_num2x(num, x):
    if (int(num/x)):
        return conv_num2x(int(num/x), x)+str(num%x)
    return str(num%x)

def main():
    N,K = LI()
    num_k = conv_num2x(N,K)
    print(len(str(num_k)))

main()



Measured memory_bytes: 27208
N = list(map(int, input()))
a,b,c,d = N[0], N[1], N[2], N[3]

if  a+b+c+d==7:
    print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))
elif a+b+c-d==7:
    print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))
elif a+b-c+d==7:
    print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
elif a+b-c-d==7:
    print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
elif a-b+c+d==7:
    print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))
elif a-b+c-d==7:
    print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))
elif a-b-c+d==7:
    print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))
elif a-b-c-d==7:
    print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))
else:
    pass

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// For integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)
int euclid(int a, int b){
    if(a < b) swap(a, b);
    if(b < 1) return -1;

    if(a % b == 0) return b;
    return euclid(b, a % b);
}

int greatestCommonDivisor(int A, int B){
    int output;
    output = euclid(A, B);
    return output;
}

int main(){
    int A, B;
    int output;
    cin >> A >> B;
    output = greatestCommonDivisor(A, B);
    cout << output << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
int main(){
  int n,gx,gy,m[17][17],mat[17][17][17][17],i,j,k,l,p,m1x,m1y,m2x,m2y,a;
  scanf("%d",&n);
  for(k=0;k<n;k++){ 
    for(i=0;i<17;i++)
      for(j=0;j<17;j++)
	for(l=0;l<17;l++)
	  for(p=0;p<17;p++){
	    m[i][j]=0;
	    mat[i][j][l][p]=0;
	  }
    m[1][1]=1;
    scanf("%d%d",&gx,&gy);
    scanf("%d",&a);
    for(i=0;i<a;i++){
      scanf("%d%d%d%d",&m1x,&m1y,&m2x,&m2y);
      mat[m1x+1][m1y+1][m2x+1][m2y+1]=1;
      mat[m2x+1][m2y+1][m1x+1][m1y+1]=1;
    }   
    for(i=1;i<=gy+1;i++){
      for(j=1;j<=gx+1;j++){
	m[j][i]=m[j-1][i]+m[j][i-1];
	m[1][1]=1;
	if(mat[j][i][j-1][i]==1)m[j][i]-=m[j-1][i];
        if(mat[j][i][j][i-1]==1)m[j][i]-=m[j][i-1];
      }
    }
      if(m[gx+1][gy+1]==0)printf("Miserable Hokusai!\n");
      else printf("%d\n",m[gx+1][gy+1]);
  }   
   return 0;
  }

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

char get_rps(const char &t) {
  char c;
  if (t == 'r') c = 'p';
  else if (t == 's') c = 'r';
  else c = 's';
  return c;
}

char get_f_rps(const char &pc, const char &fc) {
  char c;
  if      (pc == 'r' && fc == 'r') c = 's';
  else if (pc == 'p' && fc == 'r') c = 'r';
  else if (pc == 's' && fc == 'r') c = 'r';
  else if (pc == 'r' && fc == 's') c = 's';
  else if (pc == 'p' && fc == 's') c = 's';
  else if (pc == 's' && fc == 's') c = 'p';
  else if (pc == 'r' && fc == 'p') c = 'p';
  else if (pc == 'p' && fc == 'p') c = 'r';
  else if (pc == 's' && fc == 'p') c = 'p';
  return c;
}

int main() {
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  
  int win_count = 0;
  queue<char> q;
  for (int i=0; i<N; i++) {
    char c;
    if (i+1 <= K) {
      c = get_rps(T[i]);
      q.push(c);
      if (c == 'r') win_count+=R;
      if (c == 'p') win_count+=P;
      if (c == 's') win_count+=S;
    } else {
      char pc = q.front();
      q.pop();
      if (pc == get_rps(T[i])) {
        if (i+K < N) {
          c = get_f_rps(pc, T[i+K]);
          q.push(c);
        }
      } else {
        c = get_rps(T[i]);
        q.push(c);
        if (c == 'r') win_count+=R;
        if (c == 'p') win_count+=P;
        if (c == 's') win_count+=S;
      }
    }
    cerr << c;
  }
  
  cout << win_count << endl;
  return 0;
}

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

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=2e5+19;

int P[N];
int n,tmp,ans;

int main(){
	n=IN();
	For(i,1,n+1) P[IN()]=i;
	For(i,1,n+1){
		if (i==1||P[i]<P[i-1]){
			ans=max(ans,tmp);
			tmp=1;
		} else{
			tmp++;
		}
	}
	ans=max(ans,tmp);
	printf("%d\n",n-ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long f[3001][3001],a[3001];
int main()
{
	int n,i,j;
	scanf("%d",&n);
 	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(n%2==0)
			f[i][i]=-a[i];
		else
			f[i][i]=a[i];
	}	
	for(j=1;j<n;j++)
	{
		for(i=1;i<=n-j;i++)
		{
			if(j%2!=n%2)
				f[i][i+j]=max(a[i]+f[i+1][i+j],f[i][i+j-1]+a[i+j]);
			else
				f[i][i+j]=min(f[i][i+j-1]-a[i+j],f[i+1][i+j]-a[i]);
		}
	}
	printf("%lld",f[1][n]);
	return 0;
}

Measured memory_bytes: 70016
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    long long A,B,K; cin>>A>>B>>K;
    for(int i=1;i<=K;i++){
        if(i%2==1){
            if(A%2==1){
                A=(A-1)/2; B=B+A;
            }else{
                A=A/2; B=B+A;
            }
        }else{
            if(B%2==1){
                B=(B-1)/2; A=A+B;
            }else{
                B=B/2; A=A+B;
            }
        }
    }
    cout<<A<<" "<<B<<endl;
    
}


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

int main(){
    int n;
    cin>>n;
    vector<int> A(n),B(n),P(n);
    for(int i=0; i<n; ++i) cin>>A[i];
    for(int i=0; i<n; ++i) cin>>B[i];
    for(int i=0; i<n; ++i) P[i]=i+1;
    int i=1,a=0,b=0;
    do{
        if(P==A) a=i;
        if(P==B) b=i;
        if(a & b) break;
        ++i;
    }while(next_permutation(P.begin(),P.end()));

    cout<<abs(a-b)<<"\n";
}

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

using namespace std;

int main()
{
    string s;
    int i=0;
    cin>>s;
    while(s[++i]!='\0'){

        if(s[i]==s[i-1]){

            cout<<"Bad"<<endl;
            return 0;

        }
    }
    cout<<"Good"<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
//const ll p = 1e9 + 7;
//const ll p = 998244353;
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	string s, t = "CODEFESTIVAL2016";
	cin >> s;
	ll ans = 0;
	for (ll i = 0; i < 16; i++) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;
}


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

int main() {
  double a[3] = {0.2, 0.6, 1.1};
  int c[2][4];
  double l, r;

  for (int i=0; i<4; i++) {
    c[0][i] = c[1][i] = 0;
  }
  while (cin >> l >> r) {
    ++c[0][distance(a, upper_bound(a, a+3, l))];
    ++c[1][distance(a, upper_bound(a, a+3, r))];
  }
  for (int i=3; i>=0; i--) {
    cout << c[0][i] << " " << c[1][i] << endl;
  }
  return 0;
}

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

int main(){
  int P, Q, R, result=INT_MAX;

  cin >> P >> Q >> R;

  if(P+Q<result){
    result = P+Q;
  }
  if(Q+R<result){
    result = Q+R;
  }
  if(R+P<result){
    result = R+P;
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

#include <boost/multiprecision/integer.hpp>
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
template <typename T>
map<T, int> count_prime(T N){
    map<T, int> num; // N の素因数の個数
    T n = N;
    for(T j = 2; j * j <= N; ++j)
        while (n % j == 0) {
            ++num[j];
            n /= j;
        }

    if (n != 1) ++num[n];
    return num;
}

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

int N; cin >> N;
VI A(N); invec(A);

i64 maxA = *max_element(ALL(A));
VI cntp(maxA+1, 0);
for(i64 a: A){
    map<i64, int> cnta = count_prime(a);
    for (pair<i64, int> p: cnta)
        cntp[p.first] = max(cntp[p.first], (i64)p.second);
}

i64 L = 1;
rep(i, 2, maxA+1) if (cntp[i] > 0)
    (L *= boost::multiprecision::powm(i, cntp[i], MOD)) %= MOD;

i64 ans = 0;
for(i64 a: A) 
    (ans += L * modinv(a, MOD) %MOD) %= MOD;

cout << ans % MOD << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 8192
N=int(input())
S=input()
l,u=0,N
while l+1<u:
    m=(l+u)//2
    s=set()
    for i in range(N-m*2+1):
        s.add(S[i:i+m])
        if S[i+m:i+m*2] in s:
            l=m
            break
    if l!=m:
        u=m
print(l)

Measured memory_bytes: 6388
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

	n, d := nextInt(), nextInt()

	a := d*2 + 1
	ans := 0

	if n%a == 0 {
		ans += n / a
	} else {
		ans += n/a + 1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  long long arr[n];for(int i=0;i<n;i++)cin>>arr[i];
  long long ans=0;for(int i=1;i<n;i++){
    if(arr[i-1]>arr[i]){ans+=arr[i-1]-arr[i];arr[i]=arr[i-1];}}
  cout<<ans;
  return 0;
}

Measured memory_bytes: 5160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(void)
{   
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1) {
        c -= b;
        if(c <= 0) {
            puts("Yes");
            break;
        }
        a -= d;
        if(a <= 0) {
            puts("No");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3616
/*
 * atcoder/abc137/e.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <tuple>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


/*
 * 1. 0から到達不可能な頂点を削除
 * 2. N-1へ到達不可能な頂点を削除
 * 3. 削除後のグラフに対してベルマンフォード
 * 4. 
 */
const int MAX = 2500;
const int INF = 1010101010;
int n, m, p;
int G[MAX][MAX];
bool from1[MAX] = {0};
bool toN[MAX] = {0};
void dfs1(int v) {
  if (from1[v]) return;
  from1[v] = true;
  int a, b, c;
  for (int i=0; i<n; i++) {
    if (G[v][i] == INF) continue;
    dfs1(i);
  }
}
void dfsN(int v) {
  if (toN[v]) return;
  toN[v] = true;
  int a, b, c;
  for (int i=0; i<n; i++) {
    if (G[i][v] == INF) continue;
    dfsN(i);
  }
}

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

void solve() {
  int a, b, c;
  cin >> n >> m >> p;
  loop(i,0,MAX) loop(j,0,MAX) G[i][j] = INF;
  loop(i,0,m) {
    cin >> a >> b >> c;
    chmin(G[--a][--b], -(c-p));
  }
  dfs1(0);
  dfsN(n-1);

  vector<tuple<int,int,int>> E;
  loop(i,0,n) loop(j,0,n) {
    if (from1[i] and toN[j] and from1[j] and toN[i]) {
      if (G[i][j] == INF) continue;
      E.emplace_back(i, j, G[i][j]);
    }
  }
  // for (auto&&e: E) {
  //   tie(a, b, c) = e;
  //   cout << a << " " << b << " " << c << endl;
  // }

  // bellman-ford
  vector<int> D(n, INF);
  D[0] = 0;
  loop(count,0,n) {
    for (auto&&e: E) {
      tie(a, b, c) = e;
      if (D[a] == INF) continue;
      if (chmin(D[b], D[a] + c) and count == n-1) {
        cout << -1 << endl;
        return;
      }
    }
  }

  cout << max(0, D[n-1] * -1) << endl;
}


Measured memory_bytes: 24832
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

ll a, b;
int ans;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> a >> b;
    ll g = __gcd(a, b);
    for(ll i=2; i*i<=g; i++)
    {
        if(g%i == 0)
        {
            ans++;
            while(g%i == 0) g/=i;
        }
    }
    if(g>1) ans++;
    cout << ans+1 << endl;
}


Measured memory_bytes: 256
def main
  islands_num, req_num = ARGF.gets.split.map(&:to_i)

  # ソートしない解法 ※islands_num分のArrayを最初から用意しておくだけ
  # ※ソートする解法と比べて 229ms -> 192ms と速くなったが、12664kb->15740kb とメモリー使用量は増えた
  requests = Array.new(islands_num)
  req_num.times do
    a, b = ARGF.gets.split.map(&:to_i)
    # 配列indexは0始まりである点に注意
    if requests[b-1].nil?
      requests[b-1] = [a]
    else
      requests[b-1] << a
    end
  end

  # 切断した場所 例）1の場合、1-2 の間を切断したという意味
  last = 0

  # 配列のindexを b に変換するために with_index(1) により1始まりにしている
  # ※それが必要ない場合には each_with_index のほうがいいかも。
  cnt = requests.each.with_index(1).inject(0) do |cnt, (as, i)|
    if !as.nil?
      as.each do |a|
        if last < a
          last = i - 1
          cnt += 1
        end
      end
    end
    cnt
  end

  puts cnt
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 9852
N = int(input())


def solve(num):
    ret = set()

    p = 1
    while p * p <= num:
        if num % p == 0:
            ret.add(p)
            ret.add(num // p)
        p += 1

    return ret


s1 = solve(N)
s2 = solve(N-1)



# 1は答えに入らないので抜いた
ans = len(s2) - 1
for n in s1:
    if n == 1:
        continue
    tmp = N
    while tmp % n == 0:
        tmp = tmp // n
    if tmp % n == 1:
        ans += 1


print(ans)

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

using namespace std;
typedef long long ll;

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

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

int main()
{
    int N;
    cin >> N;
    int ans = 0, cnt;
    for (int i = 1; i < N + 1; i += 2)
    {
        cnt = 0;
        for (int j = 1; j < N + 1; j += 2)
        {
            if (i < j)
                break;
            if (i % j == 0)
            {
                cnt++;
            }
        }
        if (cnt == 8)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){

  string a,b;

  cin >> a >> b;

  string str_num = a + b;
  
  int num = stoi(str_num);

  for(int i = 1; i <= 317; i++){
	if(i*i < num){
	  continue;
	}
	else if(i*i == num){
	  cout << "Yes" << "\n";
	  return 0;
	}
	else{
	  cout << "No" << "\n";
	  return 0;
	}
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,w;
cin>>n>>w;
pair<int,int> arr[n];
for(int i=0;i<n;i++)
{
    cin>>arr[i].ff>>arr[i].ss;
}
int inf=pow(10,17);
int mx=pow(10,5)+5;
int prev[mx]={};
int dp[mx]={};
for(int i=1;i<mx;i++)
{
    prev[i]=inf;
}

prev[arr[0].ss]=arr[0].ff;
for(int i=1;i<n;i++)
{
    for(int j=1;j<mx;j++)
    {if(j>=arr[i].ss)
        {
            dp[j]=min(prev[j-arr[i].ss]+arr[i].ff,prev[j]);
        }
        else
        {
            dp[j]=prev[j];
        }
    }
    for(int j=1;j<mx;j++)
    {
        prev[j]=dp[j];
        dp[j]=inf;
    }
}
int ans=0;
for(int i=0;i<mx;i++)
{
    if(prev[i]<=w)
    {
        ans=i;
    }
}
cout<<ans<<endl;













    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


struct RangeTree{
    // xの各値がyのソート済み配列を持つ
    vector<vector<int>>seg;
    vector<int>x;
    int sz;
    RangeTree(vector<pair<int,int>> a){
        sz=1;
        while((int)a.size()>sz)sz<<=1;
        sort(begin(a),end(a));
        if(a.size())x.push_back(a[0].first);
        for(auto &p:a)if(x.back()!=p.first)x.push_back(p.first);
        while(x.size()<sz)x.push_back(INF);
        seg.resize(2*sz);
        int pos=0;
        for(auto &p:a){
            if(x[pos]!=p.first)pos++;
            seg[pos+sz].push_back(p.second);
        }
        for(int i=sz-1;i>0;i--){
            seg[i].resize(seg[2*i].size()+seg[2*i+1].size());
            merge(begin(seg[2*i]),end(seg[2*i]),begin(seg[2*i+1]),end(seg[2*i+1]),begin(seg[i]));
        }
    }
    // [x1,x2),[y1,y2)
    int count(int x1,int y1,int x2,int y2){
        int l=lower_bound(begin(x),end(x),x1)-begin(x),r=lower_bound(begin(x),end(x),x2)-begin(x);
        l+=sz,r+=sz;
        int ret=0;
        for(;l<r;l>>=1,r>>=1){
            if(l&1){
                ret+=lower_bound(begin(seg[l]),end(seg[l]),y2)-lower_bound(begin(seg[l]),end(seg[l]),y1);
                l++;
            }
            if(r&1){
                r--;
                ret+=lower_bound(begin(seg[r]),end(seg[r]),y2)-lower_bound(begin(seg[r]),end(seg[r]),y1);
            }
        }
        return ret;
    }
};

int c[500010];
map<int,int> pre;

signed main(){

    int n,q;cin>>n>>q;
    rep(i,n) cin>>c[i];

    vector<pair<int,int>> d;
    rep(i,n){
        if(pre.count(c[i])) d.push_back({i,pre[c[i]]});
       pre[c[i]]=i;
    }

    RangeTree seg(d);

    while(q--){
        int l,r;cin>>l>>r;l--;

        int ans=r-l-seg.count(l,l,r,r);
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 101892
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var dg = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();

            var a = dg[0];
            var b = dg[1];

            Console.WriteLine((a * b) % 2 == 0 ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 13396
s = input()
if s[0] == "M":
  print(6)
elif s[:2] == "TU":
  print(5)
elif s[0] == "W":
  print(4)
elif s[0] == "T":
  print(3)
elif s[0] == "F":
  print(2)
elif s[:2] == "SA":
  print(1)
else:
  print(7)

Measured memory_bytes: 3060
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    COUT(((N * (N - 1)) / 2) + ((M * (M - 1)) / 2));
}


Measured memory_bytes: 256
// C - いっしょ / Be Together https://atcoder.jp/contests/abc043/tasks/arc059_a

  import io.Source

  object Main extends App {
    val xs = Source.stdin.getLines()
    val n = xs.next().toInt
    val ns = xs.next().split(' ').map(_.toInt)

    println(solve(ns))

    def solve(ns: Seq[Int]): String = {
      // 総当り
      var ans = Int.MaxValue
      (-100 to 100).foreach { n =>
        val a = cost(n, ns)
        ans = Math.min(a, ans)
      }
      ans.toString
    }

    def cost(n: Int, ns: Seq[Int]): Int = {
      ns.map(m => Math.pow(m - n, 2).toInt).sum
    }
  }


Measured memory_bytes: 26028
#include <iostream>
#include <climits>
#include <cstdio>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define PI 3.14159265
#define LOOP(val, times)   for(val = 0; val < (times); val++)
int main(){
  double a,b,x;
  cin>>a>>b>>x;
  double ans=0.0;
  cout << fixed << setprecision(9);
  if(x<a*a*b/2){
    double c=2*x/b/a;
    double g=c/sqrt(b*b+c*c);
    double r=asin(g);
    ans=180.0*r/PI;
    cout<<90.0-ans<<endl;
  }
  else{
    double c=2*b-2*x/a/a;
    double g=c/sqrt(c*c+a*a);

    double r=asin(g);
    
    ans=180.0*r/PI;
   cout<<ans<<endl;
  }
}


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

#define MAX 1000005
#define INF 200000000
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long llu;

using namespace std;

int dx[]={0,0,-1,+1,-1,+1};
int dy[]={-1,+1,0,0,-1,+1};

void IO()
{
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
}

bool flag;
int n,q,m;
int arr[25];

void Fun(int i, int sum)
{
    if(sum==m){
        flag=true;
        return;
    }
    if(i>=n)return;
    if(sum+arr[i]<=m&&!flag)Fun(i+1,sum+arr[i]);
    if(!flag)Fun(i+1,sum);
}

int main()
{
    //IO();
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&arr[i]);
    scanf("%d",&q);
    for(int i=1;i<=q;i++){
        scanf("%d",&m);
        flag=false;
        Fun(0,0);
        if(flag)printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace _gnu_pbds;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i = a ; i < b ; i++)
#define stoink stack<ll>
#define quu queue<ll>
#define quee queue<pair<ll,ll>>
#define vec vector <ll>
#define vecd vector<ld>
#define vg vector<vector<ll> >
#define eg vector<pair<ll,ll>>
#define vgw vector<vector<pair<ll,ll> > >
#define pa pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 100000000
#define mod (ll)(1e9+7)
#define endl '\n'
ll n,k;
ll arr[55][55];
void print(ll mat[55][55]) {
    fr(i,0,n) {
        fr(j,0,n) cout << mat[i][j] << " ";
        cout << endl;
    }
}
void mul(ll mat1[55][55],ll mat2[55][55]) {
    ll ans[55][55];
    memset(ans,0,sizeof(ans));
    fr(i,0,n) fr(j,0,n) fr(k,0,n) ans[i][j] = (ans[i][j] + (mat1[i][k] * mat2[k][j]) % mod) % mod;
    fr(i,0,n) fr(j,0,n) mat1[i][j] = ans[i][j];
}
ll matexp(ll exp) {
    ll answer[55][55];
    memset(answer,0,sizeof(answer));
    fr(i,0,n) fr(j,0,n) if(i == j) answer[i][j] = 1;
    while(exp > 0) {
        if(exp & 1)
            mul(answer,arr);
        mul(arr,arr);
        exp >>= 1;
    }
    ll res = 0;
    fr(i,0,n) fr(j,0,n) res =(res + answer[i][j]) % mod;
    return res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> k;
    fr(i,0,n) fr(j,0,n) cin >> arr[i][j];
    cout << matexp(k);
    return 0;
}	

Measured memory_bytes: 3688
#include<stdio.h>
int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b ,&c);
    if((a == 5 || a == 7|| b == 5 || b == 7|| c == 5 || c == 7) && (a+b+c == 17\
)){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
a,b,c,x,y=gets.split.map(&:to_i)
ans=1e10
([x,y].max+1).times{|i|
  t=i*2*c
  t+=(x-i)*a if i<x
  t+=(y-i)*b if i<y
  ans=[t,ans].min
}
puts ans

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

struct Node
{
    int beginx;
    int area;
};
int main()
{
    stack<int> s1;
    stack<Node> s2;
    string s;
    int sum = 0;
    cin >> s;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='\\')
        {
            s1.push(i);
        }
        else if(s[i]=='/' && !s1.empty())
        {
            int j = s1.top(); s1.pop();
            sum += i-j;
            int a = i-j;
            while(s2.size()>0 && s2.top().beginx>j)
            {
                a += s2.top().area; s2.pop();
            }
            Node n;
            n.beginx = j;
            n.area = a;
            s2.push(n);
        }
    }
    cout << sum << endl;
    cout << s2.size();
    vector<int> s3;
    while(!s2.empty())
    {
        s3.push_back(s2.top().area); s2.pop();
    }
    reverse(s3.begin(), s3.end());
    for(vector<int>::iterator it=s3.begin(); it!=s3.end(); it++)
    {
        cout << " " << *it;
    }
    cout << endl;
    s3.clear();
    return 0;
}



Measured memory_bytes: 3328
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N;
void dfs(string s,char mc){
    if(s.length()==N){
        printf("%s\n",s.c_str());
    }else{
        for(char c='a';c<=mc;c++){
            if(c!=mc){
                dfs(s+c,mc);
            }else{
                dfs(s+c,(char)(mc+1));
            }
        }
    }

};
signed main(){
    scanf("%lld",&N);
    dfs("",'a');
    return 0;
}


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

using ll = long long;
#define REPR(i, n) for( int i = n; i >= 0; --i )
#define REP(i, n) for( int i = 0; i < (int)(n); ++i )
#define FOR(i, m, n) for( int i = m; i < (int)(n); ++i )
#define ALL(v) v.begin(), v.end()


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> k(M), p(M);
    vector<vector<int>> s(M);
    REP(i, M){
        cin >> k[i];
        REP(j, k[i]){
            int si;
            cin >> si;
            s[i].push_back(si);
        }
    }
    REP(i, M) cin >> p[i];


    int ans = 0;
    // スイッチの on, off について全探索
    REP(i, 1<<N){
        bool is_consistent = true;
        // 各クエリをチェック
        REP(j, M){
            int num_on_switches = 0;
            REP(l, k[j]){
                if(i & 1<<(s[j][l]-1)) ++num_on_switches;
            }
            if( num_on_switches%2 != p[j] ){
                is_consistent = false;
                break;
            }
        }
        if( is_consistent ) ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long h,w,n,cnt=0,x=0;
  cin >> h >> w >> n;
  long long a[n];
  string ans="",tmp;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    int ii=i+1;
    for(int j=0;j<a[i];j++){
      if(x%2==0){
        cout << i+1;
        cnt++;
        if(cnt<2*w-1){
          cout << ' ';
          cnt++;
        }else{
          cout << endl;
          x++;
          cnt=0;
        }
      }else if(x%2==1){
        stringstream ss;
        ss << ii;
        tmp=ss.str();
        if(ans!=""){
          ans.insert(0," ");
          cnt++;          
        }
        ans.insert(0,tmp);        
        cnt++;
        if(cnt==2*w-1){
          cout << ans << endl;
          ans="";
          cnt=0;
          x++;
        }
      }
    }
  }
  return 0;
}


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

using namespace std;

struct Edge {
  int u, v;
  int cap, flow;
  Edge() {}
  Edge(int u, int v, int cap): u(u), v(v), cap(cap), flow(0) {}
};

struct Dinic {
  int N;
  vector<Edge> E;
  vector<vector<int>> g;
  vector<int> d, pt;
  
  Dinic(int N): N(N), E(0), g(N), d(N), pt(N) {}

  void AddEdge(int u, int v, int cap) {
    if (u != v) {
      E.emplace_back(Edge(u, v, cap));
      g[u].emplace_back(E.size() - 1);
      E.emplace_back(Edge(v, u, 0));
      g[v].emplace_back(E.size() - 1);
    }
  }

  bool BFS(int S, int T) {
    queue<int> q({S});
    fill(d.begin(), d.end(), N + 1);
    d[S] = 0;
    while(!q.empty()) {
      int u = q.front(); q.pop();
      if (u == T) break;
      for (int k: g[u]) {
        Edge &e = E[k];
        if (e.flow < e.cap && d[e.v] > d[e.u] + 1) {
          d[e.v] = d[e.u] + 1;
          q.emplace(e.v);
        }
      }
    }
    return d[T] != N + 1;
  }

  int DFS(int u, int T, int flow = -1) {
    if (u == T || flow == 0) return flow;
    for (int &i = pt[u]; i < g[u].size(); ++i) {
      Edge &e = E[g[u][i]];
      Edge &oe = E[g[u][i]^1];
      if (d[e.v] == d[e.u] + 1) {
        int amt = e.cap - e.flow;
        if (flow != -1 && amt > flow) amt = flow;
        if (int pushed = DFS(e.v, T, amt)) {
          e.flow += pushed;
          oe.flow -= pushed;
          return pushed;
        }
      }
    }
    return 0;
  }

  int MaxFlow(int S, int T) {
    int total = 0;
    while (BFS(S, T)) {
      fill(pt.begin(), pt.end(), 0);
      while (int flow = DFS(S, T))
        total += flow;
    }
    return total;
  }
};

const int MAXN = 105;

char g[MAXN][MAXN];
int n, m;

int get(int x, int y){
	return (x - 1) * m + y;
}

int in(int x, int y){
	return 2 * (get(x, y) - 1);
}

int out(int x, int y){
	return 2 * get(x, y) - 1;
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++i) scanf("%s", g[i] + 1);
	Dinic dinic(n*m*2);
	int sx, sy, tx, ty;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			if(g[i][j] == '.') continue;
			if(g[i][j] == 'S') sx = i, sy = j;
			if(g[i][j] == 'T') tx = i, ty = j;
			for(int k = 1; k <= n; ++k){
				if(k != i){ 
					dinic.AddEdge(out(i, j), in(k, j), 1);
				}
			}
			for(int k = 1; k <= m; ++k){
				if(k != j){ 
					dinic.AddEdge(out(i, j), in(i, k), 1);
				}
			}
		}
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			if(g[i][j] != 'o') continue;
			dinic.AddEdge(in(i, j), out(i, j), 1);
		}
	}
	if(sx == tx || sy == ty) printf("-1\n");
	else printf("%d\n", dinic.MaxFlow(out(sx, sy), in(tx, ty)));
  	return 0;
}


Measured memory_bytes: 85444
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;

    ll prev2 = 2, prev = 1, L; // 2つ前の値を持たせる
    for (int i = 2; i <= N; i++) {
        L = prev2 + prev;
        prev2 = prev;
        prev = L;
    }

    if (N == 1) {
        cout << 1 << endl;
    } else {
        cout << L << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    bool y = false;
    for (int i = 0; i < n; i++) {
        char s;
        cin >> s;
        if (s == 'Y') {
            y = true;
        }
    }

    cout << (y ? "Four" : "Three") << endl;

    return 0;
}

Measured memory_bytes: 384
N,M,Q = map(int, input().split())
train = [[0 for j1 in range(N)] for i1 in range(N)]
st = [[0 for j2 in range(N+1)] for i2 in range(N)]
s = [[0 for j3 in range(N+1)] for i3 in range(N)]

for i in range(M):
    l, r = map(int, input().split())
    train[l-1][r-1] += 1
for i in range(N):
    for j in range(N):
        st[i][j+1] = st[i][j] + train[i][j]
        
for i in range(N+1):
    s[N-1][i] = st[N-1][i]
for i in range(N-2, -1, -1):
    for j in range(N+1):
        s[i][j] = s[i+1][j] + st[i][j]
 
 
for i in range(Q):
    p, q = map(int, input().split())
    print(s[p-1][q])

Measured memory_bytes: 17496
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N,Q;
string s;

vector<char> t, d;

bool lf(int k) {
  int now = k;
  for(int i = 0;i < Q;i++) {
    if(s[now] == t[i]) {
      if(d[i] == 'L') now--;
      else now++;
    }
    if(now < 0) return true;
  }
  return false;
}

bool rf(int k) {
  int now = k;
  for(int i = 0;i < Q;i++) {
    if(s[now] == t[i]) {
      if(d[i] == 'L') now--;
      else now++;
    }
    if(now >= N) return true;
  }
  return false;
}

int main() {
  cin >> N >> Q >> s;
  t.resize(Q);
  d.resize(Q);
  for(int i = 0;i < Q;i++) cin >> t[i] >> d[i];
  int l,r;

  {
    int ok = -1;
    int ng = N;
    while(ng - ok > 1) {
      int mid = (ok + ng) / 2;
      if(lf(mid)) ok = mid;
      else ng = mid;
    }
    l = ok;
  }

  {
    int ok = N;
    int ng = -1;
    while(ok - ng > 1) {
      int mid = (ok + ng) / 2;
      if(rf(mid)) ok = mid;
      else ng = mid;
    }
    r = ok;
  }
  cout << N - ((N - r) + (l + 1)) << endl;

}


Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N;
  cin >> N;

  vector<int> x(N);
  vector<int> y(N);
  vector<int> h(N);
  REP(i, N) cin >> x[i] >> y[i] >> h[i];

  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      int tmp = 0;
      while(h[tmp] == 0) tmp++;

      int H = h[tmp] + abs(cx - x[tmp]) + abs(cy - y[tmp]);
      bool flag = true;
      for (int i = 0; i < N; i++) {
        if (max(H - abs(cx - x[i]) - abs(cy - y[i]), 0) != h[i]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        cout << cx << ' ' << cy << ' ' << H << endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef pair<int,int> P;

int main() {
    long long int i,j,n,p,q;
    long long int temp=0;
    long long int a,b;
    long long int ans=0;
    int t=0;
    long long int flag=0;
    int cx,cy,h;
    long long int kakerukazu;
    string s;
    cin>>a>>b;
    flag=b-a;
    long long int temp2;

    for(i=a; i<=b; ++i){
        if(i!=0&&i!=b&&i%4==0){
            temp=i;
            break;
        }
        ans=ans^i;

    }
    temp2=b-temp;
    kakerukazu=temp2/4;

    if(temp!=0) {
        for (i = temp+ (4 * kakerukazu); i <= b; ++i) {

            ans = ans ^ i;
        }
    }
    if(flag==0){
        cout<<b;
    }
    else{
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rItr(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define Itr(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define setp(n) fixed << setprecision(n)
#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define All(a) (a.begin()),(a.end())
#define rAll(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c; cin>>a>>b>>c;
	cout<<a*b/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n, t, a, *h = map(int, open(0).read().split())
mni = 0
mn = 1e18
for i in range(n):
	if mn>=abs(t-h[i]*0.006 - a):
		mn = abs(t-h[i]*0.006 - a)
		mni = i
print(mni+1)


Measured memory_bytes: 3060
n, m, q = map(int, input().split())
lr = []
for i in range(m):
    l, r = map(int, input().split())
    lr.append((l, r))

mtx = [[0 for i in range(n)] for j in range(n)]

for item in lr:
    mtx[item[0]-1][item[1]-1] += 1

rui = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(n):
    for j in range(n):
        rui[i+1][j+1] = rui[i][j+1] + rui[i+1][j] - rui[i][j] + mtx[i][j]

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


Measured memory_bytes: 78296
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}
int main(void){
  ll n,m;
  cin >> n >> m;
  Union tree(n);
  ll a[m],b[m],c[n],d[n];
  rep(i,m){
    cin >> a[i] >> b[i];
    tree.unite(a[i]-1, b[i]-1);
  }
  rep(i,n){
    c[i]=tree.find(i);
    d[i]=0;
  }
  rep(i,n){
    d[c[i]]++;
  }
  ll ans=0;
  rep(i,n){
    if(ans<d[i])ans=d[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 11172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    int ans = 0;
    rep(i, N) {
        for (int j = i + 1; j < N; j++) {
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main() {
    int n;
    long z,w;
    cin >> n >> z >> w;
    vector<long> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    if(n == 1){
        printf("%ld", abs(w-a[n-1]));
    }else{
        printf("%ld", max(abs(w - a[n-1]), abs(a[n-2] - a[n-1])));
    }
}


Measured memory_bytes: 256
s = input()

count =[0]
counter = 0
for i in range(len(s)):
  if s[i] == "A" or s[i] =="C" or s[i] == "T" or s[i] == "G":
    count[counter] += 1
  else:
    count.append(0)
    counter += 1
print(max(count))

    

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

int br[13];
int main()
{
    int i,ans,flag = 0;
    char ar[13];
    cin>>ar;
    for(i=0;i<4;i++)
    {
        ans = ar[i] - 65;
        if(br[ans]!=1)
        {
            br[ans] = 1;
            flag++;
        }
    }
    if(flag==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

struct UnionFindTree {
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFindTree {
    fn new(n: usize) -> Self {
        let parent = (0..n).collect();
        let size = vec![1; n];
        Self { parent, size }
    }

    fn find(&mut self, x: usize) -> usize {
        if self.parent[x] == x {
            x
        } else {
            self.parent[x] = self.find(self.parent[x]);
            self.size[x] = 1;
            self.parent[x]
        }
    }

    fn unite(&mut self, x: usize, y: usize) {
        let mut x = self.find(x);
        let mut y = self.find(y);
        if x == y {
            return;
        }

        if self.size[x] < self.size[y] {
            std::mem::swap(&mut x, &mut y);
        }

        self.parent[y] = x;
        self.size[x] += self.size[y];
    }
}
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        M: usize,
        AB: [(Usize1, Usize1); M]
    }

    let mut uf = UnionFindTree::new(N);

    for &(a, b) in AB.iter() {
        uf.unite(a, b);
    }

    println!("{:?}", uf.size.iter().max().unwrap());
}


Measured memory_bytes: 10848
x1, y1, x2, y2 = map(int, input().split())

vector = (x2-x1, y2-y1)

x3 = x2 - vector[1]
y3 = y2 + vector[0]
x4 = x3 - vector[0]
y4 = y3 - vector[1]

print(x3, y3, x4, y4)

Measured memory_bytes: 61788
#include<stdio.h>
int main(){
    int N,A,B;
    scanf("%d",&N);
    scanf("%d",&A);
    scanf("%d",&B);
    
    if(N == 1){
        printf("Hello World\n");
    }else{
        printf("%d\n",A+B);
    }
    return 0;
}


Measured memory_bytes: 128