akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y;
    cin >> x >> y;
    if (x == y) cout << "Yes";else cout << "No";
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int n,k;
	cin >> n >> k;
	long long int r;
	long long int s;
	r = n%k;
	s=abs(n%k-k);
	long long int ans;
	ans= min(r,s);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

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

int N;
VI v;

int main() {
    cin >> N;
    REP (i, N) {
        int tmp;
        cin >> tmp;
        v.PB(tmp);
    }
    sort(ALL(v));
    double ans = v[0];
    FOR (i, 1, N) {
        ans = (ans + v[i]) / 2.0;
    }
    printf("%.5f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; }cout << endl; }
const LL LLINF = 1LL << 60;

vector<LL> dp(100010, LLINF);

int main(void) {
	LL H, W, A, B;
	cin >> H >> W >> A >> B;

	vector<vector<LL> > grid(H, vector<LL>(W));
	
	for (int i = 0; i < B; i++) {
		for (int j = 0; j < A; j++) {
			grid[i][j] = 1;
		}
	}
	for (int i = B; i < H; i++) {
		for (int j = A; j < W; j++) {
			grid[i][j] = 1;
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << grid[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

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

int main(){
  int N,D;
  cin>>N>>D;
  vector<vector<int>>X(N,vector<int>(D));
  for(int i=0;i<N;++i){
    for(int j=0;j<D;++j){
      cin>>X[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<N;++i){
    for(int j=i+1;j<N;++j){
      int sum=0;
      for(int k=0;k<D;++k){
        int a=abs(X[i][k]-X[j][k]);
        sum+=a*a;
      }
      bool flag=false;
      for(int k=0;k<=sum;++k){
        if(k*k==sum) flag=true;
      }
      if(flag) ans++;
    }
  }
  cout<<ans<<endl;
}

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

typedef long long int ll;

int main()
{
    ll m1,m2,t;
    cin >> m1 >> t >> m2>> t;
    if(m1 != m2){
        cout << 1;
    }
    else{
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random

import os
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    
    ans = 0
    for i in range(1, N+1):
        if i % 2 == 1:
            ans += 1
            if ans >= K:
                print("YES")
                sys.exit()
                
    print("NO")
    
    
if __name__ == "__main__":
	main()


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

int main() {
  string s;
  cin >> s;
  string r = s;
  reverse(r.begin(), r.end());  
  int cnt = 0;
  for(int i = 0;i <= (int)s.length();i++){
    if(s[i] != r[i]){
      cnt++;
    }
  }
  cout << cnt / 2 << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int gcd(int a, int b){
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  if(K % 2){
    cout << B-A << endl;
  }
  else{
    cout << A-B << endl;
  }
  return 0;
}


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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n,m; cin >> n>> m;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i]; 
        a[i]--; b[i]--;
    }
    int res=0;
    vector<vector<int>> g(n);
    rep(i,m){
        g[a[i]].PB(b[i]);
        g[b[i]].PB(a[i]);
    }
    rep(v,n){
        bool can=true;
        for(int nv:g[v]){
            if(h[v]<=h[nv]) can=false;
        }
        if(can) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 11440
fun main(args:Array<String>) {
  val m = mutableMapOf<Int,Int>() 
  readLine()!!.split(" ").map(String::toInt).map { 
    if( m[it] == null ) m[it] = 0
    m[it] = m[it]!! + 1
  }
  m.toList().mapNotNull { 
    if( it.second == 1 ) it.first
    else null
  }.first().run(::println)
}

Measured memory_bytes: 36068
//93a.cpp
#include<iostream>
using namespace std;

int main(){
    char s[3];
    cin >> s;
    if(s[0]==s[1] || s[1] == s[2] || s[2] == s[0]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    FOR(i,1,n){
        int x = i;
        bool f = 0;
        if (x % 3 == 0) f = 1;
        while (x){
            if (x % 10 == 3) f = 1;
            x /= 10;
        }
        if (f) cout << " " << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3092
n=int(input())
ans={"b":0}
ma=0
pr=[]
for i in range(n):
    name=input()
    if name in ans.keys():
        ans[name]=ans[name]+1
    else:
        ans[name]=1
for j,k in ans.items():
    if k>ma:
        ma=k 
        pr=[j]
    elif k==ma:
        pr.append(j)
pr.sort()
for l in pr:
    print(l)

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

using namespace std;
using llint = long long;
using pint = pair<int,int>;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

const int INF = 1<<28;
const llint LLINF = 1LL<<60;

int n;
vector<int> a, x;

int main() {
    // Input
    cin >> n;
    a.resize(n);
    x.resize(n);
    llint sum=0;
    for (int i = 0; i < n; ++i) {
        cin >> a.at(i);
        sum+=a.at(i);
    }

    // Solve
    for (int i = n-2; i > 0; i = i-2) {
        sum -= a.at(i)*2;
    }

    x.at(0) = sum;

    for (int i = 1; i < n; ++i) {
        x.at(i) = a.at(i-1)*2 - x.at(i-1);
    }

    // Output
    for (int i = 0; i < n; ++i) {
        
        cout << x.at(i) << " ";
    }
    cout << endl;
    return 0;
}

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

using ll = long long;
const ll SIZE = 2e5+200;

int main() {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];

    ll curr = 1;

    for (auto x : arr) {
        if (x == curr) {
            curr++;
        }
    }

    if (curr == 1) {
        cout << -1 << endl;
    } else {
        cout << n-curr+1 << endl;
    }
}

Measured memory_bytes: 4840
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner sc= new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int area=a*b;
int length=(a+b)*2;
System.out.println(area +" "+ length);
sc.close();
}
}


Measured memory_bytes: 26056
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)

using namespace std;

bool check(vector<vector<char>> F, int h, int w) {
  if (F[h-1][w]=='#') return true;
  if (F[h][w-1]=='#') return true;
  if (F[h][w+1]=='#') return true;
  if (F[h+1][w]=='#') return true;
  else return false;
}

int main() {
  int H=0, W=0;
  cin >> H >> W;
  vector<vector<char>> F(H+2, vector<char>(W+2));
  rep(h, H+2){
    rep(w, W+2){
      F[h][w] = '.';
    }
  }
  rep(h, H){
    rep(w, W){
      cin >> F[h+1][w+1];
    }
  }

  bool flag = true;

  rep(h, H){
    rep(w, W){
      if (F[h+1][w+1] == '.') continue;
      else flag *= check(F, h+1, w+1);
    }
  }

  if (flag==true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  int n, l, r;
  int ans = 0;
  cin >> n;

  rep(i, n){
    cin >> l >> r;
    ans += r - l + 1;
  }

  cout << ans << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int D,N;

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

    int ans;
    int cnt=0;
    if(D==0) repn(i,2000000){
        if(i%100!=0) cnt++;
        if(cnt==N){
            ans=i;
            break;
        }
    }
    if(D==1) repn(i,2000000){
        if(i%100==0 && i%10000!=0 && i%1000000!=0) cnt++;
        if(cnt==N){
            ans=i;
            break;
        }
    }
    if(D==2) repn(i,2000000){
        if(i%10000==0 && i%1000000!=0) cnt++;
        if(cnt==N){
            ans=i;
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;
ll gcd( ll a, ll b )
{
	if(b==0)
	{
	     return a;
	}
	else
	{
	     return gcd( b, a%b );
	}
}

void solve()
{
	int k;
	cin>>k;
	ll sum=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			ll tp=gcd(i,j);
			for(int l=1;l<=k;l++)
			{
				sum+=gcd(tp,l);
			}
		}
	}
	cout<<sum;
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int b[210000];
long long sum[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	for(int i=0;i<a;i++){
		sum[i+1]=sum[i]+b[i]*2;
	}
	long long ret=inf;
	for(int i=2;i<=a-2;i++){
		long long M=(sum[i])/2;
		int Lat=lower_bound(sum,sum+a+1,M)-sum;
		M=(sum[a]+sum[i])/2;
		int Rat=lower_bound(sum,sum+a+1,M)-sum;
		for(int j=0;j<2;j++)for(int k=0;k<2;k++){
			int A1=Lat-j;
			int A2=Rat-k;
			if(0<A1&&A1<i&&i<A2&&A2<a){
				ret=min(ret,max(max(sum[A1],sum[i]-sum[A1]),max(sum[A2]-sum[i],sum[a]-sum[A2]))-min(min(sum[A1],sum[i]-sum[A1]),min(sum[A2]-sum[i],sum[a]-sum[A2])));
			}
		}
	}
	printf("%lld\n",ret/2);
}


Measured memory_bytes: 2560
H = int(input())

# monster HP is X
# X==1 >> X=0
# X>1  other 2 monster appear. These 2 mosters have [X/2] HP.
# No.i monster vitalitiy is Hi
# two actions
# attack : reduce 1 vitaility
# special: make vitality 0. Fenek can use K times of specials.
# print(type(2*10**14))

# from collections import deque
#
# print(f"H={H}")
#
# monsters = deque()
# monsters.append(H)
# attack = 0
#
# while monsters:
# # for _ in range(3):
#     hp = monsters.popleft()
#     # print(f"attack to monster(HP={hp})")
#     if hp != 1:
#         # print(f"new 2 monsters(HP={hp//2}) appears!")
#         hp_hp = hp//2
#         monsters.extend([hp_hp, hp_hp])
#         # print(monsters)
#     attack += 1

i = 1
while H > 1:
    H //= 2
    i += 1
# print(attack)
print(2**i - 1)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
const int Max = 1e6 + 5;
const int Mod = 1e9 + 7;

int n, a[Max], b[Max], cnt[Max], ans[Max];
int f[Max];

void KMP(int sh)
{
	for (int i = 1, j = 0; i < n; i++)
	{
		while (j && (b[i] & 1 << sh) != (b[j] & 1 << sh))
			j = f[j - 1];
		if ((b[i] & 1 << sh) == (b[j] & 1 << sh))
			j++;
		f[i] = j;
	}
	for (int i = 1, j = 0; i < 2 * n; i++)
	{
		while (j && (a[i] & 1 << sh) != (b[j] & 1 << sh))
			j = f[j - 1];
		if ((a[i] & 1 << sh) == (b[j] & 1 << sh))
			j++;
		if (j == n)
			cnt[i - n + 1]++, j = f[j - 1];
	}

	for (int i = 1, j = 0; i < 2 * n; i++)
	{
		while (j && (a[i] & 1 << sh) == (b[j] & 1 << sh))
			j = f[j - 1];
		if ((a[i] & 1 << sh) != (b[j] & 1 << sh))
			j++;
		if (j == n)
			cnt[i - n + 1]++, ans[i - n + 1] |= 1 << sh, j = f[j - 1];
	}
}

int main()
{
	GO;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], a[i + n] = a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int i = 0; i < 30; i++)
		KMP(i);
	set<pair<int, int>> st;
	for (int i = 0; i < 2*n; i++)
		if (cnt[i] == 30)
			st.insert({ i % n,ans[i] });
	for (auto i : st)
		cout << i.first << ' ' << i.second << '\n';
	return 0;
}

Measured memory_bytes: 30080
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, W int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &W)

	ws := make([]int, N+1)
	vs := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &ws[i], &vs[i])
	}

	var dp [][]int
	dp = make([][]int, N+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, W+1)
	}

	for w := 0; w < W+1; w++ {
		dp[0][w] = 0
	}
	for i := 1; i < N+1; i++ {
		for w := 0; w < W+1; w++ {
			if w-ws[i] >= 0 {
				dp[i][w] = max(
					dp[i-1][w],
					dp[i-1][w-ws[i]]+vs[i],
				)
			} else {
				dp[i][w] = dp[i-1][w]
			}
		}
	}

	fmt.Println(dp[N][W])
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 82560
/*
AtCoderBeginnerContest167
Problem C - Skill Up /
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 300 points
*/

#include <iostream>
#include <vector>

int N, M, X;
std::vector<int> C;
std::vector< std::vector<int> > A;

bool works(int i)
{
    std::vector<int> score (M, 0);
    int bit = 0;
    while (i>0)
    {
        if (i%2==1)
        {
            for (int j=0; j<M; j++)
            {
                score[j] += A[bit][j];
            }
        }
        bit++;
        i>>=1;
    }
    for (int j=0; j<M; j++)
    {
        //std::cout << "score[" << j << "] = " << score[j] << "\n";
        if (score[j] < X) return false;
    }
    return true;
}

int cost(int i)
{
    int res = 0;
    int bit = 0;
    while (i>0)
    {
        if (i%2==1)
        {
            res += C[bit];
        }
        bit++;
        i>>=1;
    }
    return res;
}

int main()
{
    std::cin >> N >> M >> X;
    for (int i=0; i<N; i++)
    {
        int currC;
        std::cin >> currC;
        C.push_back(currC);
        std::vector<int> newA;
        for (int j=0; j<M; j++)
        {
            int currA;
            std::cin >> currA;
            newA.push_back(currA);
        }
        A.push_back(newA);
    }
    /*
    for (int i=0; i<N; i++)
    {
        //std::cout << "C_" << i << " = " << C[i] << "\n";
        //std::cout << "A row " << i << ":"; for (int j=0; j<M; j++) { std::cout << " " << A[i][j]; } std::cout << "\n";
    }
    */
    int MAX = 1 << N;
    int best = -1;
    for (int i=0; i<MAX; i++)
    {
        if (works(i))
        {
            int curr = cost(i);
            //std::cout << "curr: " << curr << "\n";
            if (best == -1 || best > curr)
            {
                best = curr;
                //std::cout << "new best: " << best << "\n";
            }
        }
    }
    std::cout << best << "\n";
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int st[8] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};
int ansa[10][10];

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

    for (int i = 0; i < 10; ++i)
    {
        for (int j = 0; j < 10; ++j)
        {
            ansa[i][j] = 0;
        }
    }

    int stix = 0;
    int id1, id2;
    for (int i = 1; i <= n; ++i)
    {
        if (i >= st[stix]*10)
        {
            stix++;
        }

        id1 = i/st[stix];
        id2 = i%10;
        ansa[id1][id2]++;
    }

    uint64_t ans = 0;
    for (int d1 = 1; d1 <= 9; ++d1)
    {
        for (int d2 = 1; d2 <= 9; ++d2)
        {
            if (d1 == d2)
            {
                ans += ansa[d1][d2]*(ansa[d1][d2]-1)+ansa[d1][d2];
            }
            else
            {
                ans += ansa[d1][d2]*ansa[d2][d1];
            }
        }
    }

    cout << ans << "\n";
    return 0;
}


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

// 隣り合わないようにN/2個選択する時，結構ピチピチであるという観察
// i個目までの数字を交互に取る（偶数個目を取る）ことをベースにして，イレギュラーに数字をスキップするのは高々2回まで
// dp[i][j]: i個目までの数字を，イレギュラーに数字をj回スキップしつつ，交互に取るときの，選んだ数字の総和の最大値

const long long INF = 1e18;

long long dp[200005][4];

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int k = 1 + n%2; // イレギュラーに数字をスキップできる回数
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            dp[i][j] = -INF;
        }
    }
    dp[0][0] = 0; // 0個目までの数字を，イレギュラーに数字を0回スキップしつつ交互に取るとき，その総和は0
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]);
            long long now = dp[i][j];
            if ((i+j) % 2 == 0) {
                now += a[i];
            }
            dp[i+1][j] = max(dp[i+1][j], now);
        }
    }
    cout << dp[n][k] << endl;
    return 0;
}

