akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int length = s.Length;
            int result = 0;

            for (int i = 0; i < length; i++)
            {
                if (s[i] != t[i])
                    result += 1;
            }

            Console.WriteLine(result);

        }    
    }
}


Measured memory_bytes: 27412
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int a,b;
    cin >> a >> b;
    if (a>b)
    {
        for (int i = 0; i < a; i++)
        {
            cout <<b;
        }
    }else{
        for (int i = 0; i < b; i++)
        {
            cout <<a;
        }
    }
}

Measured memory_bytes: 256
a, b = map(int, input().split())
if a % 2 != 0 and b % 2 == 0:
  print(int((a+b)/2) + 1)
elif a % 2 == 0 and b % 2 != 0:
  print(int((a+b)/2) + 1)
else:
  print(int((a+b)/2))

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
int main(){
  long long a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc126/tasks/abc126_e

# 偶奇を当てる問題
# 制約 A_Xi + A_Yi + Zi は偶数

# もしZiが偶数のとき
# A_Xi , A_Yiは偶,偶 or 奇,奇

# もしZiが奇数なら
# A_Xi , A_Yiは偶,奇 or 奇,偶

# A_XiとA_Yiについて符号が違うか同じかをメモしておけば良い？
# 未確定なAiについて魔法を使う必要がある

# Aiのiをノードとして捉えたとき、ノードXj, Yjは'同じまとまり'としてマージし続けられる
# 同じまとまりに対しては一つのAiを確定させれば、そのまとまりすべてのAiが判明する。
# よってdisjointになっている集合の数が答えになる。


class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードをしめす。負は自身が親ということ。
        self.parent = [-1] * N  # idxが各ノードに対応。

    def root(self, A):
        # print(A)
        # ノード番号を受け取って一番上の親ノードの番号を帰す
        if (self.parent[A] < 0):
            return A
        self.parent[A] = self.root(self.parent[A])  # 経由したノードすべての親を上書き
        return self.parent[A]

    def size(self, A):
        # ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
        return -self.parent[self.root(A)]

    def unite(self, A, B):
        # ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
        # 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
        A = self.root(A)
        B = self.root(B)

        # すでにくっついている場合
        if (A == B):
            return False

        # 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
        if (self.size(A) < self.size(B)):
            A, B = B, A

        # くっつける
        self.parent[A] += self.parent[B]  # sizeの更新
        self.parent[B] = A  # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる

        return True

    def is_in_same(self, A, B):
        return self.root(A) == self.root(B)

    def n_disjoint(self):
        # O(N)かかる
        return sum([x < 0 for x in self.parent])


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


N, M = read_ints()
uf = UnionFind(N)
for m in range(M):
    x, y, z = read_ints()
    uf.unite(x - 1, y - 1)

print(uf.n_disjoint())


Measured memory_bytes: 6304
/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
using namespace std;
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt","w",stderr);
    #endif
}
ll parent[100005];
ll find(ll a)
{
    std::vector<ll> v;
    while(parent[a]>0)
    {
        v.push_back(a);
        a = parent[a];
    }
    for(ll i=0;i<v.size();i++)
        parent[v[i]] = a;
    return a;
}
bool prime[100005];
void SieveOfEratosthenes(int n) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
void union1(ll a, ll b)
{
    a = find(a);
    b = find(b);
    if(a!=b)
    {
        parent[a] = min(parent[a],parent[b]);
        parent[b] = a;
    }
}  
ll n;
ll arr[100002];
ll dp[100002];
int main()
{
    memset(dp,-1,sizeof(dp));
    //fastio();
    //ll n;
    cin >> n;
//    ll arr[n];
    for(ll i=0;i<n;i++)
        cin >> arr[i];
    dp[0] = 0;
    for(ll i=1;i<n;i++)
    {
        if(i-1>=0)
            dp[i] = dp[i-1]+abs(arr[i]-arr[i-1]);
        if(i-2>=0)
            dp[i] = min(dp[i],dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
class Max
  def solve
    loop do
      n = gets.chomp.to_i
      break if n == 0
       
      max = -100000
      sum = 0
      n.times do
        a = gets.chomp.to_i
        sum += a
        if max < sum
          max = sum
        end
        if sum < 0 then 
          sum = 0
        end
      end
      puts max
    end
  end
end
Max.new.solve

Measured memory_bytes: 8796
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 500 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, k, A[MAXN], B[MAXN], sum, ans;

void calc(ll x) {
    set<pll> st;
    for (ll i = 1; i <= n; i++) B[i] = A[i] % x, st.insert({B[i], i});
    ll cost = 0;
    while (st.size() != 0) {
        pll p = *st.begin();
        ll t = p.X;
        st.erase(st.begin());

        while (t) {
            pll q = *prev(st.end());
            st.erase(q);
            ll mn = min(t, x - q.X);
            q.X = (q.X + mn) % x;
            t -= mn;
            cost += mn;
            st.insert(q);
        }
    }
    if (cost <= k) ans = max(ans, x);
}

int main() {
    fast_io;

    cin >> n >> k;
    for (ll i = 1; i <= n; i++) cin >> A[i], sum += A[i];

    for (ll i = 1; i * i <= sum; i++) {
        if (sum % i == 0) {
            calc(i);
            calc(sum / i);
        }
    }
    cout << ans << endl;

    return 0;
}
/*

*/


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

const int INF = 1<<28;

const int MAXN = 105;
int R, C;
int G[MAXN][MAXN];

int getValue(int i, int j, int di, int dj) {
  int sum = 0;
  for(int d = -1; d <= 1; d += 2) {
    int ni = i;
    int nj = j;
    for(ni = i, nj = j;
        0 <= ni && ni < R && 0 <= nj && nj < C;
        ni += d*di, nj += d*dj) {
      if(ni == i && nj == j) continue;
      if(G[ni][nj] == INF) return INF;
      sum -= G[ni][nj];
    }
    if(ni >= 0 && nj >= 0) sum += G[ni][nj];
  }
  return sum;
}

int main() {
  while(cin >> R && R) {
    cin >> C;
    for(int i = 0; i < R+1; ++i) {
      for(int j = 0; j < C+1; ++j) {
        string s;
        cin >> s;
        if(s == "?") {
          G[i][j] = INF;
        } else {
          G[i][j] = atoi(s.c_str());

        }
      }
    }
    queue<pair<int,int> > que;
    int n = 0;
    for(int i = 0; i < R; ++i) {
      for(int j = 0; j < C; ++j) {
        if(G[i][j] == INF) {
          que.push(make_pair(i,j));
          ++n;
        }
      }
    }
    vector<pair<pair<int,int>, int> > res;
    while(!que.empty()) {
      int i = que.front().first;
      int j = que.front().second;
      que.pop();
      if(G[i][j] != INF) continue;
      int u = getValue(i,j,1,0);
      int v = getValue(i,j,0,1);
      if(u != INF || v != INF) {
        G[i][j] = min(u,v);
        res.push_back(make_pair(make_pair(i,j),G[i][j]));
        for(int k = 0; k < C; ++k) {
          if(G[i][k] == INF) que.push(make_pair(i,k));
        }
        for(int k = 0; k < R; ++k) {
          if(G[k][j] == INF) que.push(make_pair(k,j));
        }
      }
    }

    static bool first = true;
    if(first) first = false;
    else cout << endl;
    if(res.size() != n) {
      cout << "NO" << endl;
    } else {
      sort(res.begin(), res.end());
      for(int i = 0; i < res.size(); ++i) {
        cout << res[i].second << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1300
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
n=int(input())
a=[int(input()) for _ in range(n)]
l=[0]*n
r=[0]*n
l[0]=a[0]
r[0]=a[-1]
for i in range(1,n):
    if a[i]>l[i-1]:
        l[i]=a[i]
    else:
        l[i]=l[i-1]
    if a[n-1-i]>r[i-1]:
        r[i]=a[n-1-i]
    else:
        r[i]=r[i-1]
print(r[n-2])
for i in range(1,n-1):
    print(max(l[i-1],r[n-i-2]))
print(l[n-2])

Measured memory_bytes: 87884
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main(){
	cin >> n;
	for(int i=1;i<=n;i+=2){
		int x=0;
		for(int j=1;j<=i;j++)
			if(i%j==0)x++;
		if(x==8)ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N, K = map(int, input().split())
r, s, p = map(int, input().split())
score = {}
score['s'] = r
score['p'] = s
score['r'] = p
T = input()
dic = defaultdict(int)
ans = 0
for i in range(N):
  c = T[i]
  if i<K:
    ans += score[c]
    dic[i] = c
    continue
  d = dic[i%K]
  if d==c:
    dic[i%K] = 0
    continue
  ans += score[c]
  dic[i%K] = c
print(ans)

Measured memory_bytes: 15468
"""

和がN以下なら恐れくYES
過半数にならないようにとっていけばいい
和がちょうどNなのが2つあったら、それを取る

和がNになるやつが現れるまでは自由にとり
N個になったら、それ+1個を取る

"""

import sys
from sys import stdin

#0-indexed , 半開区間[a,b)
#calc変更で演算変更
class SegTree:

    def __init__(self,N,first):
        self.NO = 2**(N-1).bit_length()
        self.First = first
        self.data = [first] * (2*self.NO)

    def calc(self,l,r):
        return max(l,r)

    def update(self,ind,x):
        ind += self.NO - 1
        self.data[ind] = x
        while ind >= 0:
            ind = (ind - 1)//2
            self.data[ind] = self.calc(self.data[2*ind+1],self.data[2*ind+2])

    def query(self,l,r):
        L = l + self.NO
        R = r + self.NO
        s = self.First
        while L < R:
            if R & 1:
                R -= 1
                s = self.calc(s , self.data[R-1])
            if L & 1:
                s = self.calc(s , self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return s

    def get(self,ind):
        ind += self.NO - 1
        return self.data[ind]

N = int(stdin.readline())
A = list(map(int,stdin.readline().split()))
B = list(map(int,stdin.readline().split()))

nA = [0] * (N+1)
nB = [0] * (N+1)
nS = [0] * (N+1)

for i in A:
    nA[i] += 1
    nS[i] += 1
for i in B:
    nB[i] += 1
    nS[i] += 1

if max(nS) > N:
    print ("No")
    sys.exit()

print ("Yes")

ST = SegTree( N+1 , (float("-inf") , 0) )
for i in range(N):
    ST.update( i , (nS[i] , i) )

B.sort()
B.reverse()

out = None
ans = []
for i in range(N):

    num,inds = ST.query(0,N+1)
    if num == N-i:
        out = inds
        break

    if A[-1] == B[-1]:
        B.reverse()

    nas,tmp = ST.get(A[-1])
    ST.update( A[-1] ,  ( nas-1 , A[-1] ) )
    nab,tmp = ST.get(B[-1])
    ST.update( B[-1] , ( nab-1 , B[-1] ) )
    ans.append( (A[-1],B[-1]) )
    del A[-1]
    del B[-1]

if out != None:
    for i in A:
        if i != out:
            ans.append( (i,out) )
    for i in B:
        if i != out:
            ans.append( (out,i) )

ans.sort()
pla = []
for aa,bb in ans:
    pla.append(bb)
print (*pla)


Measured memory_bytes: 164364
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
int main() {
    ll n,k;
    cin>>k>>n;
    ll a[n], b[n], x=0;
    f(i,n)
    {
        cin>>a[i];
    }
    for(ll i=0;i<n-1;i++)
    {
        b[x]=a[i+1]-a[i];
        x++;
        }
    b[x]=(k+a[0]-a[n-1]);
    x++;
    sort(b,b+x);
    ll sum=0;
    /*f(i,x)
    {
        cout<<b[i]<<' ';
    }*/
    f(i,x-1)
    {
        sum=sum+b[i];
    }
    cout<<sum;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;

using namespace std;

#define ll  long long

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef unordered_map<int,int> um;
typedef unordered_set<int> us;
typedef priority_queue<int> pq;
typedef deque<int> dq;
typedef queue<int> q;
typedef stack<int> st;

#define f first
#define s second
#define pb push_back
#define mp make_pair

#define rep(i,a,b) for (auto i = a; i < b; i++)
//#define bitset<n> b<n>

/* typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; */

//indexed_set s;
	//s.insert(2);
	//s.insert(3);
	//s.insert(7);
	//s.insert(9);

	//auto x = s.find_by_order(2);
	//s.order_of_key(7)
	
	//c_p_c();

	//__builtin_clz(x): the number of zeros at the beginning of the number
   // __builtin_ctz(x): the number of zeros at the end of the number
   // __builtin_popcount(x): the number of ones in the number
   // __builtin_parity(x): the parity (even or odd) of the number of ones

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

void max_self(ll& a, ll b) {
    a = max(a, b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 1024
H,W = map(int, input().split())

S_array = [["#" for _ in range(W+2)]] + [["#"] + list(input()) + ["#"] for i in range(H)] + [["#" for _ in range(W+2)]]

def connection_check(target_list):
    connection = 0
    connection_list = list()
    
    for i in range(len(target_list)):
        if target_list[i]=="#":
            connection_list += [connection for _ in range(connection)]
            connection_list += [0]
            connection = 0
        elif target_list[i]==".":
            connection += 1
    
    return connection_list

W_connection_array = [[0 for _ in range(W+2)]] + [connection_check(S_array[i]) for i in range(1,H+1)] + [[0 for _ in range(W+2)]]
H_connection_array = [[0 for _ in range(H+2)]] + [connection_check([row[i] for row in S_array]) for i in range(1,W+1)] + [[0 for _ in range(H+2)]]

#print(W_connection_array)
#print(H_connection_array)

ans = 0

for i in range(1,H+1):
    for j in range(1,W+1):
        temp_ans = W_connection_array[i][j] + H_connection_array[j][i]
        if ans < temp_ans:
            ans = temp_ans

print(ans - 1) #自分自身の分の重複加算を引く

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

int main()
{
  ll n,i,j;
  cin>>n;
  ll x[n+1],y[n+1],h[n+1];
  for(i=0;i<n;i++)
  {
      cin>>x[i]>>y[i]>>h[i];
  }
  ll cx,cy,ch,acx,acy,ach;
  bool f;
  for(i=0;i<=100;i++)
  {
      for(j=0;j<=100;j++)
      {
        //   cout<<i<<" "<<j<<endl;
          cx = i, cy = j;
          f = true;
          ll p = 1, q = 2000000000;
          
          ll poi = 0;
          for(ll k = 0;k<n;k++)
          {
              if(h[k]>h[poi])
              {
                poi = k;
              }
          }
          
          while(p<=q)
          {
              ll mid = (p+q)/2;
              ll th = max(mid - abs(x[poi]-cx) - abs(y[poi]-cy),0LL);
              if(th==h[poi])  break;
              else if(th<h[poi])
                p = mid+1;
              else
                q = mid-1;
          }
          if(p>q)
          {
            f = false;continue;
          }
          ll mid = (p+q)/2;
          ll th = max(mid - abs(x[poi]-cx) - abs(y[poi]-cy),0LL);
          if(th==h[poi])
          {
            //   cout<<cx<<" "<<cy<<" "<<mid<<" "<<th<<" "<<h[0]<<endl;
              ch = mid;
          }
          else
          {
            f = false;continue;
          }
          
          if(ch<1)
          {
              f =false;continue;
          }

          for(p=0;p<n;p++)
          {
            ll th = max(ch - abs(x[p]-cx) - abs(y[p]-cy),0LL);
            if(th!=h[p])
            {
                f = false;break;
            }
          }
          if(f)
          {
              acx = cx;
              acy = cy;
              ach = ch;
          }
      }
  }
  cout<<acx<<" "<<acy<<" "<<ach;
  /*else
    cout<<(1/0);*/
  return 0;
}

Measured memory_bytes: 256
import math
import itertools
def main():
    n = int(input())
    x = []
    y = []
    for i in range(n):
        xx,yy = map(int, input().split())
        x.append(xx)
        y.append(yy)
    ans = 0.0
    dist = [[0.0] * n for i in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            dist[i][j] = cal_dist(x[i],y[i],x[j],y[j])
            dist[j][i] = dist[i][j]
    r = []
    for i in range(n):
        r.append(i)
    cnt = 0
    for perm in itertools.permutations(r,n):
        p = list(perm)
        cnt += 1
        for i in range(1,n):
            ans += dist[p[i-1]][p[i]]

    ans /= cnt
    print(ans)



def cal_dist(x1,y1,x2,y2):
    a = x1 -x2
    b = y1 - y2
    retval = a ** 2 + b ** 2
    return math.sqrt(retval)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A=list(map(int,input().split()))
    K=int(input())
    A.sort()
    print(A[-1]*2**K+sum(A[:2]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
#define MAX 100010
 
int bit[MAX];
 
inline void add(int x,int w) {
  for(;x<MAX;x+=(x&-x)) bit[x] += w;
}
 
inline int sum(int x) {
  int ret = 0;
  for(;x>0;x-=(x&-x)) {
    ret += bit[x];
  }
  return ret;
}
 
int main() {
  int n,q;
  cin >> n >> q;
  int c,x,y;
  rep(i,q) {
    cin >> c >> x >> y;
    if( c == 0 ) {
      add(x,y);
    } else {
      cout << sum(y) - sum(x-1) << endl;
    }
  }
   
  return 0;
}

Measured memory_bytes: 3480
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ll n;cin >> n;
  vll p(n),q(n),a(n);

  rep(i,n) a[i] = i + 1;
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];

  ll cnt = 0;
  ll p_cnt,q_cnt;

  do{
    bool b = true;
    rep(i,n)
    {
      if(a[i] != p[i])
       b = false;
    }

    if(b) p_cnt = cnt;

    b = true;
    rep(i,n)
    {
      if(a[i] != q[i])
        b = false;
    }

    if(b) q_cnt = cnt;

    cnt++;

  }while(next_permutation(all(a)));


  cout << abs(p_cnt - q_cnt) << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,min1,min2;
cin>>a>>b>>c>>d;
if(a>=b)
 min1=b;
else
 min1=a;
if(c>=d)
min2=d;
else
min2=c;
cout<<min1+min2;
return 0;}


Measured memory_bytes: 256
n = int(input())
array = [[int(x) for x in input().split()] for y in range(n)]
sorted(array, key = lambda x:x[0])
now_x = 0
now_y = 0
now_t = 0
for t,x,y in array:
  if t - now_t < abs(x-now_x)+abs(y-now_y):
    break
  elif (t-now_t - abs(x-now_x) - abs(y-now_y)) % 2 ==1:
    break
  x = now_x
  y = now_y
  t = now_t
else:
  print("Yes")
  exit()
print("No")

Measured memory_bytes: 22644
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var)\
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

template <typename Iter>
Iter partition(Iter begin, Iter end, Iter pivot) {
  if (distance(pivot, end) != 1) {
    iter_swap(end -1, pivot);
    pivot = end - 1;
  }
  auto x = end;
  for (auto it = begin; it != end; ++it) {
    if (it != pivot && *it <= *pivot) {
      x = (x == end) ? begin : x + 1;
      if (x != it) {
        iter_swap(x, it);
      }
    }
  }
  x = (x == end) ? begin : x + 1;
  iter_swap(x, pivot);
  return x;
}

int main() {
  int n;
  cin >> n;
  vector<int> nums;
  for (int t, i = 0; i < n; ++i) {
    cin >> t;
    nums.push_back(t);
  }
  auto pivot = partition(nums.begin(), nums.end(), nums.end() - 1);
  bool first = true;
  for (auto it = nums.begin(); it != nums.end(); ++it) {
    if (!first)
      cout << " ";
    first = false;
    bool is_pivot = it == pivot;
    if (is_pivot)
      cout << "[";
    cout << *it;
    if (is_pivot)
      cout << "]";
  }
  cout << endl;
}

Measured memory_bytes: 3436
<?php
$answer_count = 0;
$stops = explode(' ', trim(fgets(STDIN)));
$stop_day = '2018-'.$stops[0].'-'.$stops[1];
$stop_day = date('Y-n-j', strtotime($stop_day.' +1 day'));
$today = '2018-1-1';
while ($today != $stop_day) {
  $day_parts = explode('-', $today);
  if ($day_parts[1] == $day_parts[2]) {
    $answer_count++;
  }
  $today = date('Y-n-j', strtotime($today.' +1 day'));
}
echo $answer_count."\n";


Measured memory_bytes: 4336
#include <stdio.h>

int main(void){
    long suuti1,suuti2,value1,value2,remainder,LCM;
    
    scanf("%ld %ld",&suuti1,&suuti2);
    
    if (suuti1 > suuti2) {
        value1 = suuti1;
        value2 = suuti2;
    } else {
        value1 = suuti2;
        value2 = suuti1;
    }
    
    while (1) {
        remainder = value1 % value2;
        if (remainder == 0 ||remainder ==1) break;
        value1 = value2;
        value2 = remainder;
    }
    
    if (remainder == 0) {
        LCM = (suuti1*suuti2) / value2;
    } else {
        LCM = (suuti1*suuti2) / remainder;
    }
    
    printf("%ld\n",LCM);
    
    return 0;
}


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

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> s(N);

	for (int i = 0; i < N; ++i) {
		string str;
		cin >> str;
		s[i] = str.substr(0, L);
	}

	sort(s.begin(), s.end());
	
	for (int i = 0; i < N; ++i) cout << s[i];
	cout << endl;
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

int main() {
    vector<int> n(3);
    for(int i = 0; i < 3; i++) {
        cin >> n[i];
    }
    sort(n.begin(), n.end(), greater<int>());
    cout << n[0] * 10 + n[1] + n[2] << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                               
def I(): return list(map(int,inp().split()))
from collections import Counter

n=I()[0]
s=input() 
cut=0
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if 2*j-i>=len(s): break
        if len({s[i],s[j],s[2*j-i]})==3: 
            cut+=1
d=Counter(s) ; mul=1
for i in d.values():
    mul*=i
if len(d)<3: print(0)
else: print(mul-cut)


            

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

struct Ant{
    int index;
    int dir;
    int pos;  
};

int solve(int n,int l){
    vector<Ant> ant(n);
    for(int i=0;i<n;i++){
        char d;
        int pos;
        cin>>d>>pos;
        ant[i].index=i+1;
        ant[i].pos=pos;
        if(d=='R'){
            ant[i].dir=1;
        }
        else{
            ant[i].dir=-1;
        }
    }
    
    int cnt=n;
    for(int t=1;;t++){
        int res=-1;
        for(int i=0;i<n;i++){
            if(ant[i].index==-1) continue;
            ant[i].pos+=ant[i].dir;
        }
        
        for(int i=0;i<n;i++){
            if(ant[i].index==-1) continue;
            if(ant[i].pos==0){                
                cnt--;
                res=ant[i].index;
                if(cnt==0){
                    cout<<t<<" "<<res<<endl;
                    return 0;
                }
                ant[i].index=-1;
                continue;
            }
            else if(ant[i].pos==l){
                cnt--;
                if(cnt==0){
                    if(res==-1) cout<<t<<" "<<ant[i].index<<endl;
                    else cout<<t<<" "<<res<<endl;
                    return 0;
                }
                ant[i].index=-1;
                continue;
            }
            for(int j=i+1;j<n;j++){
                if(ant[i].pos==ant[j].pos){
                    ant[i].dir=-ant[i].dir;
                    ant[j].dir=-ant[j].dir;
                }
            }
        }
    }
    return 0;
}

int main(){
    int n,l;
    while(cin>>n>>l,n){
        solve(n,l);
    }
    return 0;
}




Measured memory_bytes: 3008
n,d = gets.chomp.split(' ').map(&:to_i)
count = 0
i = 0
while i < n
  x,y = gets.chomp.split(' ').map(&:to_i)
  if Math.sqrt((x**2)+(y**2)) <= d
    count += 1
  end
  i += 1
end
p count

Measured memory_bytes: 14372
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

VI tb = {
0, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6
};

string mx(const string& a, const string& b) {
	if(a.size()>b.size()) return a;
	if(a.size()<b.size()) return b;
	return max(a, b);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,v;
	while(cin>>N>>M) {
		VI A(M);
		REP(i, M) cin>>A[i];
		vector<string> dp(N+1, "-");
		dp[0] = "";
		RANGE(i, 0, N+1) if(dp[i]!="-") {
			REP(mi, M) {
				ll n = i+tb[A[mi]];
				if(n<=N) {
					dp[n] = mx(dp[n], string(1, A[mi]+'0')+dp[i]);
				}
			}
		}
//		DD(dp);
		cout<<dp[N]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 32384
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;
 
void solve(){
	int N;
	LL K;
	cin >> N >> K;
	vector< pair<int,int> > v;
	for(int i=0;i<N;++i){
		int a,b;
		cin >> a >> b;
		v.push_back(pair<int,int>(a,b) );
	}
	sort( v.begin(), v.end() );
	LL sum = 0;
	for(int i=0;i<N;++i){
		sum += v[i].second;
		if( K <= sum ){
			cout << v[i].first << endl;
			return;
		}
	}
	
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  string a, b, c; cin >> a >> b >> c;
  int pa = 0;
  int pb = 0;
  int pc = 0;
  char now = 'a';
  while(true) {
  if (now == 'a') {
    if (pa == a.size()) {
      cout << 'A' << endl;
      return 0;
    }
    now = a.at(pa);
    pa++;
  } else if (now == 'b') {
    if (pb == b.size()) {
      cout << 'B' << endl;
      return 0;
    }
    now = b.at(pb);
    pb++;
  } else {
    if (pc == c.size()) {
      cout << 'C' << endl;
      return 0;
    }
    now = c.at(pc);
    pc++;
  }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  bool ok = true;
  for(int i = 0; i < 3; i++) {
    if(S[i] == S[i + 1]) ok = false;
  }
  if(ok) cout << "Good" << endl;
  else cout << "Bad" << endl;

  return 0;
}

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

int main() {
    
    int X;

    cin >> X;

    if (X>= 400 && X <= 599){
        cout << 8 << endl;
    }
    else if (X>= 600 && X<= 799){
        cout << 7 << endl;
    }
    else if (X>= 800 && X<= 999){
        cout << 6 << endl;
    }
    else if (X>= 1000 && X<= 1199){
        cout << 5 << endl;
    }
    else if(X >= 1200 && X<=1399){
        cout << 4 << endl;
    }
    else if(X >= 1400 && X<=1599){
        cout << 3 << endl;
    }
    else if(X >= 1600 && X<=1799){
        cout << 2 << endl;
    }    
    else {
        cout << 1 << endl;
    }


}


Measured memory_bytes: 3616
a = []
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
cnt = 0

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

for i in range(n):
    sum = 0
    for j in range(m):
        sum += a[i][j]*b[j]
    if sum + c > 0:
        cnt += 1
print(cnt)

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

namespace atcoder
{
    class Program
    {
        static List<bool> checkList;
        static List<List<int>> list;

        static void Main(string[] args)
        {
            var n = Int64.Parse(Console.ReadLine());
            list = new List<List<int>>();
            for (int i = 0; i < 200000; i++)
            {
                list.Add(new List<int>());
            }
            for (var i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                var l = s.Split(" ");
                var x = Int32.Parse(l[0]) - 1;
                var y = Int32.Parse(l[1]) + 100000 - 1;

                list[x].Add(y);
                list[y].Add(x);
            }

            checkList = new List<bool>(new bool[200000]);
            for(var i=0; i<200000; i++) checkList[i] = false;
            long sum = 0;

            for (var i = 0; i < 100000; i++)
            {
                if(checkList[i]) continue;
                xc = 0;
                yc = 0;
                DFS(i);
                sum += xc * yc;
            }

            Console.WriteLine(sum - n);
        }

        static long xc, yc;
        static void DFS(int index)
        {
            if (!checkList[index])
            {
                checkList[index] = true;
                if (index < 100000)
                {
                    xc++;
                }
                else
                {
                    yc++;
                }
                foreach (var l in list[index])
                {
                    DFS(l);
                }
            }
        }
    }
}

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

int main() {
	string s; cin >> s;
	int idx = 0;
	while (1) {
		int pos = s.find("BC", idx);
		if (pos == string::npos) break;
		s.erase(pos, 1);
		s[pos] = 'D';
		idx = pos;
	}
	long long ans = 0;
	long long cntA = 0, cntD = 0;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'D') cntD++;
		else if (s[i] == 'A' && cntD > 0) ans += cntD;
		else {
			cntA = 0;
			cntD = 0;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(void){
    string s;
    string t;

    int i;
    int result = 0;

    cin >> s >> t;

    for(i=0; i<s.length();i++){
        if(s[i] != t[i]) result++;
    }

    cout << result << endl;
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;

int main()
{
    fast;
    
ll n;
cin>>n;
cout<<((n+1)*(n))/2;
    
    
 
   
}

		
	
	
	
	


Measured memory_bytes: 3484
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int A =sc.nextInt();
      int B =sc.nextInt();
      
      int m1 =A+B;
      int m2 =A-B;
      int m3 =A*B;
      
   System.out.print(Math.max(m1,Math.max(m2,m3)));
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define rep2(i, s, e) for (int (i) = (s); (i) < (int)(e); ++(i))
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const long long MOD = 1000000007;

int main() {
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  int N, A;
  cin >> N >> A;
  cout << N * N - A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}
// int JUDGE_ONLINE = 1;
// if (fopen("ip1.txt", "r")) {
// 	JUDGE_ONLINE = 0;
// 	assert(freopen("ip1.txt", "r", stdin));
// 	assert(freopen("op1.txt", "w", stdout));
// }

// if (!JUDGE_ONLINE) {
// 	cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
// }

int32_t main()
{
	k_007();
	int n;
	cin>>n;
	cout<<(n+1)/2<<endl;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int ans = 0;
	string s;
	cin >> s;
	rep(i,s.size()){
		if(s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int temp = i;
		int temp_ans = 0;
		while(temp%2 == 0){
			temp_ans += 1;
			temp /= 2;
		}
		ans = max(ans, temp_ans);
	}
	cout << pow(2, ans) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=110;
int n,l[maxn];
bool chk(int a, int b, int c){
    if(a+b<=c || b+c<=a || a+c<=b) return false;
    if(a-c>=b || a-b>=c || b-c>=a) return false;
    if(c-a>=b || b-a>=c || c-b>=a) return false;
    return true;
}
int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif
    cin>>n;
    for(int i=1; i<=n; ++i) cin>>l[i];
    int ans=0;
    for(int i=1; i<=n; ++i){
        for(int j=i+1; j<=n; ++j){
            for(int k=j+1; k<=n; ++k){
                if(l[i]==l[j] || l[j]==l[k] || l[k]==l[i]) continue;
                if(chk(l[i], l[j], l[k])){
                 //   cerr<<i<<' '<<j<<' '<<k<<endl;
                    ++ans;
                }
            }
        }
    }
    cout<<ans<<'\n';
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3640
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,s;
    cin>>n>>s;
    if(s%1000==0){
        for(int i=0;i*10000<=s&&i<=n;i++){
            for(int j=0;j*5000<=s&&i+j<=n;j++){
                for(int k=0;k*1000+j*5000+i*10000<=s&&i+j+k<=n;k++){
                    if(i+j+k==n&&i*10000+j*5000+k*1000==s){
                        cout<<i<<" "<<j<<" "<<k<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
li.sort()
temp = 0
min = 100000000000000000000000000
for i in range(li[0], li[-1]+1):
    for k in li:
        temp += (k - i)**2
    if temp <= min:
        min = temp
    temp = 0
print(str(min))


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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int main(void){
	REP(i,1,10)REP(j,1,10){
		cout<<i<<"x"<<j<<"="<<i*j<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

	ll t, i, x, j, y, 	z, k, n;
	cin >> k >> x >> z >> y;
	t = max(k * z, y * x);
	t=max({t,x*z,y*k});
	ce(t);
}



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

using namespace std;
typedef complex<double> P;

P read()
{
    double x,y;
    cin>>x>>y;
    return P(x,y);
}

double ccw(P a,P b)
{
    return (a*conj(b)).imag();
}

bool online(P a,P b)
{
    P p=a*conj(b);
    return p.imag()==0&&p.real()>=0&&abs(a)>abs(b);
}

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

    while(q--)
    {
        P a=read(),b=read(),c=read(),d=read();
        cout<<(ccw(b-a,c-a)*ccw(b-a,d-a)<0&&ccw(d-c,a-c)*ccw(d-c,b-c)<0
               ||online(b-a,c-a)||online(b-a,d-a)||online(d-c,a-c)||online(d-c,b-c))<<endl;
    }

    return 0;
}




Measured memory_bytes: 3288
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];

		int i;
		for(i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		for(i = 0; i < n; i++) {
			if(a[i] % 2 == 0) {
				if(!(a[i] % 3 == 0 || a[i] % 5 == 0)) {
					System.out.println("DENIED");
					return;
				}
			}
		}
		System.out.println("APPROVED");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
  int N = inputValue();
  int A[100000];
  int S[100000];
  REP(i, N){
    int val = inputValue();
    A[val-1] = i+1;
  }
  REP(i, N){
    cout << A[i] << " ";
  }
}


Measured memory_bytes: 1152
from collections import Counter

N = int(input())
h = [int(x) for x in input().split(" ")]
 
L = [0] * N
R = [0] * N
cnt = 0
for i in range(0, N):
    L[i] = i + 1 + h[i]
    R[i] = i + 1- h[i]
LC = Counter(L)
RC = Counter(R)

cnt = 0
for key,values in LC.most_common():
    if key in RC:
        num = RC[key]
        cnt += values * num

print(cnt)

Measured memory_bytes: 75308