akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    ll a[n];
    ll gc=0;
    REP(i,n){
    cin>>a[i];
    gc=__gcd(gc,a[i]);
    }
    cout<<gc;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,ma=-1,mi=1000000,sum=0;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin>>v.at(i);
		ma=max(v.at(i),ma);
	}
	for(int i=1;i<ma+1;i++){
		for(int j=0;j<n;j++){
			sum+=pow(v.at(j)-i,2);
		}
		mi=min(sum,mi);
		sum=0;
	}
	cout<<mi<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
void call (int n) {
  int i = 1;
 CHECK_NUM:
  int x = i;
  if (x% 3 == 0) {
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if (x% 10 == 3) {
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if (x) goto INCLUDE3;
 END_CHECK_NUM:
  if (++ i <= n) goto CHECK_NUM;

  cout << endl;
}

int main()
{
    int n;
    cin >> n;
    call(n);
    return 0;
}

Measured memory_bytes: 1160
n,d = map(int,input().split( ))
px = [tuple(map(int, input().split( ))) for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i):
        sq = 0
        for t in range(d):
            sq += (px[i][t]-px[j][t])**2
        sqsq = int(sq**(1/2))
        if sq == sqsq**2 or sq==(sqsq+1)**2:
            cnt += 1
print(cnt)

Measured memory_bytes: 38256
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<queue>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int a,v,b,w,t,dis;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>a>>v>>b>>w>>t;
	dis=abs(a-b);
	if(v<=w||dis>t*(v-w))
	{
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	return 0;
}



Measured memory_bytes: 3588
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	s := io.Next()
	q := io.NextInt()
	t, f, c := make([]int, q), make([]int, q), make([]byte, q)
	for i := 0; i < q; i++ {
		t[i] = io.NextInt()
		if t[i] == 2 {
			f[i], c[i] = io.NextInt(), io.Next()[0]
		}
	}
	ans := solve(s, t, f, c)
	io.Println(ans)
}

func solve(s string, t []int, f []int, c []byte) string {
	const qMax = 200000
	ans := make([]byte, len(s)+2*qMax)
	for i := range s {
		ans[qMax+i] = s[i]
	}
	first, last := qMax, qMax+len(s)-1
	isReversed := false
	for i := range t {
		if t[i] == 1 {
			isReversed = !isReversed
		} else {
			if f[i] == 1 && !isReversed || f[i] == 2 && isReversed {
				first--
				ans[first] = c[i]
			} else {
				last++
				ans[last] = c[i]
			}
		}
	}
	ans = ans[first : last+1]
	if isReversed {
		for i := 0; i < len(ans)/2; i++ {
			ans[i], ans[len(ans)-1-i] = ans[len(ans)-1-i], ans[i]
		}
	}
	return string(ans)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 9728
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
    int a[5];
    int b;
    int flag = 0;
    for(int i=0;i<5;i++)cin >> a[i];
cin >> b;
    for(int i=1;i<5;i++){
        for(int j=0;j<i;j++){
if(a[i] - a[j] > b)flag =1;
        }
    }

    if(flag == 1)cout << ":(" <<endl;
    else cout << "Yay!" << endl;

    return 0;
}

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

using namespace std;

#define ll long long

int main() {
    float a, b, c, d; cin >> a >> b >> c >> d;
    float q = ceil(c/b);
    float r = ceil(a/d);
    if(q<=r) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;
ll a[100005];
ll num[2];

bool cmp(ll x,ll y)
{
    return x > y;
}

int main()
{
    int n,i;

    while(scanf("%d",&n) != EOF)
    {
        num[0] = 0,num[1] = 0;
        for(i = 0;i < n;i++)
        {
            scanf("%lld",&a[i]);
        }
        sort(a,a+n,cmp);
        int cnt = 0;
        for(i = 0;i+1 < n;)
        {
            if(a[i] == a[i+1])
            {
                num[cnt++] = a[i];
                i += 2;
            }
            else i++;
            if(cnt == 2) break;
        }
        printf("%lld\n",num[0]*num[1]);
    }

    return 0;
}


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

int main()
{
    const int mod = 2019;
    string s;
    cin >> s;
    int n = s.size();
    vector<int> dp(n, 0);
    int x = 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            dp[i] = s[n - 1 - i] - '0';
        } else {
            x *= 10;
            x %= mod;
            dp[i] = (dp[i - 1] + x * (s[n - 1 - i] - '0')) % mod;
        }
    }
    map<int, int> mp;
    int ans = 0;
    for (int i = 0; i < n; i++) { mp[dp[i]]++; }
    mp[0]++;
    for (auto& p : mp) { ans += p.second * (p.second - 1) / 2; }
    std::cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i;
	char str[101];
	int flag;
	int count = 0;
	
	while (scanf("%s", str) != EOF){
		flag = 0;
		for (i = 0; i < strlen(str) / 2; i++){
			if (str[i] != str[strlen(str) - 1 - i]){
				flag = 1;
				break;
			}
		}
		
		if (!flag){
			count++;
		}
	}
	
	printf("%d\n", count);
	
	return (0);
}

