akhauriyash/Code-Regression huggingface dataset:
N = int(input())
src = [map(int,input().split()) for i in range(N)]

days_normal = (20+19)*5
days_special = 20*10
days_3years = 2*days_normal + days_special

def passed(y,m,d):
    ret = ((y-1)//3) * days_3years
    ret += ((y-1)%3) * days_normal
    for i in range(m-1):
        ret += (20 if y%3 == 0 or i%2 == 0 else 19)
    ret += d
    return ret

for i in range(N):
    y,m,d = src[i]
    print(passed(1000,1,1) - passed(y,m,d))

Measured memory_bytes: 5640
#include <iostream>

using namespace std;

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

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

  double ans = 0;
  for(int i = 0; i < n; i++) ans += 1.0 / a[i];

  cout << 1.0 / ans << endl;
}


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



int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    int count=0;

    if(a>b){
        count += b;
    }else{
        count += a;
    }
    if(c>d){
        count +=d;
    }else{
        count +=c;
    }
    
    cout<<count<<endl;

}


Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 4000 + 10;
const ll MOD = 998244353;
const ll INF = 1000000010;
const ll LOG = 25;

int n, k, nCr[N][N], tav[N];
int add(int a, int b){
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int mul(int a, int b){
	return (a * 1ll * b) % MOD;
}

inline void pre(){
	tav[0] = 1;
	for (int i = 1; i < N; i++) tav[i] = tav[i - 1] * 1ll * 2 % MOD;
	for (int i = 0; i < N; i++){
		for (int j = 0; j <= i; j++){
			nCr[i][j] = (j == 0?1:add(nCr[i - 1][j - 1], nCr[i - 1][j]));
		}
	}
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	pre();
	cin >> k >> n;
//	cout << nCr[6][3] << '\n';
	for (int i = 2; i <= 2 * k; i++){
		int ans = 0;
		int cnt = (min(k, i - 1) - (i - min(k, i - 1)) + 1);
		int res = k - cnt;
		cnt /= 2;
//		cout << cnt << ' ' << res << '\n';
		for (int j = 0; j <= cnt; j++){
			int x = mul(tav[j], nCr[cnt][j]);
			ans = add(ans, mul(x, nCr[n + res - 1][j + res - 1]));
		}
//		cout << ans << '\n';
		if(i % 2 == 0){
			n--;
			for (int j = 0; j <= cnt; j++){
				int x = mul(tav[j], nCr[cnt][j]);
				ans = add(ans, mul(x, nCr[n + res - 1][j + res - 1]));
			}
			n++;
		}
		cout << ans << '\n';
	}











	return 0;
}


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

long sum(int n){
	return (long)n*(n+1)/2;
}

int main(){
	int n;
	scanf("%d", &n);
	printf("%ld\n", sum(n) - sum(n/3)*3 - sum(n/5)*5 + sum(n/15)*15);
}


Measured memory_bytes: 3792
#include <iostream>

int main()
{
	int m, f, r;
	std::cin >> m >> f >> r;

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

Measured memory_bytes: 1156
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    char a[100];
    int f[4]={0};
    cin>>a;
    for(int i=0;i<strlen(a);i++)
    {
        f[a[i]-'a']=1;
    }
    int sum=0;
    for(int i=0;i<3;i++)
    {
        sum+=f[i];
    }
    if(sum==3)cout<<"Yes\n";
    else cout<<"No\n";
   return 0;
}


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

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n+1, 0);
    for(int i = 1; i <= n; i ++){
        int input; cin >> input;
        a[i] = input;
    }
    int counter = 0;

    for(int i = 1; i <= n; i++){
        if(i == a[a[i]]) counter++;
    }

    cout << counter/2 << endl;
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N,K; cin >> N >> K;
    ll ans = (N/K) * (N/K) * (N/K);
    if(K%2 == 0) ans += ((N+K/2)/K) * ((N+K/2)/K) * ((N+K/2)/K);
    cout << ans << endl;
    return 0;
}

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

