akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int count = 0;
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    bool res = true;
    for (int j = 2; j * j <= a; j++){
      if (a % j == 0){
        res = false;
        break;
      }
    }
    if (res){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    for(int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }
    double sum = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            sum += std::sqrt(std::pow(X[j]-X[i], 2) + std::pow(Y[j]-Y[i], 2));
        }
    }
    double ans = sum * 2 / N;
    printf("%.10f\n", ans);
    
    return 0;
}


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

using namespace std;

int main()
{

    int h, a;

    cin >> h >> a;

    int n[a+2];

     int ans = 0;

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

    }

    if(ans < h)
       cout << "No" << endl;
    else
         cout << "Yes" << endl;

    return 0;
}


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

ll A[300][300];
const ll INF = 1LL << 50;
ll wf[300][300];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;

	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> A[i][j];
			wf[i][j] = A[i][j];
		}
	}

	for(int k = 0; k < N; k++)
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);

	ll ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			if(A[i][j] != wf[i][j]){
				cout << -1 << endl;
				return 0;
			}
			bool found = false;
			for(int k = 0; k < N; k++){
				if(i == k || j == k) continue;
				if(wf[i][k] + wf[k][j] == A[i][j]){
					found = true;
					break;
				}
			}
			if(!found) ans += A[i][j];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    string s;
    string ans;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')  ans.push_back('1');
        else if(s[i]=='0') ans.push_back('0');
        else if(!ans.empty()) ans.pop_back();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main(){
    multimap<ll,pll> sev;
    set<ll> xev;
    ll n, q;
    cin >> n >> q;
    ll s, t, x;
    REP(i, n)
    {
        cin >> s >> t >> x;
        sev.insert(make_pair(s - x, make_pair(1, x)));
        sev.insert(make_pair(t - x, make_pair(-1, x)));
    }
    ll d[q+2];
    ll dist[q + 2];
    REP(i, q) dist[i]=-1;
    REP(i, q) cin >> d[i];
    REP(i,q){
        for (auto ite = sev.begin(); ite != sev.end();ite++)
        {
            //cout << "EVENT: " << ite->FI << "dist:" << d[i] << endl;
            if (d[i] < ite->FI){
                if (xev.size()){
                    dist[i] = *xev.begin();
                }
                break;
            }
            if (ite->SE.FI == 1)
            {
                xev.insert(ite->SE.SE);
                sev.erase(ite);
            }
            else
            {
                xev.erase(ite->SE.SE);
                sev.erase(ite);
            }
        }
    }
    REP(i,q) cout << dist[i] << endl;
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define F first
#define S second
#define inf LLONG_MAX
#define mod 1000000007
#define PI 3.1415926536
#define vll vector <ll>
#define pll pair <ll,ll>
#define dbg(n) cout<<n<<' '
#define cu continue
#define br break
#define N 1005
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 

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

    ll n;
    cin>>n;
    set <string> st,tmp;
    string s="a",t1="",t2="";
    char c='b';
    bool fl=0;
    st.insert(s);
    for(ll i=0;i<n-1;i++)
    {
    	c='b';
    	for(auto y:st)
    	{
    		t1="a"+y;
    		t2=y+"a";
    		tmp.insert(t1);
    		tmp.insert(t2);
    	}
    	for(ll k=1;k<26;k++)
    	{
    		for(auto y:st)
    	    {
	    		fl=0;
	    		for(ll j=0;j<y.length();j++)
	    		{
	    			if(y[j]==(c-1))
	    				fl=1;
	    		}
	    		if(fl)
	    		{
	    			t1=y+c;
	    			tmp.insert(t1);
	    		}
    	    }
    	    c++;
    	}
    	st.clear();
    	for(auto z:tmp)
    		st.insert(z);
    	tmp.clear();
    }
    for(auto x:st)
    	cout<<x<<'\n';
}

Measured memory_bytes: 19328
s = input()
ans = 1
l = s[0]
cnt = 0
l_cnt = 0
for char in s[1:]:
    if (char == l and cnt == 0 and l_cnt== 0):
        cnt += 1
        continue
    else:
        l_cnt = cnt
        cnt = 0
        l = char
        ans += 1
print(ans)


Measured memory_bytes: 42332
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  long long sum = 0;
  vector<P>data(n);
  for(int i = 0;i< n;i++) cin >> data[i].first >> data[i].second;
  for(int i = n-1;i >= 0;i--){
    int mod = (sum+data[i].first)%data[i].second;
    if(mod == 0) continue;
    sum += data[i].second-mod;
  }
  cout << sum << endl;
}


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

int main() {
  int N,K,A = 0;
  cin >> N >> K;
  
  for(int i = 0 ; i < N ; i++) {
    int x;
    cin >> x;
    if(x <= K / 2)
      A += 2 * x;
    else if(x > K)
      A += 2 * (x - K);
    else
      A += 2 * (K - x);
  }
  cout << A << endl;
}