Measured memory_bytes: 536
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		@SuppressWarnings("unchecked") LinkedList<Integer>[] jobs = new LinkedList[m + 1]; // 遅延日数ごとに仕事をグルーピングする
		for ( int i = 0; i <= m; i++ ) {
			LinkedList<Integer> a = new LinkedList<>();
			a.add(0); // ダミー要素
			jobs[i] = a;
		}

		for ( int i = 0; i < n; i++ ) {
			int d = in.nextInt();
			int f = in.nextInt();
			if ( d > m ) continue; // 遅延日数的に候補になりえない仕事は除外
			jobs[d].add(f);
		}

//		for ( int i = 0; i <= m; i++ ) {
//			System.out.println(i + " " + jobs[i]);
//		}

		long total = 0;
		PriorityQueue<Integer>pool = new PriorityQueue<Integer>(Collections.reverseOrder()); // job候補のプール
		pool.add(0); // ダミー
		
		// m日目をゼロとして考え後退していく days:残り日数
		for ( int today = 0; today <= m; today++ ) {

			pool.addAll(jobs[today]);
			int daypay = (int) pool.poll();

			// System.out.println("days:" + today + " earn +=" + daypay);
			// System.out.println("pool" + pool);
			total += daypay;
		}

		System.out.println(total);
		in.close();
	}
}


Measured memory_bytes: 102420
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;

ll n_sum(ll x) {
  ll res = ((x * x + x) / 2);
  return res;
}

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

  cin >> n;

  ll ans = 0;
  FOR(i, 1, n + 1) {
    ans += n_sum((ll)n / i) * i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3604
A,B,K = map(int,input().split())

a = 0
b = 0

if A <= 10**12 and B <=10**12 and K <= 10**12:
    if A >= K :
        a = A-K
        b = B
    elif  (A + B) >=K:
        a = 0
        b = B-(K-A)
    elif  (A + B)  < K:
        a = 0
        b = 0
else :
    a = 0
    b = 0

print(a,b,end='')


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; vl num(3*n); ll ans = 0;
  
  rep(i,3*n) cin >> num[i];
  
  sort(all(num));
  
  for(ll i=3*n-2; i > n-1; i-=2){
    ans += num[i];
    
  }
  
  
  cout << ans << endl;
  
  
}

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

int cnt[100005];