int main() {
int  N,x;
    cin >> N >> x ;
  int A[N];
  for (int i=0; i<N; i++){
  cin >> A[i];
  }
  
  sort (A,A+N);
  int count =0;
  long long  sum =0;
    for (int i=0;i<N;i++)  sum +=A[i];
 if(sum<x)   count --;

  for (int i=0; i<N; i++){
   if (x>=A[i]){
    x-=A[i];
     count ++;
   }
    else break;
  }

  cout << count << endl;  
}
  


Measured memory_bytes: 256
from collections import*
from bisect import*
s=input()
n=len(s)
t=input()
d=defaultdict(list)
for i,c in enumerate(s):
    d[c].append(i)
m=-1
o=0
for c in t:
    if not d[c]:
        print(-1)
        exit()
    i=bisect(d[c],m)
    if len(d[c])==i:
        o+=1
        m=d[c][0]
    else:
        m=d[c][i]
print(o*n+m+1)

Measured memory_bytes: 7924
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

card = [[0, 0, 0],
              [0, 0, 0],
              [0, 0, 0]]
bingo  = False

# 穴あけ
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            card[i][j] = 1

# ビンゴ！？
# 縦横１列
for i in range(3):
    if sum(card[i])==3:
        bingo = True
        break
    if (card[0][i]+card[1][i]+card[2][i])==3:
        bingo = True
        break

# 斜め
if ~bingo and card[1][1]==1:
    if card[0][0] == 1 and card[2][2]==1:
        bingo = True
    if card[0][2] == 1 and card[2][0]==1:
        bingo = True
if bingo:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<vector>
#include<memory>
#include<iterator>

int main() {
  using namespace std;

  auto n = 0;
  cin >> n;

  vector<int> balls;
  multimap<int, int> mballs;
  for(int i = 0; i < n; i++)
  {
    int num = 0;
    cin >> num;
    balls.push_back(num);
    mballs.emplace(num, i);
  }

  unordered_set<int> uniqueBalls(balls.begin(),balls.end());
  if (n == uniqueBalls.size()) {
    for (int i = 0; i < n; i++) 
    {
      cout << 0 << endl;
    }
    return 0;
  }

  // value, count
  unordered_map<int, int> countBalls;
  long long cxcm1A = 0;
  for (const auto &b : uniqueBalls)
  {
    const auto c = mballs.count(b);
    countBalls.emplace(b, c);
    cxcm1A += c * (c - 1);
    mballs.erase(b);
  }

  for(int i = 0; i < n; i++)
  {
    const int kCount = countBalls.at(balls[i]);
    const long long && count = cxcm1A - 2 * (kCount - 1);
    cout << count / 2 << endl;
  }
}

Measured memory_bytes: 20376
def solve():
    s = input()
    ans = 0
    x = 0 #どこまで完成しているか
    a = 0 #連続するAの数
    n = len(s)
    for i in range(n):
        c = s[i]
        if x == 0:
            if c == 'A':
                x = 1
                a = 1
            continue
        if x == 1:
            if c == 'A':
                a += 1
            if c == 'B':
                x = 2
            if c == 'C':
                x = 0
                a = 0
            continue
        if x == 2:
            if c == 'A':
                x = 1
                a = 1
            if c == 'B':
                x = 0
                a = 0
            if c == 'C':
                x = 1
                ans += a
    return ans
print(solve())

Measured memory_bytes: 41692
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]



# Nの素因数分解を辞書で返す
def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    A = NLI()
    L = {}
    primes_a = {}
    for a in A:
        prime_a = prime_fact(a)
        primes_a[a] = prime_a
        for p, n in prime_a.items():
            L.setdefault(p, 0)
            L[p] = max(L[p], n)
    ans = 0
    l = 1
    for p, n in L.items():
        l = l * pow(p, n, MOD) % MOD

    for i, a in enumerate(A):
        ans += l * pow(a, MOD-2, MOD) % MOD
    print(ans % MOD)



if __name__ == "__main__":
    main()