Measured memory_bytes: 256
// ABC072B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int N;
	N = s.size();
	for(int i=0;i<N;i++)
	{
		if((i%2)==0)//0からだからずれてる
		{
			cout << s[i];
		}
	
	}

   
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1e+7
#define int long long
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
signed main() {
	 garou;
	 string s;
	 cin>>s;
	 if(s=="ABC"){
		 cout<<"ARC";
	 }
	 else
	 {
		 cout<<"ABC";
	 }
	 
}

Measured memory_bytes: 3612
# coding: utf-8
# Your code here!
import sys
import math
from itertools import chain

def input():
    return sys.stdin.readline().rstrip()

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

Q = int(input())
a = [list(map(int, input().split())) for _ in range(Q)]
s = []
min_num = min(list(chain.from_iterable(a)))
max_num = max(list(chain.from_iterable(a)))
ctr = 0

for j in range(min_num, max_num + 1, 2):
    if is_prime(j) and is_prime((j + 1) // 2):
        s.append(j)

for i in range(Q):
    for k in s:
        if k >= a[i][0] and k <= a[i][1]:
            ctr += 1
    print(ctr)
    ctr = 0

Measured memory_bytes: 75020
import re
M=0
L=[]

try:
    while True:
        A=str(input())
        L.append(re.findall('[0-9]+', A))
        
except EOFError:
    pass

B=len(L)
for i in range(B):
    C=len(L[i])
    D=L[i]
    for j in range(C):
        M+=int(D[j])
print(M)


Measured memory_bytes: 6540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0048
{
    class Program
    {
        static void Main(string[] args)
        {
            Class @class = new Class();
            double n = 0;
            while(double.TryParse(Console.ReadLine(),out n))
            {
                Console.WriteLine(@class.BoxerClass(n));
            }
        }
    }
    class Class
    {
        public string BoxerClass(double x)
        {
            if (x <= 48.00)
            {
                return "light fly";
            }
            else if (x > 48.00 && x <= 51.00)
            {
                return "fly";
            }
            else if (x > 51.00 && x <= 54.00)
            {
                return "bantam";
            }
            else if (x > 54.00 && x <= 57.00)
            {
                return "feather";
            }
            else if (x > 57.00 && x <= 60.00)
            {
                return "light";
            }
            else if (x > 60.00 && x <= 64.00)
            {
                return "light welter";
            }
            else if (x > 64.00 && x <= 69.00)
            {
                return "welter";
            }
            else if (x > 69.00 && x <= 75.00)
            {
                return "light middle";
            }
            else if (x > 75.00 && x <= 81.00)
            {
                return "middle";
            }
            else if (x > 81.00 && x <= 91.00)
            {
                return "light heavy";
            }
            else 
            {
                return "heavy";
            }
        }
    }
}


Measured memory_bytes: 13860
N=int(input())
digit=len(str(N))
first=int(str(N)[0])
last=N%10
mid=(N-first*10**(digit-1)-last)//10
table=[[0 for i in range(0,10)]for j in range(0,10)]

if digit==1:
    print(N)
else:
    for i in range(1,10):
        for j in range(1,10):
            if i!=j:
                table[i][j]=(10**(digit-1)-10)//90
            else:
                table[i][j]=(10**(digit-1)-10)//90+1
    for i in range(1,10):
        for j in range(1,10):
            if i<first:
                table[i][j]+=10**(digit-2)
            elif i==first:
                if last>=j:
                    table[i][j]+=mid+1
                else:
                    table[i][j]+=mid
            else:
                table[i][j]+=0

    sum=0
    for i in range(0,10):
        for j in range(0,10):
            if i!=j:
                sum+=table[i][j]*table[j][i]

    subsum=0
    for i in range(0,10):
        subsum+=table[i][i]*(table[i][i]-1)+table[i][i]
    print(sum+subsum)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int a, b, c, i, count = 0;

    scanf("%d %d %d", &a, &b, &c);

    for (i = a; i <= b; ++i ){
        if (c % i) ;
        else ++count;
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b});

    return 0;
}

Measured memory_bytes: 3608
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private def innerLoop(j: Int, p: Int): Unit = {
      notPrime(j)
      if(j + p <= top)innerLoop(j + p, p)
    }

    private def loop(i: Int): Unit = {
      val p = 2 * i + 3
      if(isPrime(i))innerLoop((p * p - 3) / 2, p)
      if(i < sqrtLimit)loop(i + 1)
    }

    private def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      loop(0)
      Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else if(n==2)println(1)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65380
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long X = Long.parseLong(sc.next());
        double money=100;
        int count=0;

        while(money < X){
            count++;
            money = Math.floor(money * 1.01);
        }
        System.out.println(count);

        sc.close();

        }
    
}

