akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
int main() {
  ll x,y;
  cin>>x>>y;
  ll anscount=0;
  ll now=x;
  while(now<=y){
    now*=2;
    anscount++;
  }
  putout(anscount);
}


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

#define pb            push_back
#define mp            make_pair
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<'\n'<<(#X)<<" = "<<(X)<<'\n'; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin>>s;
    
    cout<<(s[0]!='7'&&s[1]!='7'&&s[2]!='7'?"No":"Yes")<<endl;
}



Measured memory_bytes: 3660
from collections import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))

class Dinic():
    def __init__(self, n, s, t):
        self.n, self.s, self.t = n, s, t
        self.to = defaultdict(list)
        self.level = [-1]
        self.max_flow = -1

    def add_edge(self, u, v, cap):
        u_index_in_to_v = len(self.to[v])
        v_index_in_to_u = len(self.to[u])
        self.to[u].append([v, cap, u_index_in_to_v])
        self.to[v].append([u, 0, v_index_in_to_u])

    def set_level(self):
        s = self.s
        level = [-1] * self.n
        level[s] = 0
        q = deque()
        q.append([s, 0])
        while q:
            u, u_level = q.popleft()
            for v, cap, _ in self.to[u]:
                if cap == 0: continue
                if level[v] != -1: continue
                level[v] = u_level + 1
                if v == self.t:
                    self.level=level
                    return True
                q.append([v, u_level + 1])
        return False

    def dfs(self, u=-1, flow_to_me=10 ** 16):
        if u == -1: u = self.s
        if u == self.t: return flow_to_me
        flow_from_me = 0
        u_level = self.level[u]
        for utov_i, (v, cap, vtou_i) in enumerate(self.to[u]):
            if self.level[v] != u_level + 1: continue
            if cap == 0: continue
            flow_to_v = self.dfs(v, min(cap, flow_to_me - flow_from_me))
            if not flow_to_v: continue
            flow_from_me += flow_to_v
            self.to[u][utov_i][1] -= flow_to_v
            self.to[v][vtou_i][1] += flow_to_v
        return flow_from_me

    def calculation(self):
        res = 0
        while self.set_level():
            res += self.dfs()
        return res

    # これが出力用
    def get_max_flow(self):
        if self.max_flow == -1:
            self.max_flow = self.calculation()
        return self.max_flow

def main():
    n = int(input())
    aa = LI()
    mf = Dinic(n + 2, 0, n + 1)
    max_sum = 0
    for i, a in enumerate(aa, 1):
        if a > 0:
            mf.add_edge(i, n + 1, a)
            max_sum += a
        else:
            mf.add_edge(0, i, -a)
    for i in range(1, n // 2 + 1):
        for j in range(i * 2, n + 1, i):
            mf.add_edge(i, j, 10 ** 12)
    print(max(0, max_sum - mf.get_max_flow()))

main()


Measured memory_bytes: 3440
#!/usr/bin/env ruby
n, d = gets.chomp.split.map(&:to_i)

count = 0

n.times do
  x, y = gets.chomp.split.map(&:to_i)
  distance = Math.sqrt(x ** 2 + y ** 2)
  count += 1 if distance <= d
end

puts count


Measured memory_bytes: 14328
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

def solve(N: int, Z: int, W: int, a: "List[int]"):
    # memo[i][j] = 手番がi(X:0,Y:1)のときすでにj-index引いてる
    memo = [[0]*N for _ in range(2)]

    def maxValue(z:int, w:int, i: int, player:str) -> int:
        if i >= N:
            return abs(z-w)

        if player == "X": ## playerXが操作する。価値がmaxになるように
            if memo[0][i] > 0:
                return memo[0][i]

            value = 0
            for j in range(i,N):
                value = max(maxValue(a[j],w,j+1,"Y"),value)
            memo[0][i] = value
        else: ## yが操作,価値がminになるように
            if memo[1][i] > 0:
                return memo[1][i]
            value = 10**9
            for j in range(i,N):
                value = min(maxValue(z,a[j],j+1,"X"),value)
            memo[1][i] = value

        return value        

    print(maxValue(Z,W,0,"X"))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, Z, W, a)

