akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s;
int n;
ll Bigmod(int a,int b)
{
    if(b==0)
        return 1%MOD;
    ll x=Bigmod(a,b/2);
    x=(x*x)%MOD;
    if(b%2==1)
        x=(x*a)%MOD;
    return x;
}

ll recur(int pos)
{
    if(pos==n)
    {
        if(s[pos]=='0')
            return 1ll;
        return 3ll;
    }
    if(s[pos]=='0')
        return recur(pos+1)%MOD;
    else
        return (Bigmod(3,n-pos)+2 * recur(pos+1)%MOD)%MOD;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>s;
    n=s.length()-1;
    cout<<recur(0)<<endl;


    return 0;
}


Measured memory_bytes: 6840
#include<iostream>
#include<cstring>

using namespace std;

int main()
{
  string s;
  cin>>s;
  int f=0;
  int l= sizeof(s);
  for(int i=0;i<l;i++)
  {
    if(s[2] == s[3])
    {
      if(s[4] == s[5])
      {
        f++;
      }
    }
  }
    if(f>0)
      cout<<"Yes";
    else
      cout<<"No";
    return 0;
  }


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

const int MAX_HW=410,MAX_D=12,INF=1e9,MAX_B=1<<MAX_D;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int w,h,sh,sw,n;
vector<string> S;
vector<vector<int>> dist(MAX_HW,vector<int>(MAX_HW))
                    ,dist0(MAX_D,vector<int>(MAX_D))
                    ,dp(MAX_B,vector<int>(MAX_D));
vector<pair<int,int>> dust;
queue<pair<int,int>> que;

void bfs(int x,int y){
    for (int i=0;i<h;++i)
        for (int j=0;j<w;++j)
            dist[i][j]=INF;
    dist[x][y]=0;
    que.emplace(x,y);
    while(!que.empty()){
        auto p=que.front(); que.pop();
        for (int i=0;i<4;++i){
            int nx=p.first+dx[i],ny=p.second+dy[i];
            if (nx<0||h<=nx||ny<0||w<=ny) continue;
            if (S[nx][ny]=='x'||dist[nx][ny]!=INF) continue;
            dist[nx][ny]=dist[p.first][p.second]+1;
            que.emplace(nx,ny);
        }
    }
}

int solve(){
    dust.clear();
    for (int i=0;i<h;++i){
        for (int j=0;j<w;++j){
            if (S[i][j]=='o') sh=i,sw=j;
            if (S[i][j]=='*') dust.emplace_back(i,j);
        }
    }
    dust.emplace_back(sh,sw);
    int n=dust.size();
    for (int i=0;i<n;++i){
        bfs(dust[i].first,dust[i].second);
        for (int j=0;j<n;++j)
            dist0[i][j]=dist[dust[j].first][dust[j].second];
    }
    for (int i=0;i<(1<<(n-1));++i)
        for (int j=0;j<n;++j)
            dp[i][j]=INF;
    dp[0][n-1]=0;
    for (int mask=0;mask<(1<<(n-1));++mask)
        for (int i=0;i<n;++i)
            for (int j=0;j<n-1;++j)
                if (!(mask&1<<j))
                    dp[mask|1<<j][j]=min(dp[mask|1<<j][j],dp[mask][i]+dist0[i][j]);
    int ans=INF;
    for (int i=0;i<n-1;++i) ans=min(ans,dp[(1<<(n-1))-1][i]);
    return (ans!=INF?ans:-1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> w >> h,h){
        S.resize(h);
        for (int i=0;i<h;++i) cin >> S[i];
        cout << solve() << '\n';
    }
}


Measured memory_bytes: 4128
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

	int N, R;

	cin >> N >> R;

	int ans = R;

	if (N >= 10) {
	} else {
		ans = R + 100 * (10 - N);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE LambdaCase, DeriveFunctor #-}

import           Control.Applicative
import           Control.Arrow
import           Control.Monad
import           Data.Bits
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import           Control.Monad.Fix
import qualified Data.Set                      as S



twice f x = f x x

both :: Arrow a => a b c -> a (b, b) (c, c)
both = twice (***)

readsLn :: Read a => IO [a]
readsLn = mapM readIO . words =<< getLine


main = do
  s <- getLine
  putStrLn $ if last s == 's' then s ++ "es" else s ++ "s"


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

void swap(int &a, int &b) {
    if (a > b) {
        int temp = a;
        a = b;
        b = temp;
    }
}

int main() {
    int a, b;
    int i = 1;
    while (1) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) {
            break;
        }
        else {
            swap(a, b);
            cout << a << " " << b << endl;
        }
        ++i;
        if (i > 3000) break;
    }
    return 0;
}