Measured memory_bytes: 10380
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	char a[1010][1010];
	char b[3][3];
	char c[4][4];
	char d[5][5];
	char e[7][7];
	string str;
	str = ".aa";
	f(i, 3)b[0][i] = str[i];
	str = "b..";
	f(i, 3)b[1][i] = str[i];
	str = "b..";
	f(i, 3)b[2][i] = str[i];

	str = "abee";
	f(i, 4)c[0][i] = str[i];
	str = "abff";
	f(i, 4)c[1][i] = str[i];
	str = "ccgh";
	f(i, 4)c[2][i] = str[i];
	str = "ddgh";
	f(i, 4)c[3][i] = str[i];

	str = "ahhgg";
	f(i, 5)d[0][i] = str[i];
	str = "a.iif";
	f(i, 5)d[1][i] = str[i];
	str = "bj..f";
	f(i, 5)d[2][i] = str[i];
	str = "bj..e";
	f(i, 5)d[3][i] = str[i];
	str = "ccdde";
	f(i, 5)d[4][i] = str[i];

	str = ".aabbcc";
	f(i, 7)e[0][i] = str[i];
	str = "d.gg.hh";
	f(i, 7)e[1][i] = str[i];
	str = "di..j..";
	f(i, 7)e[2][i] = str[i];
	str = "ei..j..";
	f(i, 7)e[3][i] = str[i];
	str = "e.kk.ll";
	f(i, 7)e[4][i] = str[i];
	str = "fm..n..";
	f(i, 7)e[5][i] = str[i];
	str = "fm..n..";
	f(i, 7)e[6][i] = str[i];

	f(i, 1010) {
		f(j, 1010)a[i][j] = '.';
	}
	int n, k, x;
	scanf("%d", &n);
	if (n <= 2) {
		printf("-1\n");
		return 0;
	}
	if (n == 3) {
		f(i, 3) {
			f(j, 3)printf("%c", b[i][j]);
			printf("\n");
		}
		return 0;
	}
	if (n == 4) {
		f(i, 4) {
			f(j, 4)printf("%c", c[i][j]);
			printf("\n");
		}
		return 0;
	}
	if (n == 5) {
		f(i, 5) {
			f(j, 5)printf("%c", d[i][j]);
			printf("\n");
		}
		return 0;
	}
	if (n == 7) {
		f(i, 7) {
			f(j, 7)printf("%c", e[i][j]);
			printf("\n");
		}
		return 0;
	}
	if (n % 4 == 0) {
		f(i, n / 4) {
			f(ii, 4) {
				f(jj, 4) {
					a[(i * 4) + ii][(i * 4) + jj] = c[ii][jj];
				}
			}
		}


	}
	else if(n%4==1){
		k = (n - 5) / 4;
		f(i, k) {
			f(ii, 4) {
				f(jj, 4) {
					a[(i * 4) + ii][(i * 4) + jj] = c[ii][jj];
				}
			}
		}
		k = n - 5;
		f(i, 5) {
			f(j, 5) {
				a[k + i][k + j] = d[i][j];
			}
		}
	}
	else if (n % 4 == 2) {
		k = n / 2;
		f(i, k) {
			a[(2 * i)][(2 * i)] = 'a';
			a[(2 * i)][(2 * i)+1] = 'a';
			a[(2 * i)+1][(2 * i)] = 'b';
			a[(2 * i)+1][(2 * i)+1] = 'b';
			x = ((2 * i) + 2) % n;
			a[x][(2 * i)] = 'c';
			a[x][(2 * i) + 1] = 'd';
			x = ((2 * i) + 3) % n;
			a[x][(2 * i)] = 'c';
			a[x][(2 * i) + 1] = 'd';
		}
	}
	else {
		k = (n - 7) / 4;
		f(i, k) {
			f(ii, 4) {
				f(jj, 4) {
					a[(i * 4) + ii][(i * 4) + jj] = c[ii][jj];
				}
			}
		}
		k = n - 7;
		f(i, 7) {
			f(j, 7) {
				a[k + i][k + j] = e[i][j];
			}
		}
	}
	f(i, n) {
		f(j, n)printf("%c", a[i][j]);
		printf("\n");
	}


	return 0;
}