if __name__ == '__main__':
    main()


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

int main()
{
  char c;
  cin >> c;
  if(c >= 'a' && c <= 'z') cout << 'a' << endl;
  else cout << 'A' << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;
    
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> R[i];
    }
    
    int maxv = -2000000000; //十分小さい値を初期値に設定
    int minv = R[0];
    
    for (int i=1; i<n; i++){
        // ここで毎回R[i]を読み込めば、配列は不要
        maxv = max(maxv, R[i] - minv); // 最大値を更新
        minv = min(minv, R[i]);        // ここまでの最小値を保持しておく
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3848
#include<stdio.h>
int main(void) {
	int a[1000], b[1000],x,c,d,e,f;
	int i = 0;
	int r = 1;
	while (r) {
		scanf("%d %d",&a[i],&b[i]);
		if(a[i] == 0 && b[i] == 0) {
			r = 0;
		}
		i++;
	}
	for (x = 0; x < i; x++) {
		c = a[x];
		d = b[x];
		for (e = 0; e < a[x]; e++) {
			for (f = 0; f < b[x]; f++) {
				if (e%2==0 && f%2==0) {
					printf("#");
				}
				else if(e%2==1 && f%2==1){
					printf("#");
				}else {
					printf(".");
				}
			}
			printf("\n");
		}
		if (x != i - 1) {
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2100
using System;

class Program
{
    static void Main(string[] args)
    {
        string s1 = Console.ReadLine();
        string s2 = Console.ReadLine();
        if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String[] str = S.split("/");
		int y=Integer.parseInt(str[0]);
		int m=Integer.parseInt(str[1]);
		int d=Integer.parseInt(str[2]);
		if(m>=5) {
			System.out.println("TBD");
		}else {
			System.out.println("Heisei");
		}
	}
}

Measured memory_bytes: 21332
n = int(input())
p = input().rstrip().split(' ')
count = 0
for i in range(n-2):
  buf = []
  buf.append(int(p[i]))
  buf.append(int(p[i+1]))
  buf.append(int(p[i+2]))
  buf.sort()
  if int(p[i+1]) == buf[1]:
    count = count + 1
print(count)

Measured memory_bytes: 3064
#include <array>
#include <functional>
#include <iostream>
#include <vector>

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

  std::vector<std::vector<int>> G(N);
  for (int i = 0; i < N - 1; ++i) {
    int x, y;
    std::cin >> x >> y;
    G[x - 1].push_back(y - 1);
    G[y - 1].push_back(x - 1);
  }

  int mod = 1000000007;
  std::vector<std::array<long long, 2>> dp(N, std::array<long long, 2>({0, 0}));

  std::function<long long(int, int, int)> rec = [&](int v, int c, int pv) {
    if (dp[v][c] != 0)
      return dp[v][c];
    long long res = 1;
    for (auto &nv : G[v]) {
      if (nv == pv)
        continue;
      long long tmp = rec(nv, 0, v);
      if (c == 0)
        tmp = (tmp + rec(nv, 1, v)) % mod;
      res = (res * tmp) % mod;
    }
    return dp[v][c] = res;
  };

  long long res = (rec(0, 0, -1) + rec(0, 1, -1)) % mod;
  std::cout << res << std::endl;
}


Measured memory_bytes: 18432
#!/usr/bin/env python3

N=int(input())
h=list(map(int,input().split()))
INF=10e7+7
dp=[INF for _ in range(N)]

dp[0]=0
dp[1]=dp[0]+abs(h[0]-h[1])

for i in range(2,N):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), 
            dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])


