akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int a;
	bool b = 1;
	cin >> a;
	for(int i =1; i<=9; i++){
		if(a%i == 0 && 1<=a/i && a/i <= 9){
			b = 1;
			break;
		}
		else{
			b = 0;
		}
	}
	
	if(!b){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
char a[200005];
int n,p,s[200005],cnt[200005];
long long ans=0;
int main(){
	scanf("%d%d%s",&n,&p,a+1);
	if(p==2){
		for(int i=n;i>=1;i--)if(a[i]%2==0)ans+=i;
		cout<<ans;
		return 0;
	}
	if(p==5){
		for(int i=n;i>=1;i--)if(a[i]=='0'||a[i]=='5')ans+=i;
		cout<<ans;
		return 0;
	}
	for(int i=n,pp=1;i>=1;i--,pp=pp*10%p)s[i]=(1ll*(a[i]-'0')*pp%p+s[i+1])%p;
	cnt[0]=1;
	for(int i=n;i>=1;i--){
	//	cout<<s[i]<<' ';
		ans+=cnt[s[i]];
		cnt[s[i]]++;
	}
	cout<<ans;
}
/*
6 234
234234
*/


Measured memory_bytes: 1280
#include <stdio.h>
 using namespace std; 
int main(){ int a,b; 
while(true){ scanf("%d %d",&a,&b);
 if(a == 0 && b == 0) break; if(a > b) printf("%d %d\n",b,a);
 else{ printf("%d %d\n",a,b); 
} 
} 
} 


Measured memory_bytes: 2580
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> vec(N,0);
    int a;
    for(int i=1; i<N; i++){
        cin >> a;
        vec.at(a-1)++;
    }
    for(int i=0; i<N; i++){
        cout << vec.at(i) << endl;
    }
}


Measured memory_bytes: 4064
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(this.fibonacci(n));

    }

    private Dictionary<int, int> dic = new Dictionary<int, int>();
    private int fibonacci(int n)
    {
        if (dic.ContainsKey(n))
        {
            return dic[n];
        }

        int ans;
        if (n == 0 || n == 1)
        {
            ans = 1;
        }
        else
        {
            ans = this.fibonacci(n - 1) + this.fibonacci(n - 2);
        }
        this.dic.Add(n, ans);
        return ans;
    }

    static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 9728
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  long long w_max = 1000000;
  int N, W; cin >> N >> W;
  vector<long long> w(w_max), v(w_max);
  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

  vector< vector<long long> > DP(N + 1, vector<long long>(w_max));

  for (int i = 0; i < N; i++) {
    for (int sum_w = 0; sum_w <= W; sum_w++) {
      if (sum_w - w[i] >= 0) {
         DP[i + 1][sum_w] = max(DP[i][sum_w - w[i]] + v[i], DP[i][sum_w]);
      }
      DP[i + 1][sum_w] = max(DP[i + 1][sum_w], DP[i][sum_w]);
    }
  }

  cout << DP[N][W] << endl;
}


Measured memory_bytes: 813056
use std::io::prelude::BufRead;
use std::io::StdinLock;

pub fn read_line(locked_stdin: &mut StdinLock) -> std::io::Result<String> {
    let mut buf = String::new();
    locked_stdin.read_line(&mut buf).map(|_| buf)
}

pub fn read_to_vec<T: std::str::FromStr>(locked_stdin: &mut StdinLock) -> Vec<T> {
    read_line(locked_stdin).unwrap()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n;
    let a;

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        let mut input = read_to_vec::<usize>(&mut lkin).into_iter();
        n = input.next().unwrap();
        a = read_to_vec::<usize>(&mut lkin);
    }

    let min_max: Vec<_> = a.iter().scan(1_000_000_000,
            |min, &a| {*min = std::cmp::min(*min, a); Some(*min)})
        .take(n-1)
        .zip(a.iter().rev().scan(0, |max, &a| {*max = std::cmp::max(*max, a); Some(*max)})
            .collect::<Vec<_>>().into_iter().rev().skip(1))
        .collect();
    let max_diff = min_max.iter().fold(0, |acc, pair| std::cmp::max(acc, pair.1.saturating_sub(pair.0)));

    println!("{}", min_max.into_iter().fold((0, (0, 0)),
            |acc, pair|
                if acc.1 != pair && max_diff == pair.1.saturating_sub(pair.0) {(acc.0 + 1, pair)}
                else {acc}
        ).0);
}


Measured memory_bytes: 12540
#include<cstdio>
#include<iostream>
#include<map>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;

int main(){
	int n,k,ans = 1;
	cin >> n >> k;
	for(int i = 1;i <= n;i++){
		if(ans + k <= ans * 2) ans += k;
		else ans *= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter


n = int(input())
c = Counter(map(int, input().split()))
c = sorted(c.most_common(len(c)), key=lambda a: a[0])
total_cnt = 0
for i, (a, b) in enumerate(c):
    total_cnt += b
    if total_cnt == n // 2:
        print(c[i + 1][0] - c[i][0])
        sys.exit()
print(0)


Measured memory_bytes: 16904
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		StringBuilder s = new StringBuilder(scanner.next());
		Deque<String> stack = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		}

		System.out.println(s.length()-stack.size());
		scanner.close();
	}
}