Measured memory_bytes: 35768
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut q = Vec::new();
    for _ in 0..m {
        let v = read_vec::<usize>();
        q.push((v[0] - 1, v[1] - 1, v[2]));
    }
    let mut uft = UnionFindTree::new(n);

    for (x, y, _) in q {
        uft.unite(x, y);
    }

    let mut sets = HashSet::new();
    for i in 0..n {
        sets.insert(uft.find(i));
    }
    println!("{:?}", sets.len());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[derive(Debug, Clone)]
struct UnionFindTree {
    parent: Vec<isize>,
    size: Vec<usize>,
    height: Vec<u64>,
}

impl UnionFindTree {
    fn new(n: usize) -> UnionFindTree {
        UnionFindTree {
            parent: vec![-1; n],
            size: vec![1usize; n],
            height: vec![0u64; n],
        }
    }

    fn find(&mut self, index: usize) -> usize {
        if self.parent[index] == -1 {
            return index;
        }
        let idx = self.parent[index] as usize;
        let ret = self.find(idx);
        self.parent[index] = ret as isize;
        ret
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }

    fn get_size(&mut self, x: usize) -> usize {
        let idx = self.find(x);
        self.size[idx]
    }

    fn unite(&mut self, index0: usize, index1: usize) -> bool {
        let a = self.find(index0);
        let b = self.find(index1);
        if a == b {
            false
        } else {
            if self.height[a] > self.height[b] {
                self.parent[b] = a as isize;
                self.size[a] += self.size[b];
            } else if self.height[a] < self.height[b] {
                self.parent[a] = b as isize;
                self.size[b] += self.size[a];
            } else {
                self.parent[b] = a as isize;
                self.size[a] += self.size[b];
                self.height[a] += 1;
            }
            true
        }
    }
}


Measured memory_bytes: 12152
#include<iostream>
using namespace std;
int main(){
long n,j=1,k,a[101],b[31]={0},d[31];
char c;
while(cin>>n){
cin>>c>>a[j];
if(n==0)break;
b[a[j]]++;j++;
}
n=j;
for(k=1,j=30;j>=0;j--)if(b[j]!=0)d[j]=k++;
while(cin>>j){
cout<<d[a[j]]<<endl;
}
return 0;
}

Measured memory_bytes: 1160
unittest
{
	assert( [ "5", "2", "1", "4", "5", "3" ].parse.expand.solve == 2 );
	assert( [ "4", "0", "0", "0", "0" ].parse.expand.solve == 4 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.to!( long );
	}
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	auto cs = new long[ as.length ];
	cs[] = -1;
	auto cs_s = cs.assumeSorted!( ( x, y ) => y < x );
	LOOP: foreach( a; as )
	{
		auto i = cs_s.lowerBound( a - 1 ).length;
		cs[ i ] = a;
		if( ans <= i ) ans++;
	}
	return ans;
}


Measured memory_bytes: 4860
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    int A[100000];
    for(int i = 0; i < N; i++ )
    {
        cin >> A[i];
    }
    int rev[100000];
    for(int i = 0; i < N; i++ )
    {
        rev[A[i] - 1] = i + 1;
    }
    for(int i = 0; i < N; i++ )
    {
        cout << rev[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
int child[500010][2];
ll depth[500010];
ll cnt[500010];
ll dp[500010];
int order[500010];

int main() {
  while (scanf("%d", &n) > 0) {
    MEMSET(depth, 0);
    MEMSET(cnt, 0);
    MEMSET(dp, 0);
    REP(i, n - 1) {
      int a, b;
      scanf("%d %d", &a, &b);
      a--; b--;
      child[i][0] = a; child[i][1] = b;
    }
    queue<pair<int, int> > que;
    que.push(make_pair(0, 0));
    ll ans = 0;
    int m = 0;
    dp[n - 1] = 0;
    cnt[n - 1] = 1;
    while (!que.empty()) {
      int from = que.front().first;
      int d = que.front().second;
      que.pop();
      if (from == n - 1) { ans += d; continue; }
      depth[from] = d;
      order[m++] = from;
      que.push(make_pair(child[from][0], d + 1));
      que.push(make_pair(child[from][1], d + 1));
    }
    assert(m == n - 1);
    reverse(order, order + m);
    REP(i, m) {
      int node = order[i];
      int lc = child[node][0];
      int rc = child[node][1];
      ll d = depth[node];
      cnt[node] = cnt[lc] + cnt[rc];
      dp[node] = max(dp[lc] + dp[rc], max(cnt[lc] * d + dp[rc], cnt[rc] * d + dp[lc]));
    }
    printf("%lld\n", ans - dp[0]);
  }
}

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


int main(){
  
  char s[100];
cin>>s;
  int n=strlen(s),cnt=0;

  for(int i=0;i<n/2;i++)
  if(s[i]!=s[n-i-1])
  cnt++;
  cout<<cnt;

 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a < b){
      int c = a;
      a = b;
      b = c;
    }

    while(b > 0){
      int r = a % b;
      a = b;
      b = r;
    }

    System.out.println(a);

    sc.close();
  }
}


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

typedef pair<int,int> P;