Measured memory_bytes: 3140
#26進数
n = gets.to_i
a = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans = ""
n -= 1
ans = a[n%26]
n = n / 26
while n > 0
  n -= 1
  ans += a[n%26]
  n = n / 26
end
puts ans.reverse


Measured memory_bytes: 14360
import sys, math

readline = sys.stdin.readline

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

F = [0] * N
div = 2
while True:
    if N // (div - 1) == 0:
        break

    for i in range(N // (div - 1) - 1, N // div - 1, -1):
        t = A[i]
        for j in range(i * 2 + 1, N, i + 1):
            t ^= F[j]
        F[i] = t
    div += 1

M = sum(F)
print(M)

s = [str(i + 1) for i, x in enumerate(F) if x == 1]
if len(s) > 0:
    print(' '.join(s))


Measured memory_bytes: 71160
class Node

  attr_accessor :id, :left_child, :right_sibling, :parent

  def initialize(id)
    @id= id
    # ここでデフォルト値を設定しているとバグの元になるので直したい
    @parent = -1
    @children = []
  end

  def get_depth
    depth = 0
    u = id
    until $tree[u].parent == -1 do
      depth += 1
      u = $tree[u].parent
    end
    depth
  end

  def get_height
    leaves = self.get_leaves
    if leaves.empty?
      0
    else
      leaf_max_depth = leaves.map{|i|$tree[i].get_depth}.max
      leaf_max_depth - $tree[self.id].get_depth
    end
  end

  def get_leaves
    return [self.id] if self.get_type == 'leaf'
    children = get_children
    leaves = children.map do |child|
      $tree[child].get_leaves
    end
    leaves.flatten
  end

  def get_degree
    get_children.size
  end

  def get_children
    if left_child.nil?
      []
    else
      u = left_child
      children = [u]
      until $tree[u].right_sibling == nil do
        u = $tree[u].right_sibling
        children << u
      end
      children
    end
  end

  def get_sibling
    # rootの時は、兄弟が存在しないから無条件に返す。
    return -1 if parent == -1
    sibling = $tree[parent].get_children - [self.id]
    if sibling.empty?
      -1
    else
      # 兄弟は最大一人
      sibling[0]
    end
  end

  def get_type
    if parent == -1
      'root'
    elsif get_children == []
      'leaf'
    else
      'internal node'
    end
  end
end

n = gets.to_i

$tree = {}

n.times do
  input = gets.split.map(&:to_i)
  id = input[0]
  left_child = input[1]
  right_child = input[2]

  children = [left_child, right_child].reject {|i| i == -1}
  children_count = children.size
  $tree[id] ||= Node.new(id)
  node = $tree[id]

  if children_count == 0
    node.left_child = nil
  else
    node.left_child = children[0]
    # 最後にnil入れるの扱いにくくなるから直したい。
    children.push(nil).each_cons(2) do |a, b|
      $tree[a] ||= Node.new(a)
      $tree[a].parent = id
      $tree[a].right_sibling = b if b
    end
  end
end

for i in 0..n - 1 do
  node = $tree[i]
  puts "node #{node.id}: parent = #{node.parent}, sibling = #{node.get_sibling}, degree = #{node.get_degree}, depth = #{node.get_depth}, height = #{node.get_height}, #{node.get_type}"
end



Measured memory_bytes: 6896
N, M = map(int, input().split())
H = list(map(int, input().split()))

ans = [False for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        ans[a-1] = True
    elif H[a-1] > H[b-1]:
        ans[b-1] = True
    else:
        ans[a-1] = True
        ans[b-1] = True

print(N-sum(ans))

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

int main() {
  vector<string> C(2);
  for(int i = 0; i < 2; i++ ) cin >> C.at(i);
  
  if( C.at(0).at(1) == C.at(1).at(1) && C.at(0).at(0) == C.at(1).at(2) && C.at(0).at(2) == C.at(1).at(0) ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define Mod 1000000007
    #define INF 1e9
    #define INFL 9e18
    #define EPS 1e-9
    #define pb push_back
    #define mp make_pair
    #define SET(a) memset(a,-1,sizeof(a))
    #define CLR(a) memset(a,0,sizeof(a))
    #define CPY(a,b) memcpy(a,b,sizeof(a))
    #define all(a) (a).begin(),(a).end()
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define N 100005
    #define fs first
    #define sc second
    using namespace std;

    typedef  long long int ll;
    typedef pair<ll,ll> ii;
    typedef vector <ii> vii;
    typedef vector <ll> vi;
  
    ll arr[N];
 
    int main()
    {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
   ios;
   ll a,b,c,n,m;
   ll ans=0,cnt=0,adi=0,flag=0;
   string str;
   ll c1=0,c2=0,f=0;

   cin>>a>>b>>str;
   for(int i=0;i<str.size();i++)
   {
    if(int(str[i])>=48 && int(str[i])<=57 && f==0)
      c1++;
    else if(str[i]=='-')
      f=1;
    else if(int(str[i])>=48 && int(str[i])<=57 && f==1)
      c2++;

   }
   //cout<<c1<<" "<<c2<<endl;
if(c1==a && c2==b && str.size()==a+b+1)
  cout<<"Yes";
else
  cout<<"No";


    return 0;


    }

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

int main(){

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

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

    long long int ans = 0;
    for(int i=1; i<n; i++){
        if(a[i]<a[i-1]){
            ans+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }

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


Measured memory_bytes: 3956
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ABC = Console.ReadLine().Trim().Split(' ');
            var (A, B, C) = (ABC[0], ABC[1], ABC[2]);
            var ab = A[A.Length - 1] == B[0];
            var bc = B[B.Length - 1] == C[0];
            Console.WriteLine(ab && bc ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 25768
#pragma GCC optimize(2)

#include<bits/stdc++.h>
#define mp			make_pair
#define rep(i,n)	for(int i=0;i<n;i++)
#define BINF		0x7fffffff
#define INF			0x3f3f3f3f
#define LINF		3223372036854775807
#define END(s)		{cout<<s;return 0;}
#define CON(s)		{cout<<s;continue;}
#define BRE(s)		{cout<<s;break;}
#define pb			push_back
//#define int			long long
#define All(a)		a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a)		(int)a.size()
#define F			first
#define S			second
const bool debug=1;
const bool files=0;
using namespace std;

int a[100100];
int n,k; 
int pos;

signed main(){
	ios::sync_with_stdio(false);
	if(files){
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
		if(a[i]==1) pos=i;
	}
	cout<<(n-1)/(k-1)+(((n-1)%(k-1))?1:0)<<endl;
	return 0;
}


Measured memory_bytes: 640
using System;

namespace ITP_7_B{
    public class Program{
        public static void Main(string[] args){
            while(true){
                string[] data = Console.ReadLine().Split(' ');
                int n = int.Parse(data[0]);
                int x = int.Parse(data[1]);

                //???????????¶
                if(n==0 && x==0) break;

                //?¨??????¨??????
                Console.WriteLine(GetCount(n,x));
            }
        }
        
        private static int GetCount(int max, int target){
            int count = 0;

            for(int i=1; i<=max-2; i++){
                for(int k=i+1; k<=max-1; k++){
                    for(int m=k+1; m<=max; m++){
                        int sum = i + k + m;
                        if(sum==target) count++;
                    }
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String S = sc.next();
        String T = sc.next();

        String[] setArrayS = S.split("");
        String[] setArrayT = T.split("");

        for (int i = 0; i < n; i++) {
            System.out.print(setArrayS[i]);
            System.out.print(setArrayT[i]);
        }

        sc.close();
    }
}

Measured memory_bytes: 35784
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll h, w, d;
    cin>>h>>w>>d;
    vvl grid(h, vl(w));
    cin>>grid;
    vector<LP> as(h * w);
    rep(i, h) rep(j, w) {
        as[grid[i][j] - 1] = LP(i, j);
    }

    vvl ss(d, vl(h * w / d + 10));
    rep(i, d) {
        ll cur = i;
        ll j = 0;
        while (cur + d < h * w) {
            ss[i][j + 1] = ss[i][j] + abs(as[cur + d].fi - as[cur].fi) + abs(as[cur + d].se - as[cur].se);
            j++;
            cur += d;
        }
    }
    ll Q;
    cin>>Q;
    rep(q, Q) {
        ll l, r;
        cin>>l>>r; l--; r--;
        ll m = l % d;
        cout<<ss[m][r / d] - ss[m][l / d]<<endl;
    }
}

Measured memory_bytes: 13184
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

# 各値毎の出現位置
B = [[] for i in range(max(A)+1)]
for i, a in enumerate(A+A):
    B[a].append(i)
# 同値が何個先で出現するかを保持する
C = [0] * N
for li in B:
    for i in range(len(li)-1):
        if li[i] >= N:
            break
        C[li[i]] = li[i+1] - li[i]

# nxt[k][i] := iからスタートして、2^kブロック移動後の現在位置
nxt = list2d(61, N, 0)
# 初期化
for i in range(N):
    # iからのスタートは、1(2^0)回目はC[i]+1先に進む
    nxt[0][i] = C[i] + 1
# ダブリングのテーブル構築
for k in range(1, 61):
    for i in range(N):
        nxt[k][i] = nxt[k-1][i] + nxt[k-1][(i+nxt[k-1][i])%N]
    if min(nxt[k]) > N*K:
        break

# N*K以内でギリギリまで現在位置を進める
def get_cur():
    i = cur = 0
    while True:
        for k in range(61):
            if cur + nxt[k][i] > N * K:
                if k != 0:
                    cur += nxt[k-1][i]
                    i = cur % N
                    break
                else:
                    return cur
cur = get_cur()

# 最後のブロックについてシミュレーションする
ans = []
s = set()
for i in range(cur, N*K):
    a = A[i%N]
    # 追加
    if a not in s:
        ans.append(a)
        s.add(a)
    # 削除
    else:
        # aが来るまで遡って削除する
        while True:
            key = ans.pop()
            s.remove(key)
            if key == a:
                break
print(*ans)


Measured memory_bytes: 277084
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        int len = S.length();
        int count = 0;

        for(int i=0; i<len/2; i++){
            if(S.charAt(i) != S.charAt(len-i-1)){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 9223372036854775806
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
int main() {
	ll ans = 0, counter = 0, maxi = -1, mini = INF, pass = 0,sum=0;
	//new
	ll n=0;
	ll irons[2000000];
	irons[0] = 0;
	cin >> n;
	rep(i, n) {
		cin >>pass;
		if (i != 0)irons[i] = irons[i - 1] +pass;
		else irons[i] = pass;
		sum += pass;
	}
	rep(i, n-1) {
		mini = min(mini, abs((sum - irons[i]) - irons[i]));
	}
	cout<<mini<<endl;
}

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

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  for(int i=1; i<round(sqrt(n)); ++i){
    if(n%i == 0){
      ans += n/i -1;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  
  int ans = 1;
  int mini;
  cin >> mini;
  rep(i, n-1) {
    int p;
    cin >> p;
    if(mini >= p) ++ans;
    mini = min(mini, p);
  }
  
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort()

ans = 0
for i in range(N):
  if AB[i][1] < M:
    ans += AB[i][0] * AB[i][1]
    M -= AB[i][1]
  else:
    ans += AB[i][0] * M
    break
print(ans)

Measured memory_bytes: 27756
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

ll n,m,sz=0;
map<pll,bool> check;
vvll g;
vll c;//size of components
vb vis;

void dfs(ll s)
{
	vis[s]=true;
	sz++;
	for(auto v: g[s])
	{
		if(!vis[v])
		{
			dfs(v);
		}
	}
	c.pb(sz);
}

int main()
{
    io;
    
	cin>>n>>m;
	
	g.resize(n);
	vis.resize(n,false);
		
	FOR(i,0,m)
	{
		ll u,v;
		cin>>u>>v;
		u--;
		v--;
		if(v>u)
		{
			swap(u,v);
		}
		if(check.find({u,v})==check.end())
		{
			check[{u,v}]=true;
			g[u].pb(v);
			g[v].pb(u);
		}
	}
	FOR(i,0,n)
	{
		sz=0;
		if(!vis[i])
		{
			dfs(i);
		}
	}
	cout<<*max_element(all(c));
    return 0;
}



Measured memory_bytes: 34968
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

ll dp[105][100050];

int main () {
  int N, W;
  cin >> N >> W;
  vi w(N), v(N);
  rep(i,N) cin >> w[i] >> v[i];

  rep(i,N) {
    rep(j,W+1) {
      chmax(dp[i+1][j], dp[i][j]);
      if (j-w[i] < 0 ) continue;
      chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}

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

int main() {
    int H, W;

    while(-1) {
        cin >> H >> W;

        if(H==0&&W==0) break;

        for(int h=0; h < H; h++) {
            for(int w=0; w < W; w++) {
                if(h==0 || h == H-1) {
                    cout << '#';
                } else if (w==0 || w == W-1) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	lint N, M;
	cin >> N >> M;

	if (M / 2 < N)
		cout << M / 2 << endl;
	else
		cout << N + (M - N * 2) / 4 << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5+5;

string s;

bool ispal(int i , int j){
    string nw = "";
    for(int a = i; a <= j; a++){
        nw += s[a];
    }
    string rv = nw;
    reverse(rv.begin() , rv.end());
    return rv == nw;
}

int main(){
    cin >> s;
    s = '#' + s;
    int n = s.size() - 1;
    if(ispal(1 , (n-1)/2) && ispal(1 , n) && ispal((n+3)/2 , n)){
        cout << "Yes";
    } else {
        cout << "No";
    }
}
/*
1234567
akasaka
12345
level
*/


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int W, H, x, y, r;
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    if (x - r >= 0 && x + r <= W && y + r <= H && y - r >= 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct Line: public pair<Point, Point> {
    Line() {}
    Line(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
};

enum {
    CROSSES,
    ORTHOGONAL,
    PARALLEL,
};

int rel_lines(const Line &l, const Line &m) {
    if (abs(dot_prod(l.second-l.first, m.second-m.first)) < EPS) {
        return ORTHOGONAL;
    } else if (abs(cross_prod(l.second-l.first, m.second-m.first)) < EPS) {
        return PARALLEL;
    } else {
        return CROSSES;
    }
}

int main() {
    size_t q;
    scanf("%zu", &q);
    for (size_t i=0; i<q; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        Point p0(x, y);

        scanf("%lf %lf", &x, &y);
        Point p1(x, y);

        scanf("%lf %lf", &x, &y);
        Point p2(x, y);

        scanf("%lf %lf", &x, &y);
        Point p3(x, y);

        Line l(p0, p1), m(p2, p3);
        printf("%d\n", rel_lines(l, m));
    }

    return 0;
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int arr[305][305];
bool taken[MAX];
int point[MAX];
int ans[310];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>arr[i][j];
		}
	}
	int asns=305;
	for(int j=0;j<m;j++)
	{
		clr(ans);
		for(int i=0;i<n;i++)
		{
			while(taken[arr[i][point[i]]])
				point[i]++;
			ans[arr[i][point[i]]]++;
		}
		int maxi=-1;
		for(int k=1;k<=m;k++)
		{
			maxi=max(maxi,ans[k]);
		}
		if(maxi==0)
			break;
		//cout<<maxi<<endl;
		asns=min(asns,maxi);
		for(int k=1;k<=m;k++)
		{
			if(ans[k]==maxi)
			{
				j++;
				taken[k]=true;
			}
		}
		j--;
	}
	cout<<asns<<endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,n=0,t,a,b,c=0;
	string s,s1,s2;
	cin>>t;
	while(t--)
    {
        cin>>a>>b;
        if(a==b)
            c++;
        else
            c=0;
        if(c>=3)
            n=1;
    }
    if(n==1)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  const int N=1e9+5;
   vector<bool> primes(N,false);
   bool isprime(int n)
   {
     for(int i=2;i*i<=n;i++)
     {
       if(n%i==0)
        return false;
     }
     return true;
   }
   //Sieve of Erastothenes
   void sieve()
   {
     primes[2]=false;
     for(int i=2;i*i<=N;i++) //this is actual marking 
     {
        if(!primes[i])
        {
            for(ll j =i*2;j<=N;j+=i)
            {
                primes[j]=true;
            }
        }
     }
   }
   int gcd(int a , int b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

  int32_t main()
  { 
    #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif
    IOS
    int h1,s1,h2,s2;
    cin>>h1>>s1>>h2>>s2;
    int mov=0;
    while(true)
    {
         h2-=s1;
         mov++;
         if(h2<=0) break;
         h1-=s2;
         mov++;
         if(h1<=0) break;
    }
    if(mov&1)
      cout<<"Yes";
    else
      cout<<"No";
   return 0;
   
}



Measured memory_bytes: 125352
def main():
    X, N = map(int, input().split())
    pList = list(map(int, input().split()))

    minusX = X
    plusX = X

    while True:

        if(minusX not in pList):
            print(minusX)
            return

        if(plusX not in pList):
            print(plusX)
            return
        
        minusX = minusX - 1
        plusX = plusX + 1
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

int main(){
    int H, W;
    int sx, sy, ex, ey;
    int dx[]={-1,1,0,0};
    int dy[]={0,0,-1,1};
    cin >> H >> W;
    cin >> sy >> sx >> ey >> ex;
    sx--;sy--;
    ex--;ey--;
    int gp[H][W];
    for(int y=0;y<H;y++){
        for(int x=0;x<W;x++){
            char c;
            cin >> c;
            if(c=='.'){gp[y][x]=0;}else{gp[y][x]=1;}
        }
    }
    priority_queue<pair<int, pair<int,int>>,
    vector<pair<int, pair<int,int>>>,
    greater<pair<int, pair<int,int>>>
    > pq;
    set<int> visited;
    pq.push(make_pair(0, make_pair(sx,sy)));
    while(!pq.empty()){
        auto now=pq.top();
        pq.pop();
        int x=now.second.first;
        int y=now.second.second;
//        cout << x << "," << y << endl;
        if(x==ex && y == ey){
            cout << now.first << endl;
            return 0;
        }
        if(visited.find(y*W+x) != visited.end()){continue;}
        visited.insert(y*W+x);
        for(int d=0;d<4;d++){
            int ty=y+dy[d];
            int tx=x+dx[d];
            if(ty<0 || ty>=H || tx<0 || tx>=W){continue;}
            if(gp[ty][tx]==1){continue;}
            pq.push(make_pair(now.first, make_pair(tx,ty)));
        }
        for(int ty=y-2;ty<=y+2;ty++){
            for(int tx=x-2;tx<=x+2;tx++){
                if(ty<0 || ty>=H || tx<0 || tx>=W){continue;}
                if(gp[ty][tx]==1){continue;}
                if(ty==y && tx == x){continue;}
                pq.push(make_pair(now.first+1, make_pair(tx,ty)));
            }
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 28224
import sys


class Bit:
    def __init__(self, n, arr):
        self.size = n
        self.tree = [0] + arr
        for i in range(1, n+1):
            if i + (i & -i) < n + 1:
                self.tree[i + (i & -i)] += self.tree[i]

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def range_sum(self, l, r):
        return self.sum(r) - self.sum(l)


def main():
    n, q = map(int, sys.stdin.buffer.readline().split())
    bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))
    for x in sys.stdin.buffer.readlines():
        q, p, x = map(int, x.split())
        if q:
            print(bit.range_sum(p, x))
        else:
            bit.add(p+1, x)


if __name__ == "__main__":
    main()


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

string s;

char before;

int count = 0;

int main()
{
	cin >> s;
	before = s[0];
	count++;
	for(int i =1;i < s.size();i++)
	{
		if(before != s[i]) count++;
		before = s[i];
	}
	cout << count - 1 << endl;
	return 0;
}


Measured memory_bytes: 636
N, L = (int(x) for x in input().split())
a = [0] * N
for i in range(N):
    a[i] = L + i
a.sort()
if 0 in a:
    print(sum(a))
elif a[0] > 0 and a[-1] > 0:
    print(sum(a[1:N]))
else:
    print(sum(a[0:N-1]))

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
//#define ls x<<1
//#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-10;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
int ans[maxn];
char s[maxn];
int sum[3],f[maxn];
int getcnt(int x){int ret=0;for(;x;x&=(x-1))ret++;return ret;}
int dfs(int x){
	if(!x)return 0;
	if(~f[x])return f[x];
	return f[x]=dfs(x%getcnt(x))+1;
}
void solve(){
	int n;scd(n);
	scanf("%s",s+1);
	int num=0;
	rep1(i,n)
		if(s[i]=='1')num++;
	rep1(i,n){
		if(num>1)sum[0]=(sum[0]*2+(s[i]-'0'))%(num-1);
		sum[1]=(sum[1]*2+(s[i]-'0'))%(num+1);
	}
	int now[2]={1,1};
	for(int i=n;i;i--){
		if(s[i]=='0')ans[i]=(now[1]+sum[1])%(num+1);
		else if(num>1)ans[i]=(-now[0]+sum[0]+num-1)%(num-1);
		else ans[i]=-1;
		if(num>1)now[0]=now[0]*2%(num-1);
		now[1]=now[1]*2%(num+1);
	}
	mst(f,-1);
	rep1(i,n)if(~ans[i])
		printf("%d\n",dfs(ans[i])+1);
	else printf("0\n");
}
int main(){
    //IOS;
    //freopen("D:\\data.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
    solve();
 
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;                                             ;;
    ;;         ;;            ;;;;;;;;;       ;;    ;;
    ;;        ;; ;;        ;;                ;;    ;;
    ;;       ;;   ;;       ;;                ;;    ;;
    ;;      ;;;;;;;;;      ;;                ;;    ;;
    ;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
    return 0;
}

Measured memory_bytes: 4980
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => -x).ToArray();
		Console.WriteLine(h.Sum(x => (h[0] - x) / 2) + h.Count(x => (h[0] - x) % 2 == 0) % 3);
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

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

int main()
{
	fastIO
	//inp_out();
	ll n;
	cin>>n;
	vvll a(n,vll(3));
	for(ll i=0;i<n;++i)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}

	ll dp[n+1][3];
	dp[0][0]=dp[0][1]=dp[0][2]=0;

	for(ll i=1;i<=n;++i)
	{
		dp[i][0]=max(dp[i-1][1]+a[i-1][0],dp[i-1][2]+a[i-1][0]);
		dp[i][1]=max(dp[i-1][0]+a[i-1][1],dp[i-1][2]+a[i-1][1]);
		dp[i][2]=max(dp[i-1][1]+a[i-1][2],dp[i-1][0]+a[i-1][2]);
	}

	cout<<max({dp[n][0],dp[n][1],dp[n][2]});
	return 0;
}



Measured memory_bytes: 8064
#include <iostream>
#include<algorithm>
using namespace std;
char a[110];
int n;
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=1;
	for (int i=1;i<n;i++)
	{
		if (a[i]!=a[i-1])
			ans++;
	}
	if (ans==4)
		cout<<"Four"<<endl;
	else
		cout<<"Three"<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 504
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    string s;
    IN s;
    OUT s[0]<<s[1]<<s[2]<<endl
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int dish[5], ans = 0;
    repi(i, 5, 0)
    {
        cin >> dish[i];
        ans += (dish[i] + 9) / 10 * 10;
        dish[i] = (dish[i] % 10 ? 10 - dish[i] % 10 : 0);
    }
    sort(dish, dish + 5);
    cout << ans - dish[4] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	int ls = s.length(), lt = t.length();
	bool r = false;
	for (int i = ls-lt; i >=0; --i)
	{
		bool f = true;
		for (int j = 0; j < lt; ++j)
		{
			if (s[i + j] != '?' && s[i + j] != t[j])
			{
				f = false;
				break;
			}
		}
		if (f)
		{
			for (int j = 0; j < lt; ++j)
			{
				s[i + j] = t[j];
			}
			r = true;
			break;
			
		}
	}
	for (int i = 0; i < ls; ++i)
		if (s[i] == '?')
			s[i] = 'a';
	if (r)
		cout << s;
	else
		cout << "UNRESTORABLE";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const double PI = acos(-1);

int X[200050], Y[200050];

int flip(int s) {
  return 100000000 - s - 1;
}

int lis(const vector<int>& a) {
  const int n = a.size();
  if (n == 0) {
    return 0;
  }

  vector<int> A(n, INF), id(n);
  for (int i = 0; i < n; ++i) {
    id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i]));
    A[id[i]] = a[i];
  }
  return *max_element(id.begin(), id.end()) + 1;
}

int main() {
  int sx = in();
  int sy = in();
  int gx = in();
  int gy = in();
  int N = in();

  for (int i = 0; i < N; ++i) {
    X[i] = in();
    Y[i] = in();
  }

  if (sx > gx) {
    sx = flip(sx);
    gx = flip(gx);
    for (int i = 0; i < N; ++i) {
      X[i] = flip(X[i]);
    }
  }
  if (sy > gy) {
    sy = flip(sy);
    gy = flip(gy);
    for (int i = 0; i < N; ++i) {
      Y[i] = flip(Y[i]);
    }
  }
  if (gx - sx < gy - sy) {
    swap(sx, sy);
    swap(gx, gy);
    for (int i = 0; i < N; ++i) {
      swap(X[i], Y[i]);
    }
  }

  map<int, int> xpos;
  for (int i = 0; i < N; ++i) {
    xpos[Y[i]] = X[i];
  }

  bool stairs = true;
  for (int y = sy, px = -1; y < gy; ++y) {
    if (xpos.count(y) == 0) {
      stairs = false;
      break;
    }
    int x = xpos[y];
    if (x < sx || x > gx) {
      stairs = false;
      break;
    }
    if (px != -1 && x < px) {
      stairs = false;
      break;
    }
    px = x;
  }

  if (stairs) {
    double res = 0;
    res += (5 * PI - 20) * (gy - sy);
    if (xpos.count(gy) > 0) {
      const int lx = xpos[gy];
      const int px = (sy < gy ? xpos[gy - 1] : sx);
      if (px <= lx && lx <= gx) {
        res += (10 * PI - 20);
      }
    }
    printf("%.13f\n", res + ((gx - sx) + (gy - sy)) * 100.0);
    return 0;
  }

  vector<pair<int, int>> F;
  for (int i = 0; i < N; ++i) {
    if (sy <= Y[i] && Y[i] <= gy && sx <= X[i] && X[i] <= gx) {
      F.emplace_back(Y[i], X[i]);
    }
  }
  sort(F.begin(), F.end());

  vector<int> xs;
  for (const auto& p : F) {
    xs.push_back(p.second);
  }

  int L = lis(xs);
  double res = (5 * PI - 20) * L;
  printf("%.13f\n", res + ((gx - sx) + (gy - sy)) * 100.0);

  return 0;
}


Measured memory_bytes: 15860
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef unsigned int uint;

int n, k;
ll S[200020];
int T[200020];
void update(int x) {
	for(int i=x;i<=n+1;i+=(i&-i)) T[i]++;
}

int read(int x){
	int res = 0;
	for(int i=x;i;i-=(i&-i)) res += T[i];
	return res;
}

void solve(){
	scanf("%d%d", &n, &k);
	for(int i=1;i<=n;i++) {
		int x; scanf("%d", &x);
		S[i] = S[i-1] + x - k;
	}
	vector <ll> V;
	for(int i=0;i<=n;i++) V.pb(S[i]);
	sort(all(V)); V.resize(unique(all(V)) - V.begin());
	int P[200020];
	for(int i=0;i<=n;i++) {
		P[i] = (int)(lower_bound(all(V), S[i]) - V.begin() + 1);
	}
	update(P[0]);
	ll ans = 0;
	for(int i=1;i<=n;i++) {
		ans += read(P[i]);
		update(P[i]);
	}
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}


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

int main(){
  int A,B,ans=-1,C,D;
  cin>>A>>B;
  for(int i=1;i<10001;i++){
    C=i*0.08;
    D=i*0.1;
    if(A==C and B==D){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int main (){
	int n;
	string s1, s2;
	string b="CODEFESTIVAL2016";
	cin>>s1;
	int cant=0;
	forn(i, 16){
		if(s1[i]!=b[i]){
			cant++;
		}
	}
	cout<<cant<<endl;
}


Measured memory_bytes: 384