Measured memory_bytes: 49616
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;
int main(){
  ll n;vll dp(200000,INF);//i円が何回で引き出せるか
  cin>>n;
  dp[0]=0;
  rep(i,0,n+1){
    rep(j,0,7){
      ll m=pow(6,j);
      dp[i+m]=min(dp[i]+1,dp[i+m]);
    }
    rep(j,0,6){
      ll l=pow(9,j);
      dp[i+l]=min(dp[i]+1,dp[i+l]);
    }
  }
  cout<<dp[n]<<endl;
}


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

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

inline void solve() {
    int n;
    cin >> n;

    cout << n * (n+1) / 2 << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


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

int main(){
	double a,b,c,d,e,f;
	double x,y;
	
	while(cin >> a >> b >> c >> d >> e >> f){
		y = (f*a-c*d)/(e*a-b*d);
		x = (c-b*y)/a;
		printf("%.3lf %.3lf\n",x,y);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define INF2 1000000000000000000

int main(void)
{
    int N;
    cin >> N;
    ll A[N];
    vector<ll> B;
    rep(i ,N) cin >> A[i];
    sort(A, A + N, greater<int>());
    rep(i, N-1){
        if(A[i] == A[i+1]){
            B.push_back(A[i]);
            i++;
        }
    }
    if(B.size() < 2){
        cout << 0 << endl;
        return 0;
    }
    cout << B[0] * B[1] << endl;
    return 0;
}

Measured memory_bytes: 1660
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int n, r;
  cin >> n >> r;
  if (n >= 10)
    cout << r << endl;
  else
    cout << r + (100 * (10 - n)) << endl;
  return (0 ^ _ ^ 0);
}



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

using namespace std;

int a,b; 
int c[100010],d[100010],e[100010];
int f[200010]; 
int g[200010]; 
int main() {
  cin >> a>>b;
  for(int i=0;i<a;i++)
    cin >> c[i] >> d[i] >> e[i];
  
  for(int i=1;i<=b;i++) { 
    for(int j=0;j<200010;j++)
      g[j]=0; 
             for(int j=0;j<a;j++)
                           
          if(e[j]==i) g[c[j]*2-1]++,g[d[j]*2]--; 
    
    for(int j=1;j<200010;j++)g[j]+=g[j-1]; 
    
    for(int j=0;j<200010;j++)if(g[j]>0)f[j]++;
  } 
  int ans=0;
  
  for(int j=0;j<200010;j++){
    ans = max(ans,f[j]);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 2944
A, B, C, K = list(map(int, input().split()))
k = K
t = 0

t += min(k, A)
k -= min(k, A)


if k > 0 and B > 0:
    k -= min(k, B)

if k > 0 and C > 0:
    t -= min(k, C)
    k -= min(k, C)

ans = t
print(ans)


Measured memory_bytes: 9192
use std::char::from_u32;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut n: u64 = read();
    let mut result = String::new();
    while n > 0 {
        n -= 1;
        let mut remainder = n % 26;
        if remainder > std::u32::MAX as u64 {
            remainder /= 1000000;
        }
        let digit = from_u32(remainder as u32 + 97).unwrap();
        result = format!("{}{}", digit, result);
        n = (n - remainder) / 26;
    }
    println!("{}", result);
}


Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
signed main(){
  vector<int> s(20,0);
  vector<int> h(20,0);
  vector<int> c(20,0);
  vector<int> d(20,0);
  vector<int> count(5,0);
  int n,b,e=0;
  string a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a=="S")
      s[b-1]=1;
    if(a=="H")
      h[b-1]=1;
    if(a=="C"){
      c[b-1]=1;
    }
    if(a=="D")
      d[b-1]=1;
  }
  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
      if(i==0){
	if(s[j]!=1)
	  cout<<'S'<<' '<<j+1<<'\n';
      }
      if(i==1){
	if(h[j]!=1)
	  cout<<'H'<<' '<<j+1<<'\n';
      }
      if(i==2){
	if(c[j]!=1)
	  cout<<'C'<<' '<<j+1<<'\n';
      }
      if(i==3){
	if(d[j]!=1)
	  cout<<'D'<<' '<<j+1<<'\n';
      }
    }
  }
  return(0);
}



Measured memory_bytes: 3152
K = int(input())
amaris = [0]*(K)
num = 7
answer = -1
count = 1
while True:
    amari = num%K
    if amari == 0:
        answer = count
        break
    if amaris[amari] == 0:
        amaris[amari] = 1
    else:
        break
    num = 10*amari + 7
    count += 1
print(answer)

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

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