int main(){
	int n,m,h,r;
	vector<P> mat;
	while(cin >> n,n){
		int dp[201] = {};
		for(int i = 0;i < n;i++) {
			cin >> h >> r;
			mat.push_back(P(h,r));
			dp[i] = 1;
		}
		cin >> m;
		for(int i = n;i < n + m;i++){
			cin >> h >> r;
			mat.push_back(P(h,r));
			dp[i] = 1;
		}
		sort(mat.begin(),mat.end());
		int ma = 1;
		for(int i = 1;i < mat.size();i++){
			for(int j = 0;j < i;j++){
				if(mat[i].second > mat[j].second && mat[i].first > mat[j].first){
					dp[i] = max(dp[i],dp[j] + 1);
				}
				ma = max(dp[i],ma);
			}
		}
		cout << ma << endl;
		mat.clear();
	}
	return 0;
}

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

using namespace std;

int n;
vector<int> arr;

int dp[100005];

/*long long calc(int i)
{
	if(i == n-1)	return 0;
	long long option1=INT_MAX, option2=INT_MAX;

	if(dp[i] != 0)	return dp[i];
	if(i+1 < n)
		option1 =  abs(arr[i+1]-arr[i]) + calc(i+1);
	if(i+2 < n)
		option2 =  abs(arr[i+2]-arr[i]) + calc(i+2);

	dp[i] =  min(option1, option2);
	return dp[i];
}
*/
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);	cout.tie(0);
	
	cin >> n;
	arr.resize(n);
	for(int i=0; i<n;i++)	cin >> arr[i];			

	dp[n-1] = 0;
	if(n >= 2 )
		dp[n-2] = dp[n-1]+abs(arr[n-2]-arr[n-1]);
	if(n >= 3)
		dp[n-3] = min(dp[n-1]+abs(arr[n-3]-arr[n-1]),
					dp[n-2]+abs(arr[n-2]-arr[n-3]));

	for(int i=n-4; i>=0; i--)
	{
		dp[i] = min(dp[i+1]+abs(arr[i+1]-arr[i]),
					dp[i+2]+abs(arr[i+2]-arr[i]));
	}

	long long ans = dp[0];
		
	cout <<ans<<endl;
		
	return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	
	string s;
	auto f=[&](auto f, int c, int mx){
		if(c==n){
			cout << s <<"\n"; return;
			return;
		}
		rep( i, mx+1){
			s += char(i+'a');
			f(f, c+1, i==mx? mx+1: mx);
			s.pop_back();
		}
	};
	f(f, 0, 0);
	return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<algorithm>

#define MAX 1000007
#define INF 0x3f3f3f3f

using namespace std;
const int MOD = 1e9+7;
typedef long long ll;
ll f[MAX];

int pow(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1)res = res*x%MOD;
        x = x*x%MOD;
        y>>=1;
    }
    return res;
}