Measured memory_bytes: 77720
import java.util.Scanner;
public class Main {
	public static int[] qlist;

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		char[] k = sc.next().toCharArray();
		int n = 0;
		int bcnt = 0;
		long c = 0;
		while(n < k.length - 1) {
			if(k[n] == 'B') {
				bcnt++;
			}
			else if(k[n] == 'W') {
				bcnt = 0;
			}
			if(k[n] == 'B' && k[n + 1] == 'W') {
				k[n] = 'W';
				k[n + 1] = 'B';
				c += bcnt;
				if(bcnt >= 2) {
					bcnt --;
				}
				else {
					bcnt = 0;
				}
			}
			n++;
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 27844
import math

n, d = (int(_) for _ in input().split())

xlist=[]

for i in range(n):
    xlist.append(list(map(int, input().split())))

kotae=0

for i in range(n):
    for j in range(n-i-1):
        a=i
        b=i+j+1
        kyori=0
        for k in range(d):
            kyori+=(xlist[a][k]-xlist[b][k])**2
        kyori2=math.sqrt(kyori)
        if kyori2==int(kyori2):
            kotae+=1

print(kotae)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
int N, W;
int w[110], v[110];
ll dp[110][100010];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 100010; j++) dp[i][j] = INF; 
    }

    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 100010; j++) {
            if (j < v[i]) {
                dp[i+1][j] = dp[i][j];
            } else {
                dp[i+1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }
    ll ans = 0;
    for (int j = 0; j < 100010; j++) {
        if (dp[N][j] <= W) ans = j;
    }
    cout << ans << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  if(n==1) {
    pr("Yes");
    pr(2);
    pr(1,1);
    pr(1,1);
    return;
  }
  ll m=-1;
  REP(i,2,1000) {
    if(i*(i+1)==n*2) {
      m=i;
      break;
    }
  }
  if(m==-1) {
    pr("No");
    return;
  }
  pr("Yes");
  pr(m+1);
  int a[m+1][m];
  int k=1;
  rep(i,m) {
    REP(j,i,m) {
      a[i][j]=k;
      a[j+1][i]=k;
      k++;
    }
  }
  rep(i,m+1) {
    cout << m << " ";
    PR(a[i],m);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

vector<ll> fact(100100,1),refact(100100,1);

ll mypow(ll n,ll r){
  ll res = 1;
  while(r){
    if(r & 1)res = res*n%MOD;
    n = n*n%MOD;
    r >>= 1;
  }
  return res;
}
ll comb(ll n,ll r){return n >= r ? (((fact[n]*refact[r])%MOD)*refact[n-r])%MOD : 0;}

int main(){

  rep(i,100000)fact[i+1] = fact[i]*(i+1)%MOD;
  refact[100000] = mypow(fact[100000],MOD-2);
  for(int i = 99999;i > 0;i--)refact[i] = refact[i+1]*(i+1)%MOD;

  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(ALL(a));
  ll res = 0;
  rep(i,n)(res += comb(i,k-1)*a[i]%MOD)%MOD;
  for(int i = n-1;i >= 0;i--)res = (res+MOD-(comb(n-i-1,k-1)*a[i]%MOD))%MOD;
  cout << res << endl;




  return 0;
}


Measured memory_bytes: 2560
import collections
n = int(input())
all_list_str = input()

# n = 4
# all_list_str = "3 1 3 2"

# n = 6
# all_list_str = "105 119 105 119 105 119"

# # n = 4
# # all_list_str = "1 1 1 1"

all_list = list(map(int, all_list_str.split()))

odd_list = [all_list[i] for i in range(1, n, 2)]
even_list = [all_list[i] for i in range(0, n - 1, 2)]

c = collections.Counter(odd_list)
c_odd_list = c.most_common()

c = collections.Counter(even_list)
c_even_list = c.most_common()

if (c_odd_list[0][0] != c_even_list[0][0]):
    odd_target = c_odd_list[0][0]
    even_target = c_even_list[0][0]
elif (c_odd_list[0][1] > c_even_list[0][1]):
    odd_target = c_odd_list[0][0]
    even_target = c_even_list[1][0]
elif (c_odd_list[0][1] < c_even_list[0][1]):
    odd_target = c_odd_list[1][0]
    even_target = c_even_list[0][0]
else:
    if (len(c_odd_list) == 1 and len(c_even_list) == 1):
        odd_target = c_odd_list[0][0]
        even_target = odd_target + 1    #Set dummy num
    elif (len(c_odd_list) == 1):
        odd_target = c_odd_list[0][0]
        even_target = c_even_list[1][0]
    elif (len(c_even_list) == 1):
        odd_target = c_odd_list[1][0]
        even_target = c_even_list[0][0]
    elif (c_odd_list[1][1] > c_even_list[1][1]):
        odd_target = c_odd_list[1][0]
        even_target = c_even_list[0][0]
    else:
        odd_target = c_odd_list[0][0]
        even_target = c_even_list[1][0]

print(str(len(odd_list) - odd_list.count(odd_target) + len(even_list) - even_list.count(even_target)))

Measured memory_bytes: 21536
n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  if k == 0:
    return 0
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  else:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))



Measured memory_bytes: 3064
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=MI()
edge=[]
for i in range(m):
    edge.append(LI())
u=UnionFind(n)
count=0
for i in range(m):
    u=UnionFind(n)
    for j in range(m):
        if i==j:
            continue
        else:
            u.union(edge[j][0]-1,edge[j][1]-1)
    if u.group_count()>1:
        count+=1
print(count)

Measured memory_bytes: 40944
N, M = map(int, input().split())
print(2**M * (1900*M + (N-M)*100))

# ある事象が起こる確率をpとすると、起こらない確率は(1-p)
# N回目に初めてACする確率は、(1-p)^(k-1) * p
# よって期待値は lim{n→∞}Σ{k=1からnまで}のk*(1-p)^(k-1)*p
# 有限和の部分をとると、
# Sn = 1*p + 2(1-p)p + ・・・ + n(1-p)^(n-1)p
# 等差数列×等比数列の形なので、公比である(1-p)を和に掛けたものを引く
# (1-p)Sn =  1(1-p)p + ・・・ + (n-1)(1-p)^(n-1)p + n(1-p)^n*p
# Snと(1-p)Snとで辺々差し引くと、
# pSn = p + (1-p)p + (1-p)^2*p ・・・ (1-p)^(n-1)p - n(1-p)^n*p
# 両辺pで割って、
# Sn = { 1 + (1-p) + (1-p)^2 + ・・・ + (1-p)^(n-1) } - n(1-p)^n
#　ここで中かっこの中身は、初項1,公比(1-p)の等比数列になっているので、等比数列の和の公式より、
# Sn = 1*{1-(1-p)^n} / {1 - (1-p)}  - n(1-p)^n
# ここでn→∞とすると、(1-p) < 1 より、　1/pが得られる。
# よって、確率pで起こるある事象が起こるまで繰り返したとき、その繰り返しの回数の期待値は、1/pとなる。
# 今回の場合、すべてのテストケースで正解する確率は、(1/2)**Mなので、逆数をとって2**M回となる。

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main()
{
  int r;
  cin >> r;
  cout << r * r << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;


int main()
{

	string s; cin >> s;

	if (s == "SUN")
		cout << 7;
	if (s == "MON")
		cout << 6;
	if (s == "TUE")
		cout << 5;
	if (s == "WED")
		cout << 4;
	if (s == "THU")
		cout << 3;
	if (s == "FRI")
		cout << 2;
	if (s == "SAT")
		cout << 1;

	return 0;

}

Measured memory_bytes: 3608
N = int(input())
A = list(map(int, input().split()))
print(*A)
for i in range(1, N):
	v = A[i]
	j = i -1
	while j >= 0 and A[j] > v:
		A[j+1] = A[j]
		j -= 1
	A[j+1] = v
	print(*A)

Measured memory_bytes: 8016
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define MAX 100010
using namespace std;

int main()
{
  int n,a[MAX],b,c,suma[MAX];

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

  pair<int,int> tmp(0,0);
  for(int i=0;i<n-1;i++)tmp=max(tmp,mp(a[i]+a[i+1],i));

  vector<int> ans;
  for(int i=tmp.s;i<n-1;i++)ans.push_back(i);
  for(int i=tmp.s-1;0<=i;i--)ans.push_back(i);

  if(b<=tmp.f){
    cout<<"Possible"<<endl;
    reverse(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++)cout<<ans[i]+1<<endl;
  }
  else cout<<"Impossible"<<endl;
  return 0;
}


Measured memory_bytes: 1784
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

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

const int kMaxN = 200;

int n, ans = 100000000;
int a[kMaxN];

int main() {
  cin >> n;
  REP(i, n) {
    int tmp;
    cin >> tmp;
    int cnt = 0;
    while (tmp % 2 != 1) {
      tmp /= 2;
      ++cnt;
    }
    ans = min(ans, cnt);
  }

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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 


		signed main()
		{
			int a,b;
			cin>>a>>b;
			cout<<a*b;
		}

Measured memory_bytes: 3640
using System;
class Program
{
    static void Main ()
    {
        var input = Console.ReadLine ().Split (' ');
        var a = int.Parse (input[0]);
        var b = int.Parse (input[1]);
        if(a < b * 2)
        {
    	    Console.WriteLine (0);
        }
        else
        {
            Console.WriteLine (a - b * 2);
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int w,n,x,y;
        w=sc.nextInt();
        n=sc.nextInt();
        int[] values=new int[w];
        int i;
        for(i=0;i<values.length;i++){
            values[i]=i+1;
        }
        for(i=0;i<n;i++){
            String str = sc.next();
             String[] ab = str.split(",");
              int a = Integer.parseInt(ab[0]) - 1;
              int b = Integer.parseInt(ab[1]) - 1;
              int tmp;
              tmp=values[a];
              values[a]=values[b];
              values[b]=tmp;
        }
        int j;
        for(j=0;j<w;j++){
            System.out.println(values[j]);
        }
    }
}


Measured memory_bytes: 25988
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
char cc[9];

int in(char c[]){
	int i,n,a=1,sum=0;
	n=strlen(c);
	for(i=0;i<n;i++){
		if(c[i]=='m'){
			sum+=a*1000;a=1;
		}else if(c[i]=='c'){
			sum+=a*100;a=1;
		}else if(c[i]=='x'){
			sum+=a*10;a=1;
		}else if(c[i]=='i'){
			sum+=a;a=1;
		}else{
			a=(int)(c[i]-'0');
		}
	}
	return sum;
}
void out(int c,char *cc){
	int i=0;
	if(c>=1000){
		if(c/1000==1){
			cc[i]='m';i++;c-=1000;
		}else{
			cc[i]=(char)((c/1000)+'0');i++;
			cc[i]='m';i++;
			c-=1000*(int)(cc[i-2]-'0');
		}
	}
	if(c>=100){
		if(c/100==1){
			cc[i]='c';i++;c-=100;
		}else{
			cc[i]=(char)((c/100)+'0');i++;
			cc[i]='c';i++;c-=100*(int)(cc[i-2]-'0');
		}
	}if(c>=10){
		if(c/10==1){
			cc[i]='x';i++;c-=10;
		}else{
			cc[i]=(char)((c/10)+'0');i++;
			cc[i]='x';i++;c-=10*(int)(cc[i-2]-'0');
		}
	}if(c>=1){
		if(c==1){
			cc[i]='i';
		}else{
			cc[i]=(char)(c+'0');i++;
			cc[i]='i';
		}
	}
	cout<<cc<<endl;
}
int main(){//AOJ1137
	int n,i;
	cin>>n;
	for(i=0;i<n;i++){
		int a,b,c,j;
		char ca[9],cb[9];
		for(j=0;j<9;j++){cc[j]='\0';}
		cin>>ca>>cb;
		a=in(ca);
		b=in(cb);
		c=a+b;
		out(c,cc);
	}
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
ll h,w,a,b;
//// 階乗(mod p)

Vector fact(10000000);
void mod_fact(ll n,ll p){
  fact[0]=1;
  for(ll i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%p;
}
//// 冪乗(mod p)
//// xの逆元 mod_pow(x,p-2,p)
ll mod_pow(ll x,ll n,ll p){
  ll res=1;
  while(n>0){
    if(n&1)res=res*x%p;
    x=x*x%p;
    n>>=1;
  }
  return res;
}

//// コンビネーション(mod p)
ll mod_comb(ll n,ll k,ll p){
  if(n<0||k<0||n<k)return 0;
  return ((fact[n]*mod_pow(fact[k],p-2,p))%p)*mod_pow(fact[n-k],p-2,p)%p;
}

int main(){
  cin.sync_with_stdio(false);
  cin >> h >> w >> a >> b;
  ll ans = 0;
  mod_fact(1000000,MOD);
  rep(i,min(h - a, w - b)){
    ans += mod_comb(h - a + b - 1, b + i,MOD) * mod_comb(w - b + a - 1, a + i,MOD);
    ans %= MOD;
  }
  cout << ans << endl;
}


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

int gcd(int i,int j,int k){
  
  if(i<j) swap(i,j);
  while(j!=0){
    int x=i%j;
    i=j;
    j=x;
  }
  
  if(i<k) swap(i,k);
  while(k!=0){
    int x=i%k;
    i=k;
    k=x;
  }
  
  return i;
}

int main() {
  int k;
  cin >> k;
  
  int ans=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int h=1;h<=k;h++){
        ans+=gcd(i,j,h);
      }
    }
  }
  
  cout << ans << endl;
}

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

signed main(void)
{
	vector<int> p(3);
	int ans = 0;

	for(int i = 0; i < 3; i++) cin >> p[i];
	sort(p.begin(), p.end());
	ans += p.at(0) + p.at(1);
	cout << ans << endl;
	return 0;
}


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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;

int nums[11];

int main()
{
    int n, k;
    set<int> setint;
    string s;
    cin >> s >> k;
    while (k--) {
        int i;
        cin >> i;
        setint.insert(i);
    }
    n = stoi(s, nullptr);
    for (int i = 0; i < (int) s.size(); ++i) {
        if (setint.find(s[i]-'0') != setint.end()) {
            n++;
            i = -1;
            s = to_string(n);
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n, m;
	cin >> n >> m;
	vector<int> arr;
	for (int i = 0; i < n; ++i) arr.push_back(2);
	for (int i = 0; i < m; ++i) arr.push_back(1);

	int ans = 0;
	for (int i = 0; i < n + m; ++i) {
		for (int j = i + 1; j < n + m; ++j) {
			if ((arr[i] + arr[j]) % 2 == 0)
				++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  string s; cin>>s;
  int n = s.length();
  for (int i=0; i<n; i++) {
    if (i%2==0) cout<<s[i];
  }
  

  return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int a,b,c;
	cin >> a >> b >> c;
	if (a+b+c >= 22) {
		cout << "bust" << endl;
	} else {
		cout << "win" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

var N int
var A []int

func main() {
	sc.Split(bufio.ScanWords)
	N = nextInt()
	A = make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
		A[i] -= i + 1
	}

	sort.Ints(A)
	b := A[N/2]

	ans := 0
	for i := 0; i < N; i++ {
		ans += abs(A[i] - b)
	}

	fmt.Println(ans)
	// S := N * (N + 1) / 2

	// var b int
	// if (S-sum)%N != 0 {
	// 	b = 0
	// } else {
	// 	b = (S - sum) / N
	// }

	// fmt.Println(b)

}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


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

int main(void)
{
    // a * bの場合、必要な回数は a+b-2. したがってa+bの最小値を求めれば良い
    /*
    a+b >= 2 sqrt(ab)
    */

    unsigned long long int a,b, Num;
    cin >> Num;
    unsigned long int MaxValue = (int) floor(sqrt(Num) );
    // cout << MaxValue << endl;
    a = MaxValue;
    while(a >= 1)
    {
        if(Num % a == 0)
        {
            b = Num/a;
            cout << a+b-2 << endl;
            break;
        }

        a--;
    }

    return 0;

}


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

void swp(int &a,int &b) {
	if (a > b) {
		int hoge = a;
		a = b;
		b = hoge;
	}
}

int main() {
	int input[3];
	for (char i = 0; i < 3; i++) {
		cin >> input[i];
	}

	for (size_t i = 0; i < 2; i=i+2){
		swp(input[i], input[i+1]);
	}
	for (size_t i = 0; i < 1; i=i+2){
		swp(input[i+1], input[i+2]);
	}
	for (size_t i = 0; i < 2; i = i + 2) {
		swp(input[i], input[i + 1]);
	}
	
	cout << input[0] << " " << input[1] << " " << input[2] << endl;
}


Measured memory_bytes: 3076
#include <cstdio>
#include <cstdlib>
struct Node {
	int key;
	Node *p, *l, *r;
};
Node *root;
void insert(int key_) {
	Node *x = root, *y = 0, *z;
	z = (Node*)malloc(sizeof(Node));
	z->key = key_, z->l = 0, z->r = 0;
	while (x) y = x, x = (z->key < x->key) ? x->l : x->r;
	z->p = y;
	if (!y) root = z;
	else if (z->key < y->key) y->l = z;
	else y->r = z;
}
void walk1(Node *x) { if (!x) return; walk1(x->l); printf(" %d", x->key); walk1(x->r); }
void walk2(Node *x) { if (!x) return; printf(" %d", x->key); walk2(x->l); walk2(x->r); }
int n, v; char c[8];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", &c);
		if (c[0] == 'i') scanf("%d", &v), insert(v);
		else walk1(root), printf("\n"), walk2(root), printf("\n");
	}
}

Measured memory_bytes: 26104
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 
 * @author ikaruga
 */
class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            List<String> lines = br.lines().collect(Collectors.toList());
            // ?????\??????????????????
            String[] result = proccessAmidakuji(
            		Integer.parseInt(lines.get(0)),
            		Integer.parseInt(lines.get(1)),
            		lines.stream().skip(2).map(l -> new Yokosen(l.split(","))).collect(Collectors.toList()));
            
            Stream.of(result).forEach(System.out::println);
            
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    /**
     * ?????\???????????????????????????
     * 
     * @param tatesenNum
     * @param yokosenNum
     * @param yokosenList
     */
    private static String[] proccessAmidakuji(int tatesenNum, int yokosenNum, List<Yokosen> yokosenList) {
    	String[] result = new String[tatesenNum];
    	
    	// ????????°?????????????????????
    	for (int tatesenNo = 1; tatesenNo <= tatesenNum; tatesenNo++) {
    		int amidaNo = tatesenNo;
    		for (Yokosen yokosen : yokosenList) {
    			if (yokosen.isContain(amidaNo))
    				amidaNo = yokosen.getExchangeNumber(amidaNo);
    		}
    		result[amidaNo-1] = String.valueOf(tatesenNo);
    	}
    	return result;
    }

	/**
	 * @author ikaruga
	 *
	 */
	static class Yokosen {
		int startNo = 0;
		int endNo = 0;
		
		public Yokosen(String[] numbers) {
			startNo = Integer.parseInt(numbers[0]);
			endNo = Integer.parseInt(numbers[1]);
		}
		
		public boolean isContain(int number) {
			return startNo == number || endNo == number;
		}
		
		public int getExchangeNumber(int number) {
			return startNo + endNo - number;
		}
	}
}

Measured memory_bytes: 30912
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
ans = 0
max_num = 0
j = M
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
for i in range(N+1):
    if a[i] > K:
        break
    else:
        while b[j] > K - a[i]:
            j -=1
            if j <0:
                break
    if K>= a[i] + b[j]:
        ans = max(ans,i + j)
print(ans)
        

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a <= 0 && b >= 0){
    cout << "Zero" << endl;
  }else if (a > 0 && b > 0)  {
    cout << "Positive" << endl;
  }else if(a < 0 && b < 0){
    if((b - a + 1) % 2 == 0){
      cout << "Positive" << endl;
    }else{
      cout << "Negative" << endl;
    }
  }
}

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


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

    string P;
    string W;
    string G;
    string Y;
    string tmp;

  rep(i,N){
    cin >> tmp;

  
    if(tmp == "P"){
      P = tmp;
    }
    else if(tmp == "W"){
      W = tmp;
    }
    else if (tmp == "G"){
      G = tmp;
    }
    else if(tmp == "Y"){
      Y = tmp;
    }

  }
    if(P == "P" && W == "W" && G == "G" && Y == "Y"){
      cout << "Four";
    }
    else{
      cout << "Three";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  string S;
  cin >> S;
  int l = 0, r = S.size() - 1, ans = 0;
  while (l < r) {
    if (S.at(l) != S.at(r)) ans++;
    l++;
    r--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
from scipy.sparse import *;from scipy.sparse.csgraph import connected_components;N,M=map(int,input().split());g=lil_matrix((N,N))
for _ in [0]*M:
  a,b=list(map(int,input().split()));g[a-1,b-1]=1
c=0
for a,b in zip(*g.nonzero()):
  g[a,b]=0;c+=connected_components(g,return_labels=False)!=1;g[a,b]=1
print(c)

Measured memory_bytes: 17612
l=input()
n=len(l)
dp=[]
for i in range(n+1):
    sub_list=[0,0]
    dp.append(sub_list)
dp[0][0]=1
dp[0][1]=0
INF=10**9+7
for i in range(1,n+1):
    if l[i-1]=='0':
        dp[i][0]=dp[i-1][0]%INF
        dp[i][1]=3*dp[i-1][1]%INF
    else:
        dp[i][0]=2*dp[i-1][0]%INF
        dp[i][1]=(3*dp[i-1][1]+dp[i-1][0])%INF
print((dp[n][0]+dp[n][1])%INF)



Measured memory_bytes: 54128
#include <iostream>
#include <cstdio>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
const int sz = 1e5, ma = 1e9;
template <typename T>
T chmin(T a, T b) { a = min(a, b); }
template <typename T>
T chmax(T a, T b) { a = max(a, b); }
int n, k, a[sz], dp[41][2];
void solve()
{
    rep(m, 41)
    {
        int score[2] = {0, 0};
        rep(i, n)
        {
            score[1 - (a[i] >> m) & 1] += (1LL << m);
        }
        dp[m][0] = max(score[0], score[1]) + (m == 0 ? 0 : dp[m - 1][0]);
        if ((k >> m) & 1)
        {
            dp[m][1] = max(score[0] + (m == 0 ? 0 : dp[m - 1][0]),
                           score[1] + (m == 0 ? 0 : dp[m - 1][1]));
        }
        else
        {
            dp[m][1] = score[0] + (m == 0 ? 0 : dp[m - 1][1]);
        }
    }
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    scanf("%lld%lld", &n, &k);
    rep(i, n) scanf("%lld", a + i);
    solve();
    cout << dp[40][1] << endl;
    return 0;
}

Measured memory_bytes: 1276
// https://atcoder.jp/contests/abc170/tasks/abc170_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N;
    cin >> N;
    map<int, int> mp;
    REP(i, N) {
        int t;
        cin >> t;
        mp[t]++;
    }
    // 入力値の最大値
    int maxv = mp.rbegin()->first;
    // 入力値の2倍以上を保存
    bitset<1000001> bt;
    int ans = 0;
    for (auto &x : mp) {
        // 重複なし
        if (x.second == 1 && !bt[x.first]) {
            ans++;
        }
        for (int mul = 2; mul * x.first <= maxv; mul++) {
            bt.set(mul * x.first);
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 16240
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n);
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end());
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a)      reverse((a).begin(), (a).end());
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d);
#define outl(d)         std::cout<<(d)<<"\n";
#define Yes()           printf("Yes\n");
#define No()            printf("No\n");
#define YES()           printf("YES\n");
#define NO()            printf("NO\n");
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int r, g, b; cin >> r >> g >> b;
  if ((g * 10 + b) % 4 == 0) {
    YES()
  } else {
    NO()
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iostream>
using namespace std;
typedef long long LL;
const int INF = 1 << 30;
const int MaxN = 1e5;

int n;
LL a[2005];

LL GCD(LL x, LL y)
{
	if(y == 0) return x;
	else return GCD(y, x % y);
}

LL LCM(LL x, LL y)
{
	return x / GCD(x, y) * y;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	LL tot = 1;
	for(int i = 1; i <= n; i++) {
		tot = LCM(tot, a[i]);
	}
	printf("%lld",tot);
}


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

n = int(input())
A = list(map(int, input().split()))
ans = A[0]

def calc(a, b):
    if b == 0:
        return a
    else:
        return calc(b, a%b)

for i in range(n-1):
    ans = calc(ans, A[i+1])

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll x,a,b;cin>>x>>a>>b;
    if(abs(x-a)>=abs(x-b)){
        cout<<"B"<<endl;
    }else{
        cout<<"A"<<endl;
    }
    
    return 0;
}







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

namespace abc149_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInt();

            while (true)
            {
                if (IsPrime(N)) break;
                else N++;
            }

            Console.WriteLine(N);
        }

        /// <summary>
        /// 素数判定
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    // 素数ではない
                    return false;
                }
            }

            // 素数である
            return true;
        }


        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

    }
}


Measured memory_bytes: 11092