Measured memory_bytes: 256
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,y;
	cin>>n>>y;
	y/=1000;
	for(int i=0;i<=y/10;i++)
		for(int j=0;j<=y/5;j++)
		{
			int k=y-i*10-j*5;
			if(k>=0&&i+j+k==n){
				cout<<i<<' '<<j<<' '<<k;
				return 0;
			}
		}
	cout<<"-1 -1 -1";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	int a[5];
	for(int i=0;i<5;i++)cin>>a[i];
    sort(a,a+5);
    for(int i=4;i>0;i--)cout<<a[i]<<" ";
    cout<<a[0]<<endl;
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<algorithm>
using namespace std;
 
typedef long long ll;
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)

ll n,a,b,h[100005] = {};
 
bool boon(ll cnt){
    ll t[100005] = {};
    ll nokori  = cnt;
    rep(i,0,n){
        t[i] = h[i];
        t[i] -= b*cnt;
        if(t[i] > 0){
            nokori -= (t[i]+(a-b)-1)/(a-b);
            if(nokori < 0)return false;
        }
    }
    return true;
}
 
int main(){
	cin >> n >> a >> b;
    rep(i,0,n)cin >> h[i];
    sort(h,h+n);
    ll l = 1,r = (h[n-1]+b-1)/b;
    ll cnt = (l+r)/2;
    
    while(l < r){
        if(boon(cnt)) r = cnt;
        else l = cnt+1;

        cnt = (l+r)/2;
    }
    cout << cnt << endl;
	return  0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

int main(){
    int A,B;
    cin >> A >> B;
    map<int,bool> mp;
    mp[1]=false;
    mp[2]=false;
    mp[3]=false;
    mp[A] = true;
    mp[B] = true;
    for(auto p=mp.begin();p!=mp.end();p++){
        if(p->second==false) cout << p->first << endl;
    }
    return 0;

    
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128


signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	std::vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	map<int, int> mp;
	for(int i = 0; i < k; ++i) {
		mp[a[i]]++;
	}
	int res = 1;
	for(int i = 0; i < n - k; ++i) {
		bool ok = 0;
		if(!mp.empty() && mp.begin()->fi != a[i]) {
			ok = 1;
		}
		mp[a[i]]--;
		if(mp[a[i]] == 0) {
			mp.erase(a[i]);
		}
		if(!mp.empty() && mp.rbegin()->fi > a[i + k]) {
			ok = 1;
		}
		mp[a[i + k]]++;
		if(ok) {
			++res;
		}
		// cout << i << ' ' << ok << endl;
	}
	int len = 1, x = 0;
	for(int i = 1; i < n; ++i) {
		if(a[i] > a[i - 1]) {
			++len;
		} else {
			len = 1;
		}
		if(len == k) ++x;
	}
	if(x) res -= x - 1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10368
from collections import Counter
n,a,b=map(int,input().split())
V=list(map(int,input().split()))
V.sort()
N=50
bikkuri=[1 for i in range(N+1)]
for i in range(N):
    bikkuri[i+1]=(i+1)*bikkuri[i]
def comb(a,b):
    if b==0:
        return 1
    else:
        return bikkuri[a]//(bikkuri[a-b]*bikkuri[b])
ans1=0
ans2=0
if V[-a]==V[-1]:
    ans1=V[-1]
    VC=Counter(V)
    num=VC[ans1]
    for i in range(a,min(b,num)+1):
        ans2+=comb(num,i)
else:
    ans1=sum(V[-a:])/a
    A=list(set(V[-a:]))
    VC=Counter(V)
    num1=VC[V[-a]]
    VaC=Counter(V[-a:])
    num2=VaC[V[-a]]
    ans2=comb(num1,num2)
print(ans1)
print(ans2)

Measured memory_bytes: 3316
#include<stdio.h>
int main(){
    int i, j, n, k, p[1001], tmp, sum=0;
    scanf("%d %d", &n, &k);
    for(i=0; i<n; i++){
        scanf("%d", &p[i]);
    }
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            if(p[i] > p[j]){
                tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }
        }
    }
    for(i=0; i<k; i++){
        sum += p[i];
    }
    printf("%d", sum);
    return 0;
}

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

using namespace std;
typedef long long ll;


int main(){
    int n,m; 
    cin >> n >> m;

    vector<int> a(m);

    int req = 0;

    for(int i=0;i<m;i++){
        int tmp;
        cin >> tmp;
        req += tmp;
    }
    int res = n - req;
    if(res < 0) res = -1;
    cout << res << endl;
}

Measured memory_bytes: 3668
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

int f(int n) {
    if (n == 0)
        return 1;
    else
        return 2 * f(n - 1);
}

int comb(int n, int r) {
    if (r > n - r)
        r = n - r;
    int q = r;
    int up = 1;
    int down = 1;
    rep(i, q) {
        up *= n;
        down *= r;
        n--;
        r--;
    }
    return up / down;
}