int main(){
    ll n,k;
    ll ans;
    scanf("%lld%lld",&n,&k);
    for(int i = k;i>0;i--){
        f[i] = pow(k/i,n);
        for(int j=2*i;j<=k;j+=i)f[i]-=f[j];
        ans = (ans+f[i]*i%MOD)%MOD;
    }
    printf("%lld",(ans+MOD)%MOD);
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
#define fi first
#define se second
typedef long long ll;
using namespace std;

//BEGIN CUT HERE
//Min_cost_flow
class Min_cost_flow{
public:
    explicit Min_cost_flow(int n):vertex(static_cast<unsigned int>(n+10)){
        G.resize(vertex);
        prev_e.resize(vertex);
        prev_v.resize(vertex);
    }

    void add_edge(int from,int to,ll cap,ll cost){
        G[from].push_back((edge){to, cap, cost, static_cast<int>(G[to].size())});
        G[to].push_back((edge){from, 0, -cost, static_cast<int>(G[from].size() - 1)});
    }

    ll flow(int s,int t,ll f){
        ll res=0;
        h.clear();
        h.resize(vertex,0);
        while(f>0){
            vector<ll> dist;
            dist.resize(vertex);
            dist=dijkstra(s);
            if(dist[t]==INF)return -1;
            for(int i=0;i<vertex;i++)h[i]+=dist[i];
            ll d=f;
            for(int i=t;i!=s;i=prev_v[i]){
                d=min(d,G[prev_v[i]][prev_e[i]].cap);
            }
            f-=d;
            res+=d*h[t];
            for(int i=t;i!=s;i=prev_v[i]){
                edge &e=G[prev_v[i]][prev_e[i]];
                e.cap-=d;
                G[i][e.rev].cap+=d;
            }
        }
        return res;
    }
private:
    struct edge{
        int to;
        ll cap;
        ll cost;
        int rev;
    };

    unsigned int vertex;
    ll INF=(ll)1e16;
    vector<vector<edge> > G;
    vector<ll> h;
    vector<int> prev_v,prev_e;

    vector<ll> dijkstra(int start){
        vector<ll> dist(vertex,INF);
        dist[start]=0;
        priority_queue<pair<ll,int> > q;
        q.push({0,start});
        while(!q.empty()){
            int now=q.top().se;
            ll now_cost=-q.top().fi;
            q.pop();
            if(now_cost>dist[now])continue;
            for(int i=0;i<(int)G[now].size();i++){
                edge &e=G[now][i];
                if(e.cap>0 && dist[e.to]>dist[now]+e.cost+h[now]-h[e.to]){
                    dist[e.to]=dist[now]+e.cost+h[now]-h[e.to];
                    prev_v[e.to]=now;
                    prev_e[e.to]=i;
                    q.push({-dist[e.to],e.to});
                }
            }
        }
        return dist;
    }
};


int main(){
    int v,e,f;cin>>v>>e>>f;
    Min_cost_flow m(v);
    for(int i=0;i<e;i++){
        int from,to,cap,cost;
        cin>>from>>to>>cap>>cost;
        m.add_edge(from,to,cap,cost);
    }
    cout<<m.flow(0,v-1,f)<<endl;
}


Measured memory_bytes: 3276
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		string[] str2 = Console.ReadLine().Split();
		int[][]A = new int[N][];
		int[]B = new int[N];
		int ct = 0;
		for(var i=0;i<N;i++){
			A[i] = new int[4]{int.Parse(str[i]),-1,int.Parse(str2[i]),-1};
			B[i] = A[i][0];
			if(A[i][0] <= A[i][2]){
				ct++;
			}
		}
		string ans = "Yes";
		Array.Sort(A,(x,y)=>x[0]-y[0]);
      	for(var i=0;i<N;i++){
			A[i][1] = i;
		}
		Array.Sort(A,(x,y)=>x[2]-y[2]);
      	for(var i=0;i<N;i++){
			A[i][3] = i;
		}
		Array.Sort(B);
		for(var i=0;i<N;i++){
			if(B[i]>A[i][2]){
				ans = "No";
			}
		}
		if(ans == "Yes"){
			ans = "No";
			int[]S = new int[N];
			int si = 0;
			for(var i=0;i<N;i++){
				//Console.Error.WriteLine(si+" "+A[si][1]);
				si = A[si][1];
				if(S[si]==1){
					ans = "Yes";
					break;
				} else {
					S[si] = 1;
				}
			}
			if(ans == "No"){
				ans = "No";
				for(var i=0;i<N-1;i++){
					if(A[i][2] >= B[i+1]){
						ans = "Yes";
                  		break;
	                }
				}
            }
        }
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 37336
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int k = int.Parse(Console.ReadLine());
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int a = input[0];
        int b = input[1];
        bool flag = false;
        for (int i = a; i <= b; i++)
        {
            if (i % k == 0)
            {
                flag = true;
                break;
            }
        }
        Console.WriteLine(flag ? "OK" : "NG");
    }
}

Measured memory_bytes: 27544
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 100001
using namespace std;
LL a[MAXN],s[MAXN];
LL n,m,v,p;
int main()
{
    cin>>n>>m>>v>>p;
    
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
        s[i]=s[i-1]+a[i];
    }
    
    
    int L=1,R=n;
    int ans=p;
    for(int i=1;i<=n-p;i++)
    {
        if(a[i]+m<a[n-p+1])continue;
        if((a[i]+m)*(n-p-i+1)-(s[n-p+1]-s[i])>=(v-p-i+1)*m)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<string>
#include<iostream>
#define MAX 100005
using namespace std;

int main(){
  string s;
  int ans, a;
  cin >> s;
  ans = s.length();
  for(int i = 1; i < s.length(); i++){
    if(s[i-1] != s[i]){
      a = (i > s.length()-i ? i : s.length() - i);
      ans = (ans < a ? ans : a);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
a,b,k = map(int,input().split())
ans1 = a-k
if ans1 <= 0:
    ans2 = b - abs(ans1)
    if ans2 < 0:
        ans2 = 0
    ans1 = 0
    print(ans1, ans2)
else:
    print(ans1, b)

Measured memory_bytes: 38384
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;

typedef struct _BLOCK{
    long long n;
    long long x;
}BLOCK;

int main() {
    long long r,c;
    cin >> r >> c;
    long long table[r+1][c+1];

    for(int i=0; i<(r+1); i++){
        for(int j=0; j<(c+1); j++){
            table[i][j] = 0;
        }
    }

    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            cin >> table[i][j];
        }
    }
    
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            table[i][c] = table[i][c] + table[i][j];
        }
    }

    for(int i=0; i<c; i++){
        for(int j=0; j<r; j++){
            table[r][i] = table[r][i] + table[j][i];
        }
    }
    for(int i=0; i<c; i++){
        table[r][c] += table[r][i];
    }

    for(int i=0; i<(r+1); i++){
        for(int j=0; j<(c); j++){
            cout << table[i][j] << " ";
        }
        cout << table[i][c] << endl;
    }
}