int main() {
  int n;
  cin>>n;
  int ma=0;
  rep(i,n) {   
    int d;
    cin>>d;
    if (i==0&&d!=0) {
      cout<<0<<endl;
      return 0;
    }
    cnt[d]++;
    ma=max(d,ma);
  }
  ll ans=1;
  if (cnt[0]!=1) {
    cout<<0<<endl;
    return 0;
  }
  const int mod = 998244353;
  for (int i=1; i<=ma; i++) {
    if (cnt[i]==0) {
      cout<<0<<endl;
      return 0;
    }
    rep(j,cnt[i]) {
      ans=ans*cnt[i-1]%mod;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a , b , c ;
     cin >> a>>b >>c ;
     int temp = a ;
     a =b ;
     b= temp;
     temp = a ;
     a= c ;
     c = temp ;
     cout << a << " "<< b << " "<<c;
}


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

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

    int ans;
    for (int i = 1; i <= X; i++) {
        if (i*(i + 1)/2 >= X) {
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int as,nm,am,ah,is;
    scanf("%d",&is);
    as=is%60;
    nm=(is-as)/60;
    am=nm%60;
    ah=(nm-am)/60;
    printf("%d:%d:%d\n",ah,am,as);
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define M 200005
#define Mod 1000000007
using namespace std;
int id=0,a[M],n;
long long dp[M],la[M];//到第i位的不同序列   最后以x结尾的序列 
int main(){
	memset(la,0,sizeof(la));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)if(a[i]!=a[i-1])a[++id]=a[i];
	dp[0]=1; 
	for(int i=1;i<=id;i++){
		int x=a[i];
		la[x]=(dp[i-1]+la[x])%Mod;
		dp[i]=la[x]; 
	}
	printf("%lld\n",dp[id]%Mod);
	return 0;
}

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

const int INF = 2005;
int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> ans(n, 0);
    for (int i = 0; i < n; ++i) {
        queue<int> q;
        vector<int> dist(n, INF);
        dist[i] = 0;
        q.push(i);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            if (v+1<n && dist[v+1]==INF) {
                dist[v+1] = dist[v] + 1;
                q.push(v+1);
            }
            if (0<=v-1 && dist[v-1]==INF) {
                dist[v-1] = dist[v] + 1;
                q.push(v-1);
            }
            if (v==x && dist[y]==INF) {
                dist[y] = dist[v] + 1;
                q.push(y);
            }
            else if (v==y && dist[x]==INF) {
                dist[x] = dist[v] + 1;
                q.push(x);
            }
        }
        for (int j = 0; j < n; ++j) {
            ans[dist[j]]++;
        }
    }
    for (int i = 1; i < n; ++i) {
        cout << ans[i]/2 << endl;
    }
    return 0;
}

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

int main(){
    int N;  cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    int k = 0;
    for(int i=1; i<N; i++){
        if(A[i]==A[i-1]) k++;
    }

    if(k%2==0) cout << N - k << endl;
    else cout << N - k - 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	double N;
	cin >> N;
	for(double x=1;x<=N;x++) {
		if ((ll)(x * 1.08) == N) {
			cout << x << endl;
			return 0;
		}
	}

	cout << ":(" << endl;

}


Measured memory_bytes: 256
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

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

inline void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0, p; char f[7];
	while (x) {
		p = x; x /= 10;
		f[s++] = p - (x << 1) - (x << 3);
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], h3[100003], h4[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int Q1[110000], Q1L, Q1R;
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	Q1[0] = 1; Q1R = 1;
	while (Q1R > Q1L) {
		int a1 = Q1[Q1L]; Q1L++;
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1[Q1R] = i; Q1R++;
			}
		}
	}
	int rn = 0;
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) { h3[dist[i]]++; rn = max(rn, dist[i]); }
	for (int i = 0; i <= rn; i++) D[i].resize(h3[i]);
	for (int i = 1; i <= n; i++) D[dist[i]][h4[dist[i]]] = i, h4[dist[i]]++;
	e[1] = (1 << 30);
	for (int i = 1; i <= rn; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 24988
H, W = map(int, input().split())
Sh = [input() for _ in range(H)]

def check(h, w):
    b1 = False
    b2 = False
    b3 = False
    b4 = False
    if h > 0:
        b1 = Sh[h-1][w] == '#'
    if w > 0:
        b2 = Sh[h][w-1] == '#'
    if h < H-1:
        b3 = Sh[h+1][w] == '#'
    if w < W-1:
        b4 = Sh[h][w+1] == '#'
    return b1 or b2 or b3 or b4

for h in range(H):
    for w in range(W):
        if Sh[h][w] == '#':
            if not check(h, w):
                print("No")
                break
    else:
        continue
    break
else:
    print("Yes")


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val n = readInt()
    val a = List(n) { readInt() }

    val c = mutableSetOf<Int>()
    var ans = 0
    a.forEach {
        if (c.contains(it)) {
            c.remove(it)
            ans--
        } else {
            c.add(it)
            ans++
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()

Measured memory_bytes: 62360
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string b;
  cin >> b;
  if(b == "A")
    cout << "T";
  if(b == "T")
    cout << "A";
  if(b == "G")
    cout << "C";
  if(b == "C")
    cout << "G";
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  long long T1, T2, A1, A2, B1, B2;
  scanf("%lld%lld", &T1, &T2);
  scanf("%lld%lld", &A1, &A2);
  scanf("%lld%lld", &B1, &B2);
  A1 -= B1; A2 -= B2;
  if (A1 < 0) {
    A1 = -A1;
    A2 = -A2;
  }
  B1 = 0, B2 = 0;
  long long d1 = A1*T1 + A2*T2;
  if (d1 == 0) {
    printf("infinity\n");
    return 0;
  }
  long long offset = d1;
  if (offset > 0) {
    printf("0\n");
    return 0;
  }
  long long peakcnt = (A1*T1) / (-offset);
  long long rem = (A1*T1) % (-offset);
  long long ans = 0;
  if (rem == 0) {
    ans = peakcnt * 2;
  } else {
    ans = peakcnt * 2 + 1;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))


n = int(input())
a = lmp()
a.sort()
cnt = 0
amax = max(a)
num = [0]*int(amax+5)
for i in range(n-1):
    if num[a[i]] == 0 and a[i] != a[i+1]:
        cnt += 1
    for j in range(a[i], len(num), a[i]):
        num[j] = 1
if num[a[-1]] == 0:
    cnt += 1


print(cnt)






Measured memory_bytes: 106308
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int c(int a,int b){
	int ans=1;
	b=min(b,a-b);
	For(i,1,b){
		ans=ans*(a-i+1)/i;
	}
	return ans;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int k,s; cin>>k>>s;
	int ans=0;
	For(i,0,k) For(j,0,k){
		if(s-i-j<=k && s-i-j>=0) ans++;
	}
	cout<<ans<<"\n";
	return 0;
}





























Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
#include<map>
#include<set>
#include<list>
#include<unordered_map>
using namespace std;

signed main(){
	unordered_map<int, bool>U;
	int a; cin >> a;
	while (a--) {
		int b; cin >> b;
		U[b] = true;
	}
	int ans = 0;
	cin >> a;
	while (a--) {
		int b; cin >> b;
		ans += U[b];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4800
#include<stdio.h>
int main()
{
	int N,x,v;
	x=1000;
	scanf("%d",&N);
	if(N%x==0){
		printf("0\n");
	}
	else{ 
		v=N/x+1;
		printf("%d\n",v*x-N);
	}
	return 0;
}
 

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	map<char, int> m;
	for (int ii = 0; ii < s.size(); ++ii){
		m[s[ii]]++;
	}

	int minCnt = 100100100;
	for (char c = 'a'; c <= 'z'; ++c){
		if (m[c] == 0) continue;

		string tmp = s;
		for (int cnt = 0; cnt < s.size(); ++cnt){
			//文字列に含まれるアルファベットが1種類だけなら抜ける
			bool OK = true;
			for (int ii = 1; ii < tmp.size(); ++ii){
				if (tmp[0] != tmp[ii]){
					OK = false;
					break;
				}
			}
			if (OK){
				minCnt = min(minCnt, cnt);
				break;
			}
			//処理
			for (int ii = 0; ii < tmp.size() - 1; ++ii){
				if ( (tmp[ii] == c) || (tmp[ii+1] == c) ){
					tmp[ii] = c;
				}
			}
			tmp.erase(tmp.size() - 1);
		}
	}

	cout << minCnt << endl;


	return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = 2e6 + 5;
const ll mod = 1e9 + 7;

vector < ll > fact (N);

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

ll inv (ll a) {
  return pwr (a, mod - 2);
}

ll nCr (int n, int r) {
  return ((((fact[n] * inv (fact[r])) % mod) * inv (fact[n - r])) % mod);
}

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

  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = (i * fact[i - 1]) % mod;

  int k;
  string s;
  cin >> k >> s;
  int n = s.length();

  ll ans = 0;
  for (int x = 0; x <= k; x++) {
    ans = (ans + ((((pwr (26, x) * pwr (25, k - x)) % mod) * nCr (k - x + n - 1, n - 1)) % mod)) % mod;
  }

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


Measured memory_bytes: 19896
#include<bits/stdc++.h>
using namespace std;
int father[100005];
int fin(int x)
{
    if(x==father[x]) return x;
    return father[x]=fin(father[x]);
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        father[i]=i;
    }
    for(int i=1;i<=m;i++)
    {
        int tmp1,tmp2,tmp3;
        scanf("%d%d%d",&tmp1,&tmp2,&tmp3);
        father[fin(tmp1)]=fin(tmp2);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(fin(i)==i) ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1152
<?php

fscanf(STDIN,"%d%d",$alice,$bob);

if ($alice == 1 && $bob !== 1){
    echo "Alice";
}elseif ($alice !== 1 && $bob == 1){
    echo "Bob";
}elseif ($alice == $bob){
    echo "Draw";
}elseif ($alice > $bob){
    echo 'Alice';
}else{
    echo 'Bob';
}

Measured memory_bytes: 4728
def is_prime(number):
    """ ?????????????????´??°???????´???°???????????????????????? """
    if number == 2:
        return True
    if number < 2 or number%2 == 0:
        return False
    i = 3
    while i < (number**0.5) + 1:
        if number%i == 0:
            return False
        i = i + 2
    return True

COUNTER = 0
while 1:
    try:
        N = int(input())
        if is_prime(N):
            COUNTER += 1
    except EOFError:
        break

print(COUNTER)

Measured memory_bytes: 7844
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int[] A = new int[1001], B = new int[1001];

		int a = in.nextInt();
		for(int i = 0; i < a; i++) A[i] = Integer.parseInt(in.next());

		int b = in.nextInt();
		for(int i = 0; i < b; i++) B[i] = Integer.parseInt(in.next());

		int comparate = compare(0, A, B);
		
		if(comparate == -1) {
			if(a < b)comparate = 1;
			else comparate = 0;
		}
		
		System.out.println(comparate);
		in.close();
	}

	static int compare(int idx, int[] A, int[] B) {
		if(idx == 1001)return -1;
		if(A[idx] < B[idx]) return 1;
		else if(A[idx] > B[idx]) return 0;
		else return compare(idx + 1, A, B);
	}

}



Measured memory_bytes: 30704
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;

int n;
vector<int> E[200005];
void input() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
}

int D[200005];
int C[2];
void dfs(int x, int p) {
    D[x] = D[p] + 1;
    C[D[x] % 2]++;
    for (int i : E[x]) {
        if (i == p) continue;
        dfs(i, x);
    }
}

int A[200005], U[200005];
void calc() {
    dfs(1, 0);
    int cnt[3] = {};
    for (int i = 1; i <= n; i++) {
        cnt[i % 3]++;
    }
    if (C[0] <= cnt[0]) {
        int x = 3;
        for (int i = 1; i <= n; i++) {
            if (D[i] % 2 == 0 && x <= n) {
                A[i] = x;
                U[x] = 1;
                x += 3;
            }
        }
    }
    else if (C[1] <= cnt[0]) {
        int x = 3;
        for (int i = 1; i <= n; i++) {
            if (D[i] % 2 == 1 && x <= n) {
                A[i] = x;
                U[x] = 1;
                x += 3;
            }
        }
    }
    else {
        int x[2] = { 1, 2 };
        for (int i = 1; i <= n; i++) {
            if (x[D[i] % 2] <= n) {
                A[i] = x[D[i] % 2];
                U[x[D[i] % 2]] = 1;
                x[D[i] % 2] += 3;
            }
        }
    }
    for (int i = 1, j = 1; ; i++, j++) {
        while (i <= n && A[i]) i++;
        while (j <= n && U[j]) j++;
        if (i > n) break;
        A[i] = j;
        U[j] = 1;
    }
    for (int i = 1; i <= n; i++) {
        cout << A[i] << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    input();
    calc();
    return 0;
}

Measured memory_bytes: 19840
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include<unordered_map>
#include <cassert>
#include <string>
#include <cstring>
#include<stack>
#include<list>
#include<queue>
using namespace std;
typedef long long int ll;
# define INF 0x3f3f3f3f
# define M 1000000007

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int* arr = new int[n]();
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int ans=0;
	for(int i=0;i<k;i++)
	{
		ans += arr[i];
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
	}
	vi b(n);
	for (int i = 0; i < n; i++)
		cin >> b[i];
	vi c(n - 1);
	for (int i = 0; i < n - 1; i++)
		cin >> c[i];
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		res += b[a[i]];
		if (i && a[i - 1] + 1 == a[i])
			res += c[a[i - 1]];
	}
	cout << res;
	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  
  vector<string> vec(H);//要素の数は縦のピクセルの数と一致
  
  for(int i=0;i<H;i++){
    cin >> vec.at(i);//要素をすべて受け取る
  }
  
  cout << string(W+2,'#') << endl;//W+2個の#を意味する
  
  for(int i=0;i<H;i++){
    cout << '#' << vec.at(i) << '#' << endl;//それぞれの行に対して処理
  }
  
	cout << string(W+2,'#') << endl;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

result = ''
for i in range(0,len(S)):
  num = ord(S[i])
  if num + N > 90:
    p = num + N - 90 + 64
  else:
    p = num + N
  new = chr(p)
  result += new

print(result)

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

bool dfs (int x, int p, const vvi &g, vi &a, vll &cnt)
{
    bool ans = true;
    int sons = 0;

    vll from;
    for (int dest : g[x])
    if (dest != p)
    {
        ans &= dfs(dest, x, g, a, cnt);
        from.pb(cnt[dest]);
        cnt[x] += cnt[dest];
        sons++;
    }

    // cnt[x] - paths leave subtree
    if (sons == 0)
        cnt[x] = a[x];
    else
    {
        sort(ALL(from));
        ll suml = 0;
        forn (i, sz(from)) suml += from[i];
        ll maxin = suml / 2;
        if (from.back() >= suml - from.back())
            maxin = suml - from.back();


        // they all contain a[x]
        // so either 2 for strictly in, or 1 for leaving
        // a[x] = in + (cnt[x] - 2 * in)
        // a[x] = cnt[x] - in
        ans &= (cnt[x] >= a[x]);
        ll in = cnt[x] - a[x];
        ans &= (in <= maxin);
        cnt[x] -= 2 * in;
        ans &= (cnt[x] >= 0);
    }

    return ans;
}

void solve (int n)
{
    vi a(n);
    forn (i, n) cin >> a[i];

    vvi g(n);
    forn (i, n - 1)
    {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].pb(v);
        g[v].pb(u);
    }

    int root = -1;
    forn (i, n) if (sz(g[i]) > 1) root = i;

    if (root == -1)
    {
        assert(n == 2);
        cout << (a[0] == a[1] ? "YES" : "NO") << endl;
        return;
    }

    vll cnt(n);
    bool ok = dfs(root, -1, g, a, cnt);
    ok &= (cnt[root] == 0);
    cout << (ok ? "YES" : "NO") << endl;
    //exit(0);
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 19712
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=0
b=0
for i in range(N):
  for j in range(i+1,N):
    if A[i]>A[j]:
      a+=1
for i in range(N):
  for j in range(N):
    if A[i]>A[j]:
      b+=1
a*=K
b*=K*(K-1)//2
a%=(10**9+7)
b%=(10**9+7)
print((a+b)%(10**9+7))

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    FOR(i, 1, n+1) cin >> a[i];

    FORR(i, 1, n+1){
        for(int j=2; j*j<=i; j++){
            if(i%j == 0){
                a[j] = (a[j] + a[i]) % 2;
                if(i/j != j){
                    a[i/j] = (a[i/j] + a[i]) % 2;
                }
            }
            
        }
        if(i > 1) a[1] = (a[1] + a[i]) % 2;
    }


    int sz = 0;
    vector<int> ans;

    REP(i, n){
        if(a[i+1]){
            sz++;
            ans.push_back(i+1);
        }
    }

    cout << sz << endl;
    if(sz > 0){
        REP(i, size(ans)){
            cout << ans[i] << " ";
        }
        cout << endl;
    }


    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<double> x(n), y(n);
  for (int i{}; i < n; ++i) cin >> x[i];
  for (int i{}; i < n; ++i) cin >> y[i];

  double d[4]{};
  for (int i{}; i < n; ++i) {
    d[0] += abs(x[i] - y[i]);
  }
  for (int i{}; i < n; ++i) {
    d[1] += pow(abs(x[i] - y[i]), 2);
  }
  d[1] = sqrt(d[1]);
  for (int i{}; i < n; ++i) {
    d[2] += pow(abs(x[i] - y[i]), 3);
  }
  d[2] = cbrt(d[2]);
  for (int i{}; i < n; ++i) {
    d[3] = max(d[3], abs(x[i] - y[i]));
  }
  for (int i{}; i < 4; ++i) {
    cout << fixed << setprecision(5) << d[i] << endl;
  }

  return 0;
}




Measured memory_bytes: 3512
/*
 * atcoder/abc98/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 300100;
int N;
string S;
int acc_e[MAX] = {0}, acc_w[MAX] = {0};

void solve() {
  cin >> N >> S;
  for (int n=0; n<N; n++) acc_e[n+1] = acc_e[n] + (S[n] == 'E');
  for (int n=0; n<N; n++) acc_w[n+1] = acc_w[n] + (S[n] == 'W');
  int min_ = 400000;
  loop(n,0,N) chmin(min_, acc_w[n] + (acc_e[N] - acc_e[n+1]));
  cout << min_ << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3076
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const n = Number(inputs[0]);
  let hitList: { [key: string]: number } = {};

  for (let i = 1; i <= n; i++) {
    let str = inputs[i];
    if (!(str in hitList)) {
      hitList[str] = 1;
    }
  }

  console.log(Object.keys(hitList).length);
}


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

int main(){
  int n; string s;
  cin >>n >>s;
  int ans = 0;
  for(int i = 1; i<n; i++){
    int cnt = 0;
    for(char c = 'a'; c<='z'; c++){
      bool left = false, right = false;
      rep(j,i) if(s[j]==c) left = true;
      for(int j = i; j<n; j++){
        if(s[j]==c) right = true;
      }
      if(left && right) cnt++;
    }
    if(cnt>ans) ans = cnt;
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    while (1)
    {
        int a, b, c, n, w[1000], x[1000], y[1000], z[1000], st[301];
        cin>>a>>b>>c;
        if (a==0 && b==0 && c==0) break;
        cin>>n;
        for (int i=0; i<n; i++) cin>>w[i]>>x[i]>>y[i]>>z[i];
        for (int i=0; i<301; i++) st[i]=2;
        for (int i=0; i<n; i++)
        {
            if (z[i])
            {
                st[w[i]]=1;
                st[x[i]]=1;
                st[y[i]]=1;
            }
        }
        bool f=true;
        while (f)
        {
            f=false;
            for (int i=0; i<n; i++)
            {
                if (!z[i])
                {
                    if (st[w[i]]==1 && st[x[i]]==1 && st[y[i]]==2) { st[y[i]]=0; f=true; }
                    if (st[w[i]]==1 && st[x[i]]==2 && st[y[i]]==1) { st[x[i]]=0; f=true; }
                    if (st[w[i]]==2 && st[x[i]]==1 && st[y[i]]==1) { st[w[i]]=0; f=true; }
                }
            }
        }
        for (int i=1; i<=a+b+c; i++) cout<<st[i]<<'\n';
    }
    return 0;
}



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

int main() {
  ll n; cin >> n;
  ll sum = 0;
  ll a = n;
  while(a>0){
    sum+=a%10;
    a/=10;
  }
  if(n%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
    
  return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String s = sc.next();
        String t = sc.next();

        for (int i = 0; i < n; i++) {
            System.out.print(s.charAt(i));
            System.out.print(t.charAt(i));
        }

    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0, bf = 0;
	rep(i, n){
		int in;
		cin >> in;
		sum += fabs(bf - in);
		a.at(i) = in;
		bf = in;
	}
	sum += fabs(bf - 0);
	rep(i, n){
		bool bfp, afp;
		int bf, af, now;
		if(i == 0) bf = 0;
		else bf = a.at(i-1);
		if(i == n-1) af = 0;
		else af = a.at(i+1);
		now = a.at(i);
		bfp = now >= bf;
		afp = af >= now;
		if(bfp ^ afp){
			int ans = sum - 2 * min(fabs(now - af), fabs(bf - now));
			cout << ans << endl;
		}else{
			cout << sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <list>
#include <algorithm>
#include <bitset>
#include <string>
#include <cstring>
using namespace std;

#define lli long long int
#define pb push_back
#define M 1000000007

bool compare(pair<int, int> &p1, pair<int, int> &p2)
{
    return true;
}

template <typename T>
T maxInThree(T a, T b, T c)
{
    T temp = max(a, b);
    temp = max(temp, c);
    return temp;
}

template <typename T>
T minInThree(T a, T b, T c)
{
    T temp = min(a, b);
    temp = min(temp, c);
    return temp;
}

void solve()
{
    int t;
    cin >> t;
    map<string,int> mp;
    while(t--){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] ;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3652
use std::io::*;
use std::str::*;

fn main() {
    let n: i32 = read();
    println!("{}", n * n * n);
}

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

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
 
int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size()/2; i++) {
    if (s[i] != s[s.size() - i - 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560