signed main() {
    int n, p;
    cin >> n >> p;
    int a;
    int odd = 0;
    int even = 0;
    rep(i, n) {
        cin >> a;
        if (a % 2)
            odd++;
        else
            even++;
    }
    if (p) {
        int oddint = 0;
        repk(i, 1, odd + 1) {
            if (i % 2) {
                oddint += comb(odd, i);
            }
        }
        cout << f(even) * oddint << endl;
    }
    else {
        int oddint = 0;
        repk(i, 1, odd + 1) {
            if (i % 2 == 0) {
                oddint += comb(odd, i);
            }
        }
        cout << f(even) * (oddint + 1) << endl;
    }
}

Measured memory_bytes: 3540
n=int(input())
s=list(input())
f=0
b=-1
for d in range(1,n):
  c=0
  b=-1
  for i in range(n-d):
    if s[i]==s[i+d] and c<d:
      if b==-1:b=i
      c+=1
      f=max(f,c)
      if c>=d:
        break
    else:
      c=0
      b=-1
print(f)


Measured memory_bytes: 41948
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,m;
  int masu[1005],saikoro;
  while(1){
    int now=1;
    int cnt=0;
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=1;i<=n;i++){
      cin>>masu[i];
    }
    for(int i=0;i<m;i++){
      //cout<<"now="<<now<<endl;
      cin>>saikoro;
      if(now!=n){
	cnt++;
      }
      if(now+saikoro<=1){
	now=1;
      }
      else if(now+saikoro>=n){
	now=n;
      }
      else{
	now+=saikoro;
      }
      if(now+masu[now]<=1){
	now=1;
      }
      else if(now+masu[now]>=n){
	now=n;
      }
      else{
	now+=masu[now];
      }
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 1164
import sys
stdin = sys.stdin
from math import sqrt

def li(): return map(int, stdin.readline().split())




A, B, K = tuple(li())
count = 0
g = min(A, B)
can = []
cnt = 0
for i in range(1, g + 1):
    if A % i == 0 and B % i == 0:
        
        
        can.append(i)



print(can[-K])


Measured memory_bytes: 3060
n = int(input())
num_list = []
for _ in range(n):
    num_list.append(int(input()))

copy =  num_list.copy()
copy.sort()
maximum = copy[-1]
second = copy[-2]

for i in num_list:
    if i == maximum:
        print(second)
    else:
        print(maximum)

Measured memory_bytes: 90980
import numpy as np


def main():
    N = int(input())
    towns = [input().split() for _ in range(N)]
    towns = np.array(towns).astype(np.int64)
    diffs = np.expand_dims(towns, axis=1) - np.expand_dims(towns, axis=0)
    distances = np.sqrt(np.sum(diffs ** 2, axis=-1))
    ans = distances.sum(axis=1).mean()
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
	int v,s=0;
	priority_queue<int> q;
	for(int i=0;i<5;i++){
		cin >> v;
		s+=v;
		if(v%10!=0)q.push(10-(v%10));
	}
	if(!q.empty()) q.pop();
	
	while(!q.empty()){
		s+=q.top();
		q.pop();
	}
	
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  int a,now;
  int c = 0,ans = 0;
  cin >> now;
  for (int i = 0; i < n-1; ++i)
  {
   cin >> a;
   if(a <= now)
   {
    c++;
   }
   else
   {
     ans = max(ans,c);
     c = 0;
   }
   now = a;
  }
  ans = max(ans,c);
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int INF = 0x7fffffff;
static const int MAXN = 101;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n, M[MAXN][MAXN];

int prim()
{
	int node, minn;  //记录当前状态权值最小的边和对应的节点
	int d[MAXN], p[MAXN], color[MAXN]; //最小边权，父节点，访问状态
	/*初始化*/
	for (int i = 0; i < n; i++)
	{
		d[i] = INF;
		p[i] = -1;
		color[i] = WHITE; 
	}
	d[0] = 0;  //初始节点加入MST
	while (true)
	{
		node = -1;
		minn = INF;
		for (int i = 0; i < n; i++)
		{
			if (d[i] < minn && color[i] != BLACK)
			{
				minn = d[i];
				node = i;
			}
		}
		if (node == -1)	break; //图遍历完毕，没有可以新加入MST的节点
		color[node] = BLACK;   //把新节点加入MST

		/*更新状态*/
		for (int i = 0; i < n; i++) 
		{
			if (color[i] != BLACK && M[node][i] < INF)
			{
				if (d[i] > M[node][i])
				{
					d[i] = M[node][i];
					p[i] = node;
				}
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] != -1)	sum += M[i][p[i]];  //求MST每条边的权和
	}
	return sum;
}

int main()
{
	int tmp;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> tmp;
			M[i][j] = (tmp == -1 ) ? INF : tmp;
		}
	}
	cout << prim() <<endl;
    return 0;
}




Measured memory_bytes: 3088
from math import asin, degrees, sqrt
 
a,b,x = map(int,input().split())
 