Measured memory_bytes: 13928
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){ 
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		String S = sc.next();
		char[] chars = S.toCharArray();
		int red = 0;
		int blue = 0;
		for (char ch : chars) {
			if (ch == '0') {
				red += 1;
			} else {
				blue += 1;
			}
		}
		System.out.println(S.length() - Math.abs(red - blue));
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 25812
n=int(input())

red=[]
for _ in range(n):
  a,b=map(int,input().split())
  red.append((a,b))

blue=[]
for _ in range(n):
  c,d=map(int,input().split())
  blue.append((c,d))

blue.sort()
red.sort()
cnt=0

#print(blue,red)

for item1 in blue:
  x,y=item1[0],item1[1]
  result=[]
  for item2 in red:
    xx,yy=item2[0],item2[1]
    if x>xx and y>yy:
      if result==[]:
        result=[xx,yy]
      else:
        if yy>result[1]:
          result=[xx,yy]
  if result!=[]:
    #print(x,y,result)
    red.remove((result[0],result[1]))
    cnt+=1
print(cnt)


        
        
    
  


  


Measured memory_bytes: 39152
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int value, change;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		while(read()){
			slove();
		}
	}
	static boolean read(){
		value = sc.nextInt();
		if(value == 0){
			return false;
		}
		return true;
	}
	static void slove(){
		//System.out.println(value);
		change = 1000 - value;
		int count = 0;
		while(change > 0){
			if(change >= 500){
				change -= 500;
				count++;
			}else if(change >= 100){
				change -= 100;
				count++;
			}else if(change >= 50){
				change -= 50;
				count++;
			}else if(change >= 10){
				change -= 10;
				count++;
			}else if(change >= 5){
				change -= 5;
				count++;
			}else if(change >= 1){
				change -= 1;
				count++;
			}
		}
		System.out.println(count);
	}
}

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

int main(){
    int x , a ,b ,c , d ;
    cin >> x ;
		a = x / 1000 ;
    			 b = x / 100 - a * 10 ;
     	c = x / 10 - a * 100 - b * 10 ;
     	d = x - a * 1000 - b * 100 - c * 10;
  
   if(a == b) {
     cout << "Bad" << endl ;
   }
   else if(b == c) {
     cout << "Bad" << endl ;
   }
   else if(c == d) {
      cout << "Bad" << endl ;
   }
  else{
    cout << "Good" << endl ;
  }
}


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

const ll INF = pow(10, 9) + 7;

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

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int gcd(int i, int j) {
	if (i < j)swap(i, j);
	if (i % j)return gcd(j, i % j);
	else return j;
}