Measured memory_bytes: 2176
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,ans = 0;
    string S;
    cin >> N;
    cin >> S;

    rep(i, 1000){
        string key;
        rep(j, 3 - to_string(i).size()){
            key += '0';
        }
        key += to_string(i);

        int c = 0;
        rep(k, N){
            if(c >= 3){
                break;
            }
            if(S.at(k) == key.at(c)){
                c++;
            }
        }

        if(c == 3){
            ans++;
        }
    }

    cout << ans << endl;
}

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

signed main() {

  string s;
  cin >> s;

  auto it = s.rbegin();

  while (true) {

    bool flag = true;
    if (it + 5 > s.rend()) { flag = false; }

    if (!flag) {
      cout << "NO" << endl;
      return 0;
    }

    switch (*it) {
    case 'm':
      if (*(it + 1) == 'a' && *(it + 2) == 'e' && *(it + 3) == 'r' && *(it + 4) == 'd') {
        it += 5;
      } else {
        flag = false;
      }
      break;
    case 'e':
      if (*(it + 1) == 's' && *(it + 2) == 'a' && *(it + 3) == 'r' && *(it + 4) == 'e') {
        it += 5;
      } else {
        flag = false;
      }
      break;
    case 'r':
      if (*(it + 1) == 'e') {
        if (it + 6 > s.rend()) {
          flag = false;
        } else if (*(it + 2) == 's' && *(it + 3) == 'a' && *(it + 4) == 'r' && *(it + 5) == 'e') {
          it += 6;
        } else if (it + 7 > s.rend()) {
          flag = false;
        } else if (*(it + 2) == 'm' && *(it + 3) == 'a' && *(it + 4) == 'e' && *(it + 5) == 'r' && *(it + 6) == 'd') {
          it += 7;
        } else {
          flag = false;
        }
      } else {
        flag = false;
      }
      break;
    default: flag = false; break;
    }

    if (!flag) {
      cout << "NO" << endl;
      return 0;
    }
    if (it == s.rend()) {
      cout << "YES" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3732
n, m, x, y = map(int, input().split())
xmax = max(list(map(int, input().split()))) + 1
ymin = min(list(map(int, input().split())))
if ymin - xmax < 0:
  print('War')
  exit()
for i in range(xmax, ymin + 1):
  if x < i <= y:
    print('No War')
    exit()
print('War')

Measured memory_bytes: 80340
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] a;

    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        a = cin.ArrayInt(N);
    }
    static void solve()
    {
        input();
        int odd = a.Count(x => x % 2 == 1);
        int time4 = a.Count(x => x % 4 == 0);
        if (N - odd - time4 > 0)
            odd++;
        WriteLine(odd <= time4 + 1 ? "Yes" : "No");
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 22496
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, x, y := iScan(), iScan(), iScan()
	a, b, c := make([]int, n), make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
		b[i] = iScan()
		c[i] = iScan()
	}
	p, q := make(map[[2]int]int), make(map[[2]int]int)
	for i := 0; i < (1 << uint(n/2)); i++ {
		z := [2]int{0, 0}
		r := 0
		for j := 0; j < n/2; j++ {
			if (i>>uint(j))&1 == 1 {
				z[0] += a[j]
				z[1] += b[j]
				r += c[j]
			}
		}
		if _, ok := p[z]; ok {
			p[z] = smaller(p[z], r)
		} else {
			p[z] = r
		}
	}
	for i := 0; i < (1 << uint(n-n/2)); i++ {
		z := [2]int{0, 0}
		r := 0
		for j := 0; j < n-n/2; j++ {
			if (i>>uint(j))&1 == 1 {
				z[0] += a[j+n/2]
				z[1] += b[j+n/2]
				r += c[j+n/2]
			}
		}
		if _, ok := q[z]; ok {
			q[z] = smaller(q[z], r)
		} else {
			q[z] = r
		}
	}
	ans := mod
	cand := make([][2]int, 0, 400)
	for i := 1; i <= 400; i++ {
		if x*i <= 400 && y*i <= 400 {
			cand = append(cand, [2]int{x * i, y * i})
		}
	}
	for k, v := range p {
		for _, w := range cand {
			d := [2]int{w[0] - k[0], w[1] - k[1]}
			if _, ok := q[d]; ok {
				ans = smaller(ans, v+q[d])
			}
		}
	}
	if ans == mod {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 2832
#include <iostream>
  using namespace std;
  #include <math.h>

  int main(){
    long long X, out = 1;
    int mod = pow(10,9) + 7;
    cin >> X;
    for(int i = 1; i<=X; ++i){
      out = (i * out) % mod;
    }
     cout << out << endl;
  }

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        double t,x; cin>>t>>x;
        cout<<t/x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
#include <iostream>
ll gcd(ll a, ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d; cin>>a>>b>>c>>d;
  ll C=b/c-(a-1)/c;
  ll D=b/d-(a-1)/d;
  ll cd=c/gcd(c,d)*d;
  ll CD=b/cd-(a-1)/cd;
  cout<<b-a+1-C+-D+CD<<endl;
}

Measured memory_bytes: 256
import math

a, b = map(int, input().split())

xa = math.ceil(a / 0.08)
xb = math.ceil(b / 0.10)
if xa >= xb:
    xmin = xa
else:
    xmin = xb

ya = math.ceil((a + 1) / 0.08)
yb = math.ceil((b + 1) / 0.10)
if ya <= yb:
    xmax = ya
else:
    xmax = yb

if xmax <= xmin:
    print(-1)
else:
    print(xmin)


# a <= x * 0.08 < a + 1
# b <= x * 0.10 < b + 1

# a / 0.08 <= x < (a + 1) / 0.08
# b / 0.10 <= x < (b + 1) / 0.10


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

int main()
{
  int a, b, Result;
  char op;

  while(1)
    {
      cin >> a >> op >> b;
      if(op =='+')
	{
	  Result = a+b;
	}
      else if(op == '-')
	{
	  Result = a-b;
	}
      else if(op == '*' )
	{
	  Result = a*b;
	}
      else if(op == '/')
	{
	  Result = a/b;
	}
      else if(op == '?')
	{
	  break;
	}

      cout << Result << endl;
    }
  return 0;
}

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

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  int ans = 0;
  for(int i = 0;i < m;i++){
    cin >> b[i];
  }
  int a[n][m];
  for(int i = 0;i < n;i++){
    for(int j = 0;j < m;j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0;i < n;i++){
    int kari = 0;
    for(int j = 0;j < m;j++){
      kari += b[j]*a[i][j];
    }
    kari += c;
    if(kari > 0){
      ans++;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>


int main(){
    int N,i,j,num[1001],v,x;
    
    scanf("%d",&N);
    for (i=0; i<N; i++) {
        scanf("%d",&num[i]);
    }
    
    for (x=0; x<N-1;x++) {
      printf("%d ",num[x]);
     }
    printf("%d\n",num[N-1]);
    for (i=1; i<N; i++) {
        v=num[i];
        j=i-1;
        while (j>=0 && num[j]>v) {
            num[j+1]=num[j];
            j--;
        }
        
        num[j+1]=v;
        for (x=0; x<N-1;x++) {
          printf("%d ",num[x]);
        }
         printf("%d\n",num[N-1]);

    }
    
    return(0);
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10)
        cout << a * b << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define debug(x) {cerr<<#x<<" = "<<(x)<<endl;}
#define M(x) memset(x,0,sizeof(x))
#define dalao main
#define MOD 1000000007
using namespace std;
inline ll ksc(ll x,ll y,ll p)
{//计算x乘y的积，对p取模
    ll res=0;//加法初始化
    while(y){
        if(y&1)res=(res+x)%p;//模仿二进制
        x=(x<<1)%p; y>>=1;//将x不断乘2达到二进制
    }return res;
};
ll a[200005],pro=0,qzh[200005];
int dalao()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;

    qzh[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        qzh[i] = (qzh[i-1]+a[i]) % MOD;
    }
    for(int i=n;i>=2;i--)
    {
        ll temp = ksc(a[i],qzh[i-1],MOD);
        pro = (pro+temp) % MOD;
    }
    cout<<pro%MOD;
    return 0;
}


Measured memory_bytes: 6768
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100010
using namespace std;
struct edge{int x, y, next;}a[N*2];
int n, l, p[N], sg[N], x, y, ans;
inline void add(int x, int y){a[++l].x=x; a[l].y=y; a[l].next=p[x]; p[x]=l;}
inline void dfs(int x, int fa){
	sg[x]=0;
	for(int i=p[x]; i; i=a[i].next)if(fa!=a[i].y){dfs(a[i].y, x); sg[x]^=sg[a[i].y];}
	sg[x]++;
}
int main(){
	scanf("%d", &n);
	l=0; memset(p, 0, sizeof(p));
	for(int i=1; i<=n-1; i++){scanf("%d%d", &x, &y); add(x, y); add(y, x);}
	ans=0;
	for(int i=p[1]; i; i=a[i].next){dfs(a[i].y, 1); ans^=sg[a[i].y];}
	if(ans)printf("Alice"); else printf("Bob");
	return 0;
}

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

int main(){
  long long H;
  cin >> H;
  
  long long i = 0LL;
  long long ans = 0LL;
  while (H>0){
    ans += pow(2LL, i++);
    H /= 2LL;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(in) in.begin(), in.end()

int main(){
    FIO;
    ll n;   cin >> n;   n = n * n * n;  cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll i,j,n,m,k,l,r,a,b,c=0,d=0,e,g,p,q,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n >> k;
    vector<ll> V(n);
    for(i=0;i<k;i++)
    {
        cin >> d;
        for(j=0;j<d;j++)
        {
            cin >> u ; V[u-1]++;
        }
    }
    for(i=0;i<n;i++)
    {
        if(V[i]==0) c++;
    }
    cout << c;
}
    return 0;
}

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

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 3648
from sys import stdin
r = stdin.readline

def is_palin(t):
    ans, n = True, len(t)
    for i in range((n//2)+1):
        if t[i]!=t[n-i-1]: ans=False; break
    return ans

def main():
    t = r().strip()
    n = len(t)
    print("Yes" if is_palin(t) and is_palin(t[:((n-1)//2)]) and is_palin(t[(n+2)//2:]) else "No") 

main()

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

vector<int> EMP(5, 0), FULL(5, 1);

class TETORIS {
public:
	int N;
	vector<vector<int> > bd;
	TETORIS() : N(0) {}
	void put(int len, int pos) {
		int k = bd.size()-1;
		for (; k>=0; --k) {
			for (int i=0; i<len; ++i) {
				if (bd[k][pos+i]) goto brk;
			}
		} brk:;
		++k;
		if (bd.size() == k) bd.push_back(EMP);
		for (int i=0; i<len; ++i) {
			bd[k][pos+i] = 1;
		}
		N += len;
	}
	void update() {
		for (int i=bd.size()-1; i>=0; --i) {
			if (bd[i] == FULL) {
				bd.erase(bd.begin()+i);
				N -= 5;
			}
		}
	}
};

int main() {
	int n, d, p, q;
	while (cin >> n, n) {
		TETORIS tet;
		for (int i=0; i<n; ++i) {
			cin >> d >> p >> q;
			if (d == 1) {
				tet.put(p, q-1);
				tet.update();
			} else {
				for (int j=0; j<p; ++j) tet.put(1, q-1);
				tet.update();
			}
		}
		cout << tet.N << endl;
	}
	return 0;
}

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

int main() {
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) {
		cin >> a[i];
		a[i]--;
	}
	if (k<=2LL*n) {
		ll town = 0;
		rep(i,k) town = a[town];
		cout << town+1LL << endl;
	}
	else {
		vector<bool> visited(n,false);
		visited[0] = true;
		bool b_loop = false;
		ll cnt_b_loop = 0LL;  // ループ開始までの移動数
		ll town = 0LL;
		while(!b_loop) {
			town = a[town];
			if (visited[town]) b_loop = true;
			else visited[town] = true;
			cnt_b_loop++;
		}
		ll town_b_loop = town;  // ループの始点
		//printf("cnt_b_loop:%lld\ntown_b_loop:%d\n",cnt_b_loop, town_b_loop);
		ll size_loop = 0LL;  // ループの大きさ
		rep(i,n) visited[i] = false;  // visitedをリセット
		while(1) {
			town = a[town];
			size_loop++;
			if (town == town_b_loop) break;
		}
		k = (k-cnt_b_loop) % size_loop;
		//k = (k % size_loop) + 2LL * size_loop;
		town = town_b_loop;
		rep(i,k) town = a[town];
		cout << town+1LL << endl;
	}

	return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using Pii = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define _GLIBCXX_DEBUG
 
constexpr int MOD = 1000000007;
const int INF = 1 << 30;
 
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }


// 各操作を行う関数を実装する
 
// AとBに共通して含まれる要素からなる集合を返す
int main(){
 int a,b,c;
  cin >>a>> b>>c;
  int sum=0;
  for(int i = a ; b>=i;i++){
    if(i%c==0){
      sum++;
    }
  }
  cout << sum;
  
  
}

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

#define MOD 1000000007
#define lli long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = n - 1; ~i; i--)
#define pb push_back
#define mkp make_pair
#define endl "\n"

using namespace std;

bool enable_test_case = false;
bool enable_google = false;

void solve()
{
    int r, c;
    cin >> r >> c;
    string a[r];

    rep(i, r)
    {
        cin >> a[i];
    }

    vector<vector<lli>> dp(r, vector<lli>(c, 0));

    bool stop = false;
    for (int i = 1; i < c; i++)
    {
        if (stop)
        {
            dp[0][i] = 0;
        }
        else
        {
            if (a[0][i] != '#')
            {
                dp[0][i] = 1;
            }
            else
            {
                dp[0][i] = 0;
                stop = true;
            }
        }
    }

    stop = false;
    for (int i = 1; i < r; i++)
    {
        if (stop)
        {
            dp[i][0] = 0;
        }
        else
        {
            if (a[i][0] != '#')
            {
                dp[i][0] = 1;
            }
            else
            {
                dp[i][0] = 0;
                stop = true;
            }
        }
    }

    for (int i = 1; i < r; i++)
    {
        for (int j = 1; j < c; j++)
        {
            if (a[i][j] == '#')
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
    }
    cout << dp[r - 1][c - 1] << endl;
}

void google_contests(int t)
{
    cout << "Case #" << t + 1 << ": ";
}

void test_case()
{
    if (enable_test_case)
    {
        lli t;
        cin >> t;
        rep(i, t)
        {
            if (enable_google)
                google_contests(i);
            solve();
        }
    }
    else
    {
        solve();
    }
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    test_case();

    return 0;
}


Measured memory_bytes: 12128
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000001), 1000000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	t := getNextString(scanner)
	p := getNextString(scanner)
	mp := MP{}
	mp.init(p)
	n := len(t)
	pn := len(p)
	pi := 0
	for i := 0; i <= n; i++ {
		if pi == pn {
			fmt.Fprintln(writer, i-pn)
			pi = mp.table[pi]
		}
		if i == n {
			break
		}
		if t[i] != p[pi] {
			for pi >= 0 && t[i] != p[pi] {
				pi = mp.table[pi]
			}
		}
		pi++
	}

	writer.Flush()
}

// MP ...
type MP struct {
	s     string
	table []int
}

func (mp *MP) init(s string) {
	mp.s = s
	n := len(s)
	table := make([]int, n+1)
	table[0] = -1
	j := -1
	for i := 0; i < n; i++ {
		for j >= 0 && s[i] != s[j] {
			j = table[j]
		}
		j++
		table[i+1] = j
	}
	mp.table = table
}



Measured memory_bytes: 6004
// Bismillahirrahmanirrahim
// by Batrrr Tolkynbayev
#include <bits/stdc++.h>
// skripi krasava
#define respa return 0
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5 + 17, M = N << 2, mod = 1e9 + 7; 

int tt = 1, n;
ll res, bal, a[N], b[N], d[N];

void solve () {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
		d[i] = (a[i] + b[i] - 1) / b[i] * b[i] - a[i];
	}
	for (int i = n; i >= 1; --i) {
		if (d[i] < d[i + 1]) d[i] += ((d[i + 1] - d[i] + b[i] - 1) / b[i]) * b[i];
	}
	for (int i = n; i >= 1; --i) {
		d[i] -= bal;
		res += d[i];
		bal += d[i];
	}
	cout << res;
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin >> tt;
	while (tt--) solve();
	respa;
}

Measured memory_bytes: 5988
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


N = I()
A = LMI()

d = dict()
for a in A:
    if d.get(a) is None:
        d[a] = 1
    else:
        print('NO')
        exit(0)
print('YES')

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

int main() {
  int n; cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s; cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto p : mp)
    ans += (ll)p.second * (p.second - 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
N = int(input())
dp = [0]*(100000+1)
dp[100] = 1
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1
for i in range(200, N+1):
    if dp[i-100]==1 or dp[i-101]==1 or dp[i-102]==1 or dp[i-103]==1 or dp[i-104]==1  or dp[i-105]==1:
        dp[i]=1
print(dp[N])
    

Measured memory_bytes: 39536
import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  if ans[0] not in p:
    print(ans[0])
    exit()
  if ans[1] not in p:
    print(ans[1])
    exit()
  ans+=[-1,1]
    


Measured memory_bytes: 27220
#include <bits/stdc++.h>
using namespace std;
int n,ans;
char s[60];
int main () {
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n-2;i++) {
		if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {ans++;} 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256