m = 2*x/a**2 - b
if m >= 0:
    sin = (b-m)/sqrt((b-m)**2+a**2)
    print("{:.10f}".format(degrees(asin(sin))))
else:
    sin = b/sqrt((b**2)+((2*x)/(a*b))**2)
    print("{:.10f}".format(degrees(asin(sin))))

Measured memory_bytes: 3060
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n,k = map(int, input().split())
ans = len(Base_10_to_n(n,k))
print(ans)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a * 100 + b * 10 + c) % 4  == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

namespace ABC150_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var kx = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(kx[0] * 500 >= kx[1] ? "Yes" : "No");
        }
    }
}


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

int main()
{
    int m = 0;           //中間試験の点数
    int f = 0;           //期末試験の点数
    int r = 0;           //再試験の点数
    int i = 0;           //ループカウンタ
       

    cin >> m >> f >> r;
    while (m != -1 || f != -1 || r != -1) {



        if (m == -1 || f == -1) {
            cout << "F" << endl;
        }
        else if (m + f >= 80) {
            cout << "A" << endl;
        }
        else if (m + f >= 65)
        {
            cout << "B" << endl;
        }
        else if (m + f >= 50)
        {
            cout << "C" << endl;
        }
        else if ( 30 <= m + f )
        {
            if (r >= 50) {
                cout << "C" << endl;
            }
            else
            {
                cout << "D" << endl;
            }
                
        }
        else
        {
            cout << "F" << endl;
        }
        cin >> m >> f >> r;
    }
    


}


Measured memory_bytes: 3120
N = gets.to_i
arr = gets.split(" ").map(&:to_i)

a = 0
b = 0
ans = 0

(N-1).times do
    b = a + 1
    
    (N-1).times do
        if arr[b].nil?
            break
        else
            ans = ans + arr[a] * arr[b]
            b += 1
        end
    end
    
    a += 1
end

puts ans


Measured memory_bytes: 1788
import java.util.*

fun main(args: Array<String>) {
    val cin = Scanner(System.`in`)
    val a = cin.nextInt()
    val b = cin.nextInt()
    println(
            if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
                "Possible"
            } else {
                "Impossible"
            }
    )
}

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

int main(){
	int n;
	cin>>n;
	vector<pair<int,int> >arr;
	for(int i=1; i<=n; i++){
		int a;
		cin>>a;
		arr.push_back(make_pair(a,i));	
	}
	sort(arr.begin(),arr.end());
	for(int i=0; i<arr.size(); i++) cout<<arr[i].second<<" ";
}


Measured memory_bytes: 4280
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    int n, m;
    cin >> n >> m;
    vector<vector<int>> e(n);
    REP(i,m) {
        int u,v;
        cin >> u >> v;
        --u; --v;
        e[u].PB(v); e[v].PB(u);
    }
    queue<PII> q;
    vector<bool> vis(n);
    q.emplace(0,0);
    vis[0]=1;
    while ( q.size() ) {
        int u=q.front().first, d=q.front().second;
        q.pop();
        if ( d>2 ) break;
        if ( u==n-1 ) {
            cout << "POSSIBLE\n";
            return 0;
        }
        for ( int v:e[u] ) {
            if ( vis[v] ) continue;
            q.emplace(v, d+1);
            vis[v]=1;
        }
    }
    cout << "IMPOSSIBLE\n";
    return 0;
}

Measured memory_bytes: 12784
#!/usr/bin/env ruby

if $0 == __FILE__
  N = gets.to_i
  H = gets.split(' ').map &:to_i

  dp = Array.new(N, 100000)
  dp[0] = 0
  dp[1] = (H[1] - H[0]).abs

  (2..(N-1)).each do |i|
    cost1 = dp[i-2] + (H[i] - H[i-2]).abs
    cost2 = dp[i-1] + (H[i] - H[i-1]).abs
    dp[i] = cost1 < cost2 ? cost1 : cost2
  end

  puts dp[N-1]
end


Measured memory_bytes: 8844
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
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; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;
// const ll k=998244353;

const ll MAX = 510000;
const ll MOD =998244353;

ll c[MAX];