int main() {

	int n, k;
	cin >> n >> k;
	vi a(n);
	int mx = 0;
	rep(i, n) {
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	int g=a[0];
	rep(i, n)g = gcd(g, a[i]);
	

	bool ok = true;
	if (mx < k)ok = false;
	if (g > 1 && k % g)ok = false;

	if (ok)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 640
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twol pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int in(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
ll m,n,ans;
int main(){FAST;xRand;
cin>>n;
for(ll i=2;i<=sqrt(n);i++){
	m=i;
	if(n%m==0){
		if(n%(m-1)==n/(m-1))
			ans+=m-1;
		if(n/m!=m&&n%(n/m-1)==n/(n/m-1))
			ans+=n/m-1;	
	}
}
if(n>2)
	ans+=n-1;
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int t[4] = { 6000,4000,3000,2000 };
    FOR(i, 0, 4) {
        int j, n;
        cin >> j >> n;
        cout << t[--j] * n << "\n";
    }
}


Measured memory_bytes: 3144
n,x,y = map(int,input().split())
dists = [0]*(n)
for i in range(1,n+1):
    for j in range(1,i):
        dists[min(abs(i-j),abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y))]+=1
    
for i in range(len(dists) - 1):
    print(dists[i+1])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int MAX = 1e6+10;
const int INF = 0x3fffffff;

int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int sum=0;
		int temp=n;
		while(n>0){
			sum+=n%10;
			n/=10;
		} 
		if(temp%sum==0)
			cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<int,int> a;
    REP(i,n) {
        int num;cin >> num;
        ++ a[num];
    }
    ll ans = 1;
    bool flag = true;
    for(auto x: a) {
        if(x.second>2 || (n%2==0 && x.second<2) || (n%2==1 && ((x.first==0 && x.second==2)||x.first>0 && x.second<1))) {
            flag = false;
            break;
        }
        if(x.second==2) ans *= 2;
        ans %= MOD;
    }
    cout << (flag ? ans : 0) << endl;
    return 0;
}

Measured memory_bytes: 3200
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n;
  cin>>n;

  int a[n];
  llong b[n+1];
  b[0] = 0;
  REP(i,n){
    cin>>a[i];
    b[i+1] = b[i] + a[i];
  }
  int p0,p1,p3,p4;
  p0 = 0;
  p1 = 1;
  p3 = 3;
  p4 = n;
  llong sumL,sumR;
  llong ans = INF;
  for(int p2=2;p2<n-1;p2++){
    sumL = b[p2] - b[p0];
    sumR = b[p4] - b[p2];
    while(p1<p2-1){
      llong d1,d2;
      d1 = abs((sumL - b[p1]) - b[p1]);
      d2 = abs((sumL - b[p1+1]) - b[p1+1]);
      if(d1<d2){
        break;
      }else{
        p1++;
      }
    }
   while(p3<p4-1){
      if(p3<=p2)p3 = p2 + 1;
      llong d1,d2;
      llong v3 = b[p3] - b[p2];
      d1 = abs((sumR - v3) - v3);
      v3 = b[p3+1] - b[p2];
      d2 = abs((sumR - v3) - v3);
      if(d1<d2){
        break;
      }else{
        p3++;
      }
    }
    llong v1 = b[p1];
    llong v2 = b[p2] - b[p1];
    llong v3 = b[p3] - b[p2];
    llong v4 = b[p4] - b[p3];
    llong hyp = max(max(max(v1,v2),v3),v4) - min(min(min(v1,v2),v3),v4);
    ans = min(ans,hyp);
  }

  cout<<ans<<endl;



  return 0;
}

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int>> v(N, vector<int>(3));
  rep(i, N) cin >> v[i][0] >> v[i][1] >> v[i][2];
  bool f = true;
  int x0 = 0, y0 = 0;
  int x1 = W, y1 = H;
  rep(i, N) {
    int xi = v[i][0];
    int yi = v[i][1];
    int ai = v[i][2];
    if (ai == 1) // x < xi
      x0 = max(x0, xi);
    if (ai == 2) // x > xi
      x1 = min(x1, xi);
    if (ai == 3) // y < yi
      y0 = max(y0, yi);
    if (ai == 4) // y > yi
      y1 = min(y1, yi);
    if (x0 >= x1 || y0 >= y1) {
      f = false;
      break;
    }
  }
  if (f) {
    int w = x1 - x0;
    int h = y1 - y0;
    cout << w * h << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
	
	int n,j,sum,max1;
		
	while(cin>>n,n){
		
		vector<int> v;
		
		for(int i=0;i<n;i++){
			cin>>j;
			v.push_back(j);
		}
		max1=v[0];

		for(int i=0;i<n;i++){
				sum=0;
			for(int j=i;j<n;j++){
				sum=sum+v[j];
				max1=max(max1,sum);
			}
		}
		cout<<max1<<endl;
		

	}
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.buffer.readline().rstrip()
read = sys.stdin.buffer.read
def resolve():
    n,q=map(int,input().split())
    data = list(map(int,read().split()))
    S = data[:3*n:3]
    T = data[1:3*n:3]
    X = data[2:3*n:3]
    D = data[3*n:]

    E=[]
    E+=[(s-x,1,x) for s,x in zip(S,X)]
    E+=[(t-x,2,x) for t,x in zip(T,X)]
    E+=[(d,3,i) for i,d in enumerate(D)]
    E.sort()
    from collections import defaultdict
    cnt=defaultdict(int)
    cnt[INF]=1

    from heapq import heappop,heappush
    Q=[INF]
    ans=[None]*q
    for a,b,c in E:
        if(b==1):
            heappush(Q,c)
            cnt[c]+=1
        elif(b==2): # 本来はここでqからcを削除したいが、できないためb==3で処理する
            cnt[c]-=1
        else:
            while(cnt[Q[0]]==0): # 本来削除されるべき通行止めをここで消す
                heappop(Q)
            x=Q[0]
            ans[c]=x if(x!=INF) else -1
    print(*ans,sep="\n")
resolve()

Measured memory_bytes: 137008
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap, pair
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt,ceil,M_PI, pow, sin
#include <sstream>	//stringstream,getline
#include <numeric>	//gcd, accumlate
#include <deque>	//deque

using namespace std;

int main() {

	int a;
	cin >> a;

	cout << a * a * 3 << endl;

	return 0;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=2e5+5;
int n,m,ans,a[N];
bool b[N];

bool check(int x){
	for(int i=1;i<=n;i++) b[i]=a[i]<=x;
	int flag=-1,mi=n;
	for(int i=2;i<=n;i++) if(b[i]==b[i-1]) if(abs(m-i)<mi){
		mi=abs(m-i);
		flag=b[i];
	}
	for(int i=n-1;i>=1;i--) if(b[i]==b[i+1]) if(abs(m-i)<mi){
		mi=abs(m-i);
		flag=b[i];
	}
	if(flag==-1) flag=b[1];
	return flag;
}

signed main(){
	m=read(n);n=n*2-1;
	for(int i=1;i<=n;i++) read(a[i]);
	int l=1,r=n;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	write(ans);
}

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

int main(){
    int n;
    cin>>n;
    vector<string>s(n);
    rep(i,n)cin>>s[i];
    int ans=0;
    rep(dy,n){
        bool ng=false;
        rep(i,n)rep(j,n){
            if(s[(dy+i)%n][j]!=s[(dy+j)%n][i])ng=true;
        }
        if(!ng)ans+=n;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3768
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

struct Edge{
    int to,cost;
    Edge(int to,int cost): to(to), cost(cost){}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool operator < (const Edge &e, const Edge &f){
    return e.cost > f.cost;
}

vector<int> dijkstra(const Graph &g, int s){
    vector<int> d(g.size(),INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0,s)); // P(dis, pos)
    while(!que.empty()){
        int dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if(d[v]<dist) continue;
        for(const auto &e: g[v]){
            if(d[e.to]<=d[v]+e.cost) continue;
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
        }
    }
    return d;
}

struct Road{
    string from, to;
    int d;
    Road(string from, string to,int d): from(from), to(to), d(d) {}
};

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

    int n,m,cap;
    while(cin>>n>>m>>cap, n){
        string src,dest;cin>>src>>dest;
        cap *= 10;
        map<string,int> mp;
        mp[src]=1;mp[dest]=2;
        vector<vector<Edge>> g(6666);
        vector<Road> roads;
        for(int i=0;i<n;i++){
            string st,gt;cin>>st>>gt;
            int d;cin>>d;
            roads.push_back(Road(st,gt,d));
        }
        vector<int> v;
        v.push_back(1);v.push_back(2);
        int idx=3;
        for(int i=0;i<m;i++){
            string s;cin>>s;
            if(mp[s]!=0) continue;
            mp[s] = idx;
            v.push_back(idx);
            idx++;
        }
        for(int i=0;i<n;i++){
            string st=roads[i].from,gt=roads[i].to;
            int d=roads[i].d;
            if(mp[st]==0){
                mp[st]=idx;
                idx++;
            }
            if(mp[gt]==0){
                mp[gt]=idx;
                idx++;
            }
            g[mp[st]].push_back(Edge(mp[gt],d));
            g[mp[gt]].push_back(Edge(mp[st],d));
        }
        int sz=v.size();
        vector<vector<int>> dis(sz+1,vector<int>(sz+1,INF));
        for(int i=1;i<=sz;i++) dis[i][i]=0;
        for(int i=1;i<=sz;i++){
            vector<int> tmp=dijkstra(g, i);
            for(int j=i+1;j<=sz;j++){
                if(tmp[j]>cap) continue;
                dis[i][j]=dis[j][i]=tmp[j];
            }
        }
        
        for(int k=1;k<=sz;k++){
            for(int i=1;i<=sz;i++){
                for(int j=1;j<=sz;j++){
                    dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
                }
            }
        }
        if(dis[1][2]>=INF) cout<<-1<<endl;
        else cout<<dis[1][2]<<endl;
    }
}


Measured memory_bytes: 4384
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]


ans = [0] * n
for i in range(n):
    if d[i][0] == d[i][1]:
        ans[i] = 1

ans.append(0)
max_cnt = 0
cnt = 0


for i in range(n + 1):
    if ans[i] == 1:
        cnt += 1
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 0

if max_cnt >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62436
s = input()
n = len(s)

k = s[0::2]
g = s[1::2]

d = 0

for i in range(len(k)):
  if k[i] == "L":
    print("No")
    d = 1
    break

if d == 0:
  for i in range(len(g)):
    if g[i] == "R":
      print("No")
      d = 1
      break
if d == 0:
  print("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N; cin >> N;
	bool ok = true;
	vector<pair<ll, ll>>pairs(N);
	ll a, b,ans=0;
	for (int i = 0;i < N;i++) {
		cin >> a >> b;
		pairs[i] = make_pair(b, a);
	}
	sort(pairs.begin(), pairs.end());
	for (int i = 0;i < N;i++) {
		ans += pairs[i].second;
		if (ans > pairs[i].first) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3328
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt)

    var answer = 0
    var now = 1

    for(i in 0 until N){
        if(A[i] == now){
            now++
        }else{
            answer++
        }
    }
    
    println(
        if(answer == N){
            -1
        }else{
            answer
        }
    )
}

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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(bool a) {
  return a ? "T" : "F";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;

const int N = 1e5 + 10;

int n, m;
pair <int, int> fa[N];
bool ok;

void init() {
  for (int i = 1; i <= n; ++i) fa[i].first = i, fa[i].second = 0;
}

pair <int, int> find(int x) {
  if (fa[x].first == x) return fa[x];
  int d = fa[x].second;
  auto t = find(fa[x].first);
  return fa[x] = make_pair(t.first, t.second + d);
}

void mrg(int l, int r, int d) {
  auto fal = find(l);
  int fl = fal.first;
  auto far = find(r);
  int fr = far.first;
  if (fl == fr) {
    ok &= (fal.second + d == far.second);
  } else {
    fa[fr].first = fl;
    fa[fr].second = fal.second + d - far.second;
  }
}

void run() {
  ok = 1;
  cin >> n >> m;
  init();
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    debug(l, r, d);
    mrg(l, r, d);
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  run();
  return 0;
}


Measured memory_bytes: 1152
def can_Travel(visits):
    current_loc = (0, 0)
    current_time = 0
    for visit in visits:
        next_loc = (visit[1], visit[2])
        distance =  abs(next_loc[0] - current_loc[0]) + abs(next_loc[1] - current_loc[1])

        if distance > visit[0] - current_time:
            return False
        elif (visit[0] - current_time - distance)%2 != 0:
            return False

    return True


n = int(input())
visits = []
for _ in range(n):
    visits.append(list(map(int, input().split())))

print("Yes" if can_Travel(visits) else "No")


Measured memory_bytes: 27380
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int area = 0;

		int A = scan.nextInt();
		int B = scan.nextInt();

		area = (A * B) - (A + B -1);

		System.out.println(area);
	}
}

Measured memory_bytes: 22100
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

  
int main()
{
    int n,m;
    scf(n),scf(m);
    
    int ans=1000003;
    rep(i,0,n)
    {
        int c,t;
        scf(c),scf(t);
        
        if(t<=m)
        ans=min(c,ans);

    }
    
    if(ans==1000003)
    cout<<"TLE";
    
    else
    prin(ans);
    
   
    
}

Measured memory_bytes: 256
n,d = map(int,input().split())
x = []
for i in range(n):
    x.append(list(map(int,input().split())))
count = 0
for i in range(n):
    for j in range(i+1,n):
        value = 0
        for k in range(d):
            value += (x[i][k] - x[j][k]) ** 2
        check = value ** (1/2)
        dotti = check.is_integer()
        if dotti:
            count += 1
print(count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    int n;
    scanf("%d",&n);
    vector<int> order;
    vector<int> vec;
    forn(i,0,n) {
        int xi;
        scanf("%d",&xi);
        vec.push_back(xi);
        order.push_back(xi);
    }
    sort(all(vec));
    int m = (n / 2) - 1;
    forn(i,0,n) {
        int xi = order[i];
        int mi = vec[m];
        if (xi <= mi) {
            mi = vec[m + 1];
        } else {
            mi = vec[m];
        }
        printf("%d\n", mi);
    }
    return 0;
}


Measured memory_bytes: 3948
#include <bits/stdc++.h> 
using namespace std; 
long long countPrimeFactors(long long x) 
{ 
    long long res = 0; 
    if (x % 2 == 0) { 
        res++; 
        while (x % 2 == 0) 
            x = x / 2; 
    } 
    for (long long i = 3; i <= sqrt(x); i = i + 2) 
    { 
        if (x % i == 0)
        { 
            res++; 
            while (x % i == 0) 
                x = x / i; 
        } 
    } 
    if (x > 2) 
        res++; 
    return res; 
} 
int main()
{
    long long A,B,i;
    cin>>A>>B;
    long long h=__gcd(A,B);
    cout<<countPrimeFactors(h)+1;
}


Measured memory_bytes: 256
N, X, Y = list(map(int, input().split()))
res = [0] * N
for j in range(1, N + 1):
    for i in range(1, j):
        res[min(j - i, abs(X - i) + abs(Y - j) + 1)] += 1

for i in range(1, N):
    print(res[i])


Measured memory_bytes: 45532
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 2019

from collections import defaultdict

S = list(input())
dic = defaultdict(int)
dic[0] += 1

ans = 0
x = 0
count = 0
for s in S[::-1]:
    x += int(s) * pow(10, count, MOD)
    x %= MOD
    ans += dic[x]
    dic[x] += 1
    count += 1

print (ans)


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

int main() {
int h,n,x,i;
int sum=0;
cin>>h>>n;
for( i=0 ;i<n;i++)

{
  cin >>x;
  sum+=x;
}   

if (sum>=h)
cout<< "Yes";
else
cout<<"No";
    return 0;
}


Measured memory_bytes: 256
//Moh_K_Imar .......
//29/08/2020  ... 5,42.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3596
#include <stdio.h>

int main(void){
  
  int a;
  int b;
  int c;
  int d;
  
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  if(a <= b){
    if(c <= d){
      printf("%d",a + c);
    }
    else{
      printf("%d",a + d);
    }
  }
  else{
    if(c <= d){
      printf("%d",b + c);
    }
    else{
      printf("%d",b + d);
    }
  }
  
  return 0;
}
   


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
D - Summer Vacation
https://atcoder.jp/contests/abc137/tasks/abc137_d

"""
import sys


from heapq import heapify, heappop, heappush

def solve(N, M, jobs):
    heapify(jobs)
    availables = []
    ans = 0
    for day in range(1, M+1):
        while jobs and jobs[0][0] <= day:
            A, B = heappop(jobs)
            heappush(availables, (-B))
        if availables:
            ans -= heappop(availables)
    return ans


def main(args):
    N, M = map(int, input().split())
    jobs = []
    for _ in range(N):
        A, B = map(int, input().split())
        jobs.append((A, B))
    ans = solve(N, M, jobs)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 17024
import java.io.*;
import java.util.*;

public class Main {
  private static long solve(char[] s) {
    long countB = 0;
    long answer = 0;
    for (char c : s) {
      if (c == 'W') {
        answer += countB;
      } else {
        countB++;
      }
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] s = reader.next().toCharArray();
    out.println(solve(s));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 25172
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt");
    if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    ll ans = 0, N = S.size();
    rep(i, N/2){
        if(S[i] != S[N-i-1]) ans++;
    }
    cout << ans << endstr;
    return 0;
}


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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int N;
V<int64_t> A;


int main() {
	cin >> N;
	A.resize(3*N);
	READALL(A);

	multiset<int64_t> large;
	set<int> small_inds;
	multiset<pair<int64_t, int>> not_in_small;

	int64_t lsum = 0, ssum = 0;


	for (int i = 0; i < 3*N; ++i) {
		if (i < N) {
			if (large.size() < N || A[i] > *large.begin()) {
				if (large.size() == N) {
					// cout << " rm " << *large.begin();
					lsum -= *large.begin();
					large.erase(large.begin());
				}
				// cout << " add " << A[i] << endl;
				large.insert(A[i]);
				lsum += A[i];
			}
		} else {
			not_in_small.emplace(A[i], i);
		}
	}

	for (auto kv : not_in_small) {
		// cout << kv.first << " " << kv.second << endl;
	}

	for (int i = 0; i < N; ++i) {
		ssum += not_in_small.begin()->first;
		// cout << " kek " << not_in_small.begin()->first << endl;
		small_inds.insert(not_in_small.begin()->second);
		not_in_small.erase(not_in_small.begin());
	}

	int64_t ans = lsum - ssum;

	// cout << lsum << " " << ssum << endl;



	int i = N;
	while (not_in_small.size() + small_inds.size() > N) {
		if (A[i] > *large.begin()) {
			lsum -= *large.begin();
			large.erase(large.begin());
			large.insert(A[i]);
			lsum += A[i];
		}
		not_in_small.erase(make_pair(A[i], i));
		int sind = *small_inds.begin();
		if (sind == i) {
			ssum -= A[sind];
			small_inds.erase(sind);
			ssum += not_in_small.begin()->first;
			small_inds.insert(not_in_small.begin()->second);
			not_in_small.erase(not_in_small.begin());
		}
		// cout << lsum << " " << ssum << endl;
		ans = max(ans, lsum-ssum);
		++i;
	}

	cout << ans << endl;
}

Measured memory_bytes: 19840
#include"bits/stdc++.h"
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<string>> S(H, vector<string>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
            if (S[i][j] == "snuke") {
                printf("%c%d\n", 'A' + j, i + 1);
                return 0;
            }
        }
    }
}

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

// one-based numbering
struct UnionFind {
	vector<int> data;
	// i: (data[i] < 0) -> group size, (data[i] > 0) -> parent;
	UnionFind(int n) {
		data.resize(n+1, -1);
	}
	int find(int x) {
		if(data[x] < 0) return x;
		else return data[x] = find(data[x]);
	}
	int size(int x) {
		return -data[find(x)];
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if(x == y) return false;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	bool same(int x, int y) {
		x = find(x); y = find(y);
		return x == y;
	}
};

int main() {
    long long n, m; cin >> n >> m;
    UnionFind uf(n);
    deque<long long> ans = {0};
    vector<int> x(m), y(m);
    for (long long i = 0; i < m; i++) {
        cin >> x[m-i-1] >> y[m-i-1];
    }
    long long cur = 0;
    for (int i = 0; i < m; i++) {
        if (uf.same(x[i], y[i])) {
            ans.push_front(cur);
        } else {
            long long p = uf.size(x[i]);
            long long q = uf.size(y[i]);
            uf.unite(x[i], y[i]);
            long long r = uf.size(x[i]);
            cur += r * (r-1) / 2 - p * (p-1) / 2 - q * (q-1) / 2;
            ans.push_front(cur);
        }
    }
    for (int i = 1; i <= m; i++) {
        cout << n * (n-1) / 2 - ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  string str;cin>>str;
  int fr=0;
  int re=0;
  for(int i=0;i<str.size();i++){
    if(str[i]=='('){
      re++;
    }else{
      if(re==0)fr++;
      else re--;
    }
  }
  for(int i=0;i<fr;i++)
    cout<<"(";
  cout<<str;
  for(int i=0;i<re;i++)
    cout<<")";
  cout<<endl;
  return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    while (n != 0 && m != 0) {
        int a[n] = {}; for (int i = 0; i < n; ++i) cin >> a[i];
        int max_price = 0;
        for (int a_i = 0; a_i < n; ++a_i) {
            for (int a_j = a_i + 1; a_j < n; ++a_j) {
                int sum_price = a[a_i] + a[a_j];
                if (sum_price <= m) max_price = max(max_price, sum_price);
            }
        }
        if (max_price == 0) cout << "NONE" << endl;
        else cout << max_price << endl;
        
        cin >> n >> m;
    }
    return 0;
}


Measured memory_bytes: 3088