Measured memory_bytes: 3140
N,K=map(int,input().split())
S=input()
a=[0]
for i in range(1,N):
  if S[i-1]!=S[i]:
    a.append(i)
a.append(N)
l=len(a)
ans=[]
for i in range(l-1):
  if S[a[i]]=='0':
    ans.append(a[min(i+2*K,l-1)]-a[i])
  else:
    ans.append(a[min(i+2*K+1,l-1)]-a[i])
print(max(ans))

Measured memory_bytes: 16976
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	ll k;
	cin>>k;
	if(k%2==0 || k%5==0){
		printf("-1");
		return 0;
	}
    long long n=7;
    for(ll i=1;i<=10000000;++i){
    	if(n%k==0){
    		cout<<i;
    		return 0;
    	}
    	n=n*10+7;
    	n%=k;
    }
    printf("-1");
    return 0;
}

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

int main()
{
    int w,a,b;

    while(cin>>w>>a>>b)
    {
        if((a<b && b<a+w)||(b<a && a<b+w)||a==b){
            cout<<0<<endl;
            }
        else if(b<a){
            cout<<abs(b+w-a)<<endl;
        }
        else
        cout<<abs(a+w-b)<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long g[10000005];
long long a[10000005];
long long cnt;
long long isort(long long a[],long long n,long long g)
{
    for(long long i=g;i<n;i++)
    {
        long long v=a[i];
        long long j=i-g;
        while(j>=0&&a[j]>v)
        {
            a[j+g]=a[j];
            j=j-g;
            cnt++;

        }
        a[j+g]=v;
        //cout<<cnt<<endl;
    }
}
void shellsort(long long a[],long long n,long long m)
{
    cnt=0;
    for(long long i=0;i<m;i++)
    {
        isort(a,n,g[i]);
    }
}
int main()
{
    long long n;
    cin>>n;
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long l=0,e=n;
    while(e>0)
    {
        g[l]=e;
        e/=2;
        l++;
    }
    cout<<l<<endl;
    for(long long i=0;i<l;i++)
    {
        cout<<g[i]<<' ';
    }
    cout<<endl;
    shellsort(a,n,l);
    cout<<cnt<<endl;
    for(long long i=0;i<n;i++) cout<<a[i]<<endl;

}

Measured memory_bytes: 10876
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;

int main() {
	double a, b, c, d; cin >> a >> b >> c >> d;

	int u = ceil(a / d);
	int t = ceil(c / b);

	if (t <= u) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3724
#include <stdio.h>
 int main(void){
char s[100000];



int i,ans;
int cnt0=0;
int cnt1=0;
scanf("%s",s);
 
for(i=0;s[i]!='\0';i++){
  
if(i%2==0){
 if(s[i]=='0') cnt0++;}
if(i%2==1){
 if(s[i]=='1') cnt0++;}
}
for(i=0;s[i]!='\0';i++){
if(i%2==1){
 if(s[i]=='0') cnt1++;}
if(i%2==0){
 if(s[i]=='1') cnt1++;}
}

if(cnt0>cnt1){ans=cnt1;}
else{ans=cnt0;}


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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
using namespace std;
inline int read()
{
	int ans=0,f=1;
	char c=getchar();
	while (!isdigit(c))
	{
		if (c=='-')
			f=-1;
		c=getchar();
	}
	while (isdigit(c))
	{
		ans=(ans<<3)+(ans<<1)+(c^48);
		c=getchar();
	}
	return ans*f;
}
void write(int x)
{
	if (x>=10)
	{
		write(x/10);
		x%=10;
	}
	putchar(x+'0');
}
int max(int a,int b,int c)
{
	return max(a,max(b,c));
}
int min(int a,int b,int c)
{
	return min(a,min(b,c));
}
int main()
{
	int a,b,c;
	a=read(),b=read(),c=read();
	write(max(a,b,c)-min(a,b,c));
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# from collections import deque

def linput(ty=int, cnv=list):
    return cnv(map(ty, input().split()))

def vinput(rep=1, ty=int, cnv=list):
    return cnv(ty(input().rstrip()) for _ in "*"*rep)

def gcd(n,m):
    while m: n,m = m, n%m
    return n

def lcm(n,m): return n*m//gcd(n,m)

def main():
    X,Y = linput()

    res = X if X%Y else -1
    print(res)
    # sT = "No Yes".split()
    # print(sT[res])
    # for vR in mR:
    #     print(*vR, sep="")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
#include<stdio.h>
int main()
{
	int h[10],x,max1=0,max2=0,max3=0;
	for(x=0; x<10; x++)
		scanf("%d",&h[x]);
	for(x=0; x<10; x++)
	{
		if(max1<h[x])
		{
			if(max1>max2)
			{
				if(max2>max3)
					max3=max2;
				max2=max1;
			}
			max1=h[x];
		}
		else if(max2<h[x])
		{
			if(max2>max3)
				max3=max2;
			max2=h[x];
		}
		else if(max3<h[x])
			max3=h[x];
	}
	printf("%d\n%d\n%d\n",max1,max2,max3);
	return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			
			//line = br.readLine();
			String s= br.readLine();
			//StringTokenizer st = new StringTokenizer(line, "");
			int min = 99999999;
			for (int i =0;i < s.length()-2;i++) {
				int temp = Integer.parseInt(s.substring(i, i+3));
				if (Math.abs(753-temp) < min) {
					min= Math.abs(753-temp);
				}
			}
			
			System.out.println(min);

			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;

bool checkIfPrime(int& a){
  for (int i=2;i<=sqrt(a);i++){
    if((a%i)==0)return 0;
  }
  return 1;
}

int main()
{
  int a;
  cin>>a;
  if(checkIfPrime(a))cout<<a;
  else {
    while(!checkIfPrime(++a));
    cout<<a;
  }

  return 0 ;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M;
int A[100];
int sum = 0;

// A[i]/sum >= 1/(4M)
// 4MA[i] >= sum

signed main(){
    cin >> N >> M;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }
    sort(A, A+N, greater<int>());
    if(4*M*A[M-1] >= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> e(m);
	vector<bool> b(n+1,true);
	for(int i=0;i<m;i++) cin >> e[i];
	reverse(e.begin(),e.end());
	for(int i=0;i<m;i++){
		if(b[e[i]]){
			cout << e[i] << endl;
			b[e[i]]=false;
		}	
	}
	for(int i=1;i<=n;i++){
		if(b[i]){
			cout << i << endl;
			b[i]=false;
		}	
	}
  return 0;
}


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

int main(){

  int x,h;
  double sum;

  while(cin >> x >> h , x&&h){
    sum = x*x;
    sum += x* sqrt(h*h+(x/2.0)*(x/2.0)) / 2.0 *4;
    printf("%.6f\n",sum);
  }


  return 0;

}

Measured memory_bytes: 1192
#include <algorithm>
#include <cctype>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
} 
const int N = 2e5+5;
const int64 INF = 0x3f3f3f3f3f3f3f3f;
int n, t, e, px[N];
int64 f[N], w = INF;
int main()
{
    n = read(), e = read(), t = read();
    for(int i = 1, j = 0; i <= n; ++i)
    {
        px[i] = read();
        while(2*(px[i]-px[j+1]) >= t) w = min(f[j]-2*px[j+1], w), ++j;
        f[i] = min(w+2*px[i], f[j]+t);
    }
    printf("%lld\n", f[n]+e);
    return 0;
}

Measured memory_bytes: 1280
final class UnionFindTree2 {
    
    private enum Parent {
        case element(Int)
        case root(groupSize: Int)
    }
    
    private var parents: [Parent]
    
    init(size: Int) {
        self.parents = [Parent](repeating: .root(groupSize: 1), count: size)
    }
    
    func group(of element: Int) -> (representative: Int, size: Int) {
        let parentOfElement = parents[element]
        switch parentOfElement {
        case .element(let parent):
            let (representative, groupSize) = group(of: parent)
            self.parents[element] = .element(representative)
            return (representative: representative, size: groupSize)
        case .root(let groupSize):
            return (representative: element, size: groupSize)
        }
    }
    
    func sameGroupContains(_ a: Int, and b: Int) -> Bool {
        group(of: a) == group(of: b)
    }
    
    func uniteGroups(of a: Int, and b: Int) {
        var smallerGroup = group(of: a)
        var biggerGroup = group(of: b)
        guard smallerGroup.representative != biggerGroup.representative else { return }
        if smallerGroup.size > biggerGroup.size {
            swap(&smallerGroup, &biggerGroup)
        }
        self.parents[biggerGroup.representative] = .root(groupSize: smallerGroup.size + biggerGroup.size)
        self.parents[smallerGroup.representative] = .element(biggerGroup.representative)
    }
}

func main(input1: String = readLine()!) {
    let integers = input1.split(separator: " ").map { Int($0)! }
    let n = integers[0]
    let m = integers[1]
    
    let tree = UnionFindTree2(size: n)
    for _ in 0..<m {
        let integers = readLine()!.split(separator: " ").map { Int($0)! }
        let a = integers[0] - 1
        let b = integers[1] - 1
        tree.uniteGroups(of: a, and: b)
    }
    var maxGroupSize = 0
    for someone in 0..<n {
        let groupSize = tree.group(of: someone).size
        if maxGroupSize < groupSize {
            maxGroupSize = groupSize
        }
    }
    print(maxGroupSize)
}

main()

Measured memory_bytes: 10932
import java.util.Scanner;

public class Main {

	private int gcd(int a, int b) {
		if (a > b) {
			int tmp = b;
			b = a;
			a = tmp;
		}
		// a <= b
		while (b % a != 0) {
			int oldA = a;
			a = b % a;
			b = oldA;
		}
		
		return a;
		
	}
	
	public int solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] Ai = new int[N];
		for (int i=0; i<N; i++) {
			Ai[i] = in.nextInt();
		}
		in.close();
		
		int ret = Ai[0];
		for (int i=1; i<N; i++) {
			ret = gcd(ret, Ai[i]);
		}
		
		return ret;
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		System.out.println(main.solve());
	}
}

Measured memory_bytes: 49536
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
a = [None]*(n-1)
from collections import defaultdict
c = defaultdict(list)
for i in range(n-1):
    num = int(input())
    c[num].append(i+2)

### 行きがけ順DFS
def dfs(start):
    q = [start] # now, prev
    us = []
    seen = set([start])
    while q:
        u = q.pop()
        us.append(u)
        for v in c[u]:
            if v in seen:
                continue
            q.append(v)
            seen.add(v)
    return us

us = dfs(1)
val = {}
for winner in us[::-1]:
    l = len(c[winner])
    vs = []
    for p in c[winner]:
        vs.append(val[p])
    vs.sort()
    ans = max([l] + [(l-i+v) for i,v in enumerate(vs)])
    val[winner] = ans
ans = val[1]
print(ans)

Measured memory_bytes: 115712
#include <stdio.h>

int main(void){
  int n, x;
  while(1){
    scanf("%d %d\n", &n, &x);
    if (n == 0 && x == 0) break;
    else{
      int i, j, k;
      int count = 0;
      for(i=1; i<=n; i++){
        for(j=i+1; j<=n; j++){
          for(k=j+1; k<=n; k++){
            if(i+j+k == x) count++;
          }
        }
      }
      printf("%d\n", count);
    }
  }

  return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


   


int main() {
  int n;
  cin >> n;
  ll ans=1;
  for (int i=1;i<= n;i++){
    ans *= i;
    ans%=MOD;
    //cout << ans << endl;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3568
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define rep(i,n) for(ll i=0;i<n;i++)
typedef long long ll;
using namespace std;

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}

void chmax(ll &a,const ll &b){
    if(a<b) a=b;
}
void chmin(ll &a,const ll &b){
    if(a>b) a=b;
}


int main()
{
    ll N,W;

    cin >> N >> W;

    ll w[N],v[N],dp[W+1];

    rep(i,N) cin >> w[i] >> v[i];
    rep(i,W+1) dp[i]=0;

    rep(i,N){
        for(int j=W;j>=0;j--){
            if(j-w[i]>=0){
                chmax(dp[j],dp[j-w[i]]+v[i]);
            }
        }
    }


    cout << dp[W] << endl;



 
    return 0;

}

Measured memory_bytes: 1024
#include<iostream>
#define ll long long
using namespace std;

ll k;

int main(){
  cin>>k;

  cout<<50<<endl;
  ll a = k/50;
  for(int i=0;i<50;i++){
    if(a==k/50+50-k%50)
      a++;
    cout<<a<<" ";
    a++;
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String s = scan.nextLine();
    String t = scan.nextLine();
    int sum = 0;
    
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) != t.charAt(i)) {
        sum++;
      }
    }

    System.out.println(sum);
  }
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << 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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n,k;cin>>n>>k;
  ll a[n];rep(i,0,n)cin>>a[i];
  ll e[n];CLR(e,0);
  if(k>2*pow(10,5)){
    ll num=1;
    ll count=0;
    while(!e[num-1]){
      e[num-1]=count;
      num=a[num-1];
      count++;
    }
    ll c=count-e[num-1];
    k-=count;
    k%=c;
    while(k--){
      num=a[num-1];
    }
    out(num);

  }else{
    ll num=1;
    while(k--){
      num=a[num-1];
    }
    out(num);
  }



  return 0;
}


Measured memory_bytes: 6760
#include<bits/stdc++.h>
using namespace std;
static const int num_x = 100;

int main(){
  int n;
  long double k = 0.0;
  int x[num_x];
  cin >> n;
  for(int i=0;i<n;i++){
    cin>>x[i];
    k += x[i];
  }
  //cout << k/n << endl;
  k = k/n;
  if(k - floor(k) >= 0.5) k = ceil(k);
  else k = floor(k);

  long long int S = 0;
  for(int i=0;i<n;i++){
    S += pow((x[i] - k), 2);
  }
  cout << S << endl;
  //cout << k << endl;
  return 0;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = (int)1e9+7;
long long d[100003],ans,mul=1;
char str[100003];
int main(){
    int i,j,len;
    scanf("%s",str);
    len=strlen(str);
    d[0]=1;
    for(i=1;i<=100000;i++) d[i]=d[i-1]*3%mod;
    for(i=0;i<len-1;i++){
        if(str[i]=='1'){
            ans+=mul*d[len-i-1]%mod;
            mul=mul*2%mod;
        }
    }
    if(str[i]=='1') ans=(ans+mul*3)%mod;
    else ans=(ans+mul)%mod;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1152