int main(){

  ll n;cin>>n;
  ll d[n];
  rep(i,0,n){
    cin>>d[i];
    c[d[i]]++;
  }
  if(d[0]!=0){out(0);return 0;}
  rep(i,1,n){
    if(d[i]==0){out(0);return 0;}
  }


  ll ans=1;
  ll ma=*max_element(d,d+n);
  rep(i,1,ma+1){
    ll num=1;
    rep(j,0,c[i]){
      num*=c[i-1]%MOD;
      num%=MOD;
    }
    ans*=num%MOD;
    ans%=MOD;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n, t;
	cin >> n >> t;
	int in, mini = INF, macs = -INF, ans = 1;
	rep (i, n) {
		cin >> in;
		if (mini <= in) {
			if (macs < in - mini) {
				macs = in - mini;
				ans = 1;
			} else if (macs == in - mini) {
				ans++;
			}
		} else {
			mini = in;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,cnt=1;
    cin>>n;
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    ll mini=p[0];
    rep(i,n){
        if(mini>p[i]){
            mini = min(mini,p[i]);
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

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

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i, 0, n)
    cin >> a[i];
  
  bool check = true;
  
  rep(i, 0, n){
    if(a[i] %2 == 0){
      if(a[i] %3 != 0 && a[i] %5 != 0){
        check = false;
        break;
      }
    }
  }
  
  if(check)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
  
  return 0;
  
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int main(){
  int N;
  cin >> N;
  vector<tuple<string,int,int>> vec;
  REP(i,N){
    string s;
    int p;
    cin >> s >> p;
    vec.push_back(make_tuple(s,100-p,i));
  }
  sort(ALL(vec));
  for (tuple<string,int,int>t : vec){
    int y,z; string x;
    tie(x,y,z) = t;
    cout << z+1 << endl;
  }
}

Measured memory_bytes: 256
// [Tag]
// #

#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <deque>
#include <map>
using namespace std;

#define fi     	first    
#define se     	second  

/** Type Define **/
typedef long long int           ll;
typedef pair<ll, ll>            p_ll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
typedef unsigned char           uchar;
typedef unsigned int            ui;
typedef unsigned long long int  ull;

constexpr int               inf =   	2123456789;
constexpr long long 		INF = 		9123456789123456789;
constexpr long long         MOD =       1000000007LL;

template<class T>
using MaxHeap = priority_queue<T>;
template<class T>
using MinHeap = priority_queue<T,vector<T>,greater<T> >;


template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
  for(int i=0;i<vec.size();i++){
    os << vec[i];
    if(i+1<vec.size())os << ' ';
  }
  return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
  for(int i=0;i<vec.size();i++)is >> vec[i];
  return is;
}


/*************************************************/

int N, M;
void sol() {
	if( N == M)
      cout << "Yes\n";
  	else
      cout << "No\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    /*INPUT*/
	cin >> N >> M;
    /*Get_Answer*/
    sol();
    return 0;
}


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

typedef vector<int> vi;

string S, T;
int sz_s, sz_t;
vector<vi> dp;

void input_init(void) {
	cin >> S >> T;
	sz_s = S.length();
	sz_t = T.length();
	dp.resize(sz_s + 1, vi(sz_t + 1, 0));
}

void calcu(void) {
	for (int i = 0; i < sz_s; ++i) {
		for (int j = 0; j < sz_t; ++j) {
			if (S[i] == T[j])
				dp[i + 1][j + 1] = dp[i][j] + 1;
			else
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
		}
	}
}

string solve(void) {
	int sz = dp[sz_s][sz_t];
	string s = string(sz, ' ');
	int i = sz_s;
	int j = sz_t;
	while (sz > 0) {
		if (dp[i][j] == dp[i - 1][j])
			--i;
		else if (dp[i][j] == dp[i][j - 1])
			--j;
		else {
			--i; 
			--j;
			--sz;
			s[sz] = S[i];
		}
	}
	return s;
}

int main(void) {
	input_init();
	calcu();
	string ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 35584
a, op, b = [x for x in input().split()]
while (op != '?') :
    if op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/' and b != '0':
        print(int(a) // int(b))
    a, op, b = [x for x in input().split()]


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>

using namespace std;

int64_t gcd(int64_t A, int64_t B) {
  if (A < B) swap(A, B);
  int64_t C = A % B;
  while (C != 0) {
    A = exchange(B, C);
    C = A % B;
  }
  return B;
}

int main() {
  int64_t A, B;
  cin >> A >> B;
  int64_t den = gcd(A, B);
  cout << (A * (B / den)) << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

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

  int n;
  cin >> n;
  cout << (n+1)%2 << endl;
}

Measured memory_bytes: 3644
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double PI=4*atan(1.0);

double calcAngle(const vector<double> &a,const vector<double> &b){
  double d=0;
  for(int i = 0; i < a.size(); i++)
    d+=a[i]*b[i];
  double e1=0;
  for(int i=0;i<a.size();i++)
    e1+=a[i]*a[i];
  e1=sqrt(e1);
  double e2=0;
  for(int i=0;i<a.size();i++)
    e2+=b[i]*b[i];
  e2=sqrt(e2);
  //cout<<d/(e1*e2)<<" ";
  return acos(d/(e1*e2));
}

int main(){

  int n,m;
  while(cin>>n&&n!=0){
    vector<vector<double> > tels;
    vector<vector<double> > stars;
    for(int i = 0; i < n; i++){
      vector<double> v;
      for(int j = 0; j < 3; j++){
	double t;
	cin>>t;
	v.push_back(t);
      }
      stars.push_back(v);
    }
    cin>>m;
    double angs[1000];
    for(int i = 0; i < m; i++){
      vector<double> v;
      for(int j = 0; j < 3; j++){
	double t;
	cin>>t;
	v.push_back(t);
      }
      tels.push_back(v);
      cin>>angs[i];
    }
    set<int> s;
    // ツつサツづェツつシツづェツづ荊elツづ可づつつ「ツづ陳イツ債ク
    for(int i = 0; i < m; i++){
      for(int j = 0; j < n; j++){
	double a=calcAngle(tels[i],stars[j]);
	//cout<<a<<" ";
	if(a<angs[i])
	  s.insert(j);
      }
    }
    cout<<s.size()<<endl;
  }
  
  return 0;
}  

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<(N); i++)
typedef long long ll;
const ll mod=1e9+7;

ll A,B;
string S;

int main(){ 

cin.tie(0);
ios::sync_with_stdio(false);

cin>>A>>B>>S;

rep(i,S.size()){
	if(i==A){
		if(S[i]!='-'){
			cout<<"No"<<endl; return 0;
		}
	}else{
		if(S[i]=='-'){
			cout<<"No"<<endl; return 0;
		}
	}
}

cout<<"Yes"<<endl;

}


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

int n;
int ans =100;
int tot=0;
int subtotmae=0;
int subtotato;
int w[100];

void solve() {
  
  for (int i=0; i<n; i++) {
    subtotmae += w[i];
    subtotato = tot - subtotmae;
      ans = min(ans, abs(subtotato - subtotmae));
  }

}

int main()
{
    cin >> n;

    for (int i=0; i<n; i++) {
      cin >> w[i];
      tot += w[i];
    }

      solve();

    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int max = 0;
    ArrayList<Integer> N = new ArrayList<Integer>();
    for (int i = 0; i < A; i++) {
      N.add(sc.nextInt());
      max = Math.max(max, N.get(i));
    }
    Collections.sort(N, Collections.reverseOrder());
    N.set(0, max / 2);
    System.out.println(N.stream().mapToInt(x -> x).sum());
  }
}


Measured memory_bytes: 27476
# 解説 AC

# 参考1: https://twitter.com/rickytheta/status/1175412019006074880
# 参考2: https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2019-09-21agc-038

mod = 998244353
max_A = 10**6
N = int(input())
A = list(map(int, input().split()))

# nまでの自然数が素数かどうかを表すリストを返す  O(nloglogn)
def make_prime_checker(n):
    is_prime = [False, True, False, False, False, True] * (n//6+1)
    del is_prime[n+1:]
    is_prime[1:4] = False, True, True
    for i in range(5, int(n**0.5)+1):
        if is_prime[i]:
            is_prime[i*i::i] = [False] * (n//i-i+1)
    return is_prime

primes = [p for p, is_prime in enumerate(make_prime_checker(max_A)) if is_prime]  # max_A 以下の素数のリスト

g = [0] * (max_A+1)
for a in A:
    g[a] += a
for p in primes:
    # 倍数集合の高速ゼータ変換みたいなやつ  O((max_A)loglog(max_A))
    # 参考: http://noshi91.hatenablog.com/entry/2018/12/27/121649
    # 大量に約数列挙みたいなことをするときはこれで高速化できる場合が多そう？（みんぷろ 2018 本戦 A - Uncommon など）
    for k in range(max_A//p, 0, -1):
        g[k] += g[k*p]

# この時点で g[d] = Σ_{d|a} a  (A の要素のうち d の倍数であるものの総和)

g = [v * v % mod for v in g]

# この時点で
# g[d] = (Σ_{d|a} a)(Σ_{d|b} b)
#      = Σ_{(d|a)∧(d|b)} ab
#      = Σ_{d | gcd(a,b)} ab

# この式変形天才すぎないか？（これを使った一連の操作を gcd 畳み込み というらしい？）

for p in primes:
    # 倍数集合の高速メビウス変換みたいなやつ  O((max_A)loglog(max_A))

    # for k in range(1, max_A//p+1):
    #     g[k] -= g[k*p]  # 包除原理ヤバい

    for k, g_kp in enumerate(g[p::p], 1):  # 高速化（ゼータ変換の方は途中で g が変化するので高速化できない）
        g[k] -= g_kp  # 包除原理ヤバい

# この時点で g[d] = Σ_{gcd(a,b)=d} ab

def make_modinv_list(n, mod=10**9+7):
    # 0 から n までの mod 逆元のリストを返す O(n)
    modinv = [0, 1]
    for i in range(2, n+1):
        modinv.append(mod - mod//i * modinv[mod%i] % mod)
    return modinv

modinv_list = make_modinv_list(max_A, mod)
ans = sum((gg * minv % mod for gg, minv in zip(g, modinv_list)))
ans %= mod

# この時点で
# ans = Σ_d ( Σ_{gcd(a,b)=d} ab/d )
#     = Σ_d ( Σ_{gcd(a,b)=d} lcm(a,b) )
#     = Σ_a Σ_b lcm(a,b)

ans -= sum(A)
ans *= modinv_list[2]
ans %= mod

# この時点で ans = Σ_{i<j} lcm(a,b)

print(ans)


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

#define int long long
#define mp make_pair
#define pb push_back
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define EPS 0.00000001

const int inf = 4e18; ///
const int mod2 = 1e9+7;

using namespace std;
void print(vector<int> & v){
    for(auto it:v) cout << it << " ";
    cout << "\n";
}

signed main(){
    double a;
    cin >> a;
    cout << 2*a*3.1415926;
}


Measured memory_bytes: 3772
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from collections import deque

class SegTree():
    def __init__(self, n):
        self.value = [0 for i in range(n*2)]



def main():
    n = getN()
    nums = getList()
    d = deque()
    for i, num in enumerate(nums):
        if i % 2 != n % 2:
            d.appendleft(num)
        else:
            d.append(num)


    print(*d)

if __name__ == "__main__":
    main()

Measured memory_bytes: 91192
function main(input) {
    var inputs = input.split('\n');
    var num = inputs[0];
    var str = inputs[1];
    if(num <= 1){
        console.log('No');
        return;
    }
    var str1 = str.substring(0,num/2);
    var str2 = str.substr(num/2,num);
    if(str1 == str2)
        console.log('Yes');
    else
        console.log('No');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    long K;
    int already[200000] = {};
    int A[200000];
    scanf("%d %ld", &N, &K);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }
    
    int flag = 0;
    int machi = 1;
    already[machi-1] = -1;
    long loopsize;
    long k;
    for(k = 1; k <= K && flag == 0; k++)
    {
        machi = A[machi-1];
        if(already[machi-1] == 0)
            already[machi-1] = k;
        else
        {
            flag = 1;
            if(already[machi-1] == -1)
            {
                already[machi-1] = 0;
            }
            loopsize = k - already[machi-1];
        }
        // printf("%d,",machi);
    }
    // printf("\n");
    
    if(k <= K)
    {
        k -= 1;
        //printf("%d:%ld:machi = %d\n",already[machi-1],k,machi);
        long dest = (K-k)%loopsize;
        for(long d = 1; d <= dest; d++)
        {
            machi = A[machi-1];
        }
    }
    //printf("%ld\n",loopsize);
    printf("%d\n",machi);
}


Measured memory_bytes: 5360
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    double ans = 0.0;
    REP(i, 1, N) {
        int score = i;
        double winrate = 1.0;
        while(score < K) {
            score *= 2;
            winrate *= 0.5;
        }
        ans += winrate/N;
    }
    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_122
{
    class Program
    {

        static void Main(string[] args)
        {
            string data = Console.ReadLine();
            string ret = "";

            if("A" == data)ret = "T";
            else if("C" == data)ret = "G";
            else if("G" == data)ret = "C";
            else if("T" == data)ret = "A";
            Console.WriteLine(ret);

        }
    }
}



Measured memory_bytes: 13140
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif

     long long int n,x,t,sum=0,time=0;
    scanf("%lld %lld %lld ",&n,&x,&t);
    if(n<=x)
    	printf("%lld\n",t );
    else if(n>x)
    {
    	for (long long int i = 0; n-sum>0 ; ++i)
    	{
    		sum=x*i;
    		time=t*i;
    	}
    	printf("%lld\n",time );
    }



    
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    //freopen("test.in", "r+", stdin);
    int N, H, res = 0, mx = -1;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> H;
        if(H >= mx)res++;
        mx = max(mx, H);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct uni_t
{
	int id, n, p;
};


int get_p(vector<uni_t>&u, int x)
{
	int p=u[x].p;
	if(p==x) return p;
	return u[x].p=get_p(u, p);
}


void join(vector<uni_t>&u, int a, int b)
{
	int pa=get_p(u, a);
	int pb=get_p(u, b);
	if(pa==pb) return;
	if(u[pa].n<u[pb].n)
	{
		swap(a, b);
		swap(pa, pb);
	}
	u[pa].n+=u[pb].n;
	u[pb].n=0;
	u[pb].p=pa;
}


struct solve
{
	solve(){}
	ll operator()(int n, vi&a, vi&b) {
		int m=a.size();
		vector<uni_t> c(n+1);
		for(int i=1;i<=n;i++)
		{
			c[i].id=c[i].p=i;
			c[i].n=1;
		}
		for(int i=0;i<m;i++)
		{
			join(c, a[i], b[i]);
		}
		int ans=-1;
		for(int i=1;i<=n;i++)
		{
			if(c[i].n>0) ans++;
		}

		return ans;
	}
};

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

	for(;;)
	{
		int n, m;
		cin >> n >> m;
		if(cin.fail()) break;
		vi a(m), b(m);
		for(int i=0;i<m;i++) cin >> a[i] >> b[i];
		cout << solve()(n, a, b) << "\n";
	}
	return 0;
}


Measured memory_bytes: 5308