akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int n;
cin>>n;
if(n%2==0)cout<<n/2-1<<endl;
else cout<<n/2<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define ip1(arr, n) for(int i=1; i<=n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define inf 1e9
#define INF 1e16
#define MOD 1000000007
 
 
int main(){

    ll n,d;
    cin>>n>>d;
 
    ll ans=0;
    for(int i=0; i<n; i++){
        ll x,y;
        cin>>x>>y;
        ans += ((x*x + y*y) <= (d*d));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String line = sc.nextLine();
			if(line.equals(".")==true) break;
			String[] line2 = line.split("");
			Stack<String> stack = new Stack<String>();
			boolean flag=true;
			for(int i=0;i<line2.length;++i){
				if(line2[i].matches("[(\\[]")==true){
					stack.add(line2[i]);
				}
				if(line2[i].equals(")")==true){
					if(!stack.isEmpty()&&stack.peek().equals("(")==true) stack.pop();
					else flag=false;
				}
				if(line2[i].equals("]")==true){
					if(!stack.isEmpty()&&stack.peek().equals("[")==true) stack.pop();
					else flag=false;
				}
				if(flag==false) i=line2.length;
			}
			if(stack.isEmpty()&&flag==true) System.out.println("yes");
			else System.out.println("no");
		}
	}
}



Measured memory_bytes: 106444
INF = 10 ** 20

def main():
  m, n = map(int, input().split())
  manju_lst = [int(input()) for i in range(m)]
  manju_lst.sort(reverse=True)
  
  acc = 0
  cum_sum = [0]
  for manju in manju_lst:
    acc += manju
    cum_sum.append(acc)
  
  clst = []
  elst = []
  
  for i in range(n):
    c, e = map(int, input().split())
    clst.append(c)
    elst.append(e)
  
  dp = [[INF] * (m + 1) for _ in range(n + 1)]
  for i in range(n + 1):
    dp[i][0] = 0
  #dp[x][y]...x種類目までの箱でy個まで売る時の最小コスト
  #dp[x][y] = min(dp[x - 1][y], dp[x - 1][y - cx] + ex) if (y - cx >= 0) else min(dp[x - 1][y], (dp[x - 1][y + 1] if (y + 1 <= m) else ex))
  
  for x in range(1, n + 1):
    cx = clst[x - 1]
    ex = elst[x - 1]
    predp = dp[x - 1]
    for y in range(m, 0, -1):
      predp_y = predp[y]
  
      if y >= cx:
        comp = predp[y - cx] + ex
      elif y + 1 <= m:
        comp = dp[x][y + 1]
      else:
        comp = ex
  
      if predp_y <= comp:
        dp[x][y] = predp_y
      else:
        dp[x][y] = comp
  
  dpn = dp[n]
  print(max([cum_sum[x] - dpn[x] for x in range(m + 1)]))

main()


Measured memory_bytes: 61404
#include<bits/stdc++.h>
using namespace std;
using LL=int64_t;
const int INF=0x3f3f3f3f;
const int maxn=1e5+5;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    m/=1000;
    for(int i=0;i*10<=m&&i<=n;i++) {
        for(int j=0;j*5+i*10<=m&&i+j<=n;j++) {
            for(int k=0;k+j*5+i*10<=m&&i+j+k<=n;k++) {
                if(k+j*5+i*10==m&&i+j+k==n) {
                    cout<<i<<" "<<j<<" "<<k<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"-1 -1 -1";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 505
#define int long long
using namespace std;
int n,m,a[N],p[N*N],tot,cnt,K,L[N],R[N];
bool check(int x){
	memset(L,0,sizeof(L));memset(R,0,sizeof(R));
	for(int i=1;i<=n;i++){
		int t=a[i]%x;
		L[i]=t;
	}
	sort(L+1,L+n+1);R[n]=x-L[n];
	for(int i=n-1;i>=1;i--)R[i]=R[i+1]+x-L[i];
	for(int i=2;i<=n;i++)L[i]+=L[i-1];
	int res=1e9;
	for(int i=1;i<=n;i++)res=min(res,max(L[i],R[i+1]));
	return res<=K;
}
signed main(){
	scanf("%lld%lld",&n,&K);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),m+=a[i];
	for(int i=1;1ll*i*i<=1ll*m;i++)
		if(m%i==0){
			p[++tot]=i;
			if(1ll*i*i!=1ll*m)p[++tot]=m/i;
		}
	sort(p+1,p+tot+1);
	for(int i=tot;i>=1;i--){
		if(check(p[i])){
			printf("%lld\n",p[i]);
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
int n, m ,x;
vector<long long int> H(100001, 0);
vector<vector<pair<long long int, long long int>>> root(100001);
vector<long long int> dist(100001, LLONG_MAX);
vector<long long int> high(100001, 0);
bitset<100001> used;

void Dijkstra(long long int start = 1){
    priority_queue< tuple<long long int, long long int, long long int>, vector<tuple<long long int, long long int, long long int>>, greater<tuple<long long int, long long int, long long int>> > que;
    que.push(make_tuple(0, start, x));
    while(!que.empty()){
        long long int d, t, h;
        tie(d, t, h) = que.top(); que.pop();
        if(used[t]) continue;
        used[t] = true, dist[t] = d, high[t] = h;
        for(auto e : root[t]){
            long long int cost = d + e.first, nh = h - e.first;
            if(nh > H[e.second]) cost += nh - H[e.second], nh = H[e.second];
            if(nh < 0) cost += abs(0 - nh), nh = 0;
            if(dist[e.second] <= cost) continue;
            que.push(make_tuple(cost, e.second, nh));
        }
    }
}


int main(int argc, const char * argv[]) {
    cin >> n >> m >> x;
    for(int i = 0; i < n; ++i) cin >> H[i + 1];
    for(int i = 0; i < m; ++i){
        long long int a, b, c;
        cin >> a >> b >> c;
        if(H[a] >= c) root[a].emplace_back(c, b);
        if(H[b] >= c) root[b].emplace_back(c, a);
    }
    
    Dijkstra();
    if(dist[n] == LLONG_MAX) cout << -1 << endl;
    else cout << dist[n] + ((high[n] == H[n]) ? 0 : H[n] - high[n]) << endl;
    
    return 0;
}



Measured memory_bytes: 35804
#include<cstdio>

#define MOD 1000000007

long long int x[1000000];
long long int y[1000000];

int main(void) {
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; i++)
        scanf("%lld",&x[i]);
    for(int i=0; i<m; i++)
        scanf("%lld",&y[i]);

    long long int lx=0, ly=0;
    for(int i=0; i<n-1; i++)
        lx += (x[i+1] - x[i])*(i+1) * (n-i-1), lx %= MOD;
    for(int i=0; i<m-1; i++)
        ly += (y[i+1] - y[i])*(i+1) * (m-i-1), ly %= MOD;

    printf("%lld\n", lx*ly % MOD);
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
map<string,int> a;
#define ll long long
int main()
{
	int n,num=0;
	string s;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(a[s]==0)
		{
		    num++;
			a[s]++;	
		} 
		else
		a[s]++;
	}
	cout<<num;
    return 0;
}


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

/* gcd(a,b,c) = gcd(gcd(a,b),c) */

int gcd(int a,int b){ /*ユークリッドの互除法*/
    if ( a % b == 0)
        return b;

    return gcd(b, a % b);
}

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

Measured memory_bytes: 3572
#include<stdio.h>
#include<math.h>

int main()
{
    int a, b, c, i, k, sum;

    scanf("%d%d%d\n", &a, &b, &c);
    scanf("%d", &k);

    sum = a*pow(2, k)+b+c;

    if(a<=b){
        sum = a+b*pow(2, k)+c;
    }
    if(b<=c){
        sum = a+b+c*pow(2, k);
    }
    if(c<=a){
        sum = a*pow(2, k)+b+c;
    }

    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<list>
#include<climits>
#define endl '\n'
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define PI acos(-1)
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int a, b, c,d;
	cin>>a>>b>>c>>d;int q=0;
	while(a>0&&c>0)
	{
       if(q%2==0)
	   {
		   q++;
		   c=c-b;
	   }
	   else
	   {
		   q++;
		   a= a-d;
	   }
	   
	}
	if(a>0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
	return 0;
}

Measured memory_bytes: 3640
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

const int N = 410;

int dp[N][N];// [i,j] total cost
int a[N];
int sum[N];
int n;
int32_t SALI()
{

    cin >> n; for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) sum[i] = a[i] + sum[i-1];
    //for(int i = 1; i <= n; i++) dp[i][i] = a[i];
    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= n-i+1; j++){
            // [j,i+j-1]
            int k = j;
            dp[j][i+j-1] = (sum[k] - sum[j-1]) + (sum[i+j-1] - sum[k]) + dp[j][k] + dp[k+1][i+j-1];
            for(k = j+1; k < i+j-1; k++){ // [j,k] , [k+1,i+j-1]
                dp[j][i+j-1] = min(dp[j][i+j-1] , (sum[k] - sum[j-1]) + (sum[i+j-1] - sum[k]) + dp[j][k] + dp[k+1][i+j-1]);
            }
        }
    }
    cout << dp[1][n];
}




/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MAXN=1e5+5;
int dp[MAXN];
vector<vi> adj(MAXN);

void dfs(int u) {
    if(dp[u] >= 0) return;
    dp[u]=0;
    for(auto to : adj[u]) {
        dfs(to);
        dp[u] |= MAX(dp[to] + 1);
    }
}

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

    int n,m; cin>>n>>m;
    FOR(i,m) {
        int a,b;
        cin>>a>>b; a--; b--;
        adj[a].push_back(b);
    }

    memset(dp, 0xff, sizeof dp);
    FOR(i,n)
        dfs(i);

    cout<<*max_element(dp, dp+n)<<endl;

    return 0;
}



Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int X, N;
    cin >> X >> N;
    vector<int> P(N);
    for (int i = 0; i < N;i++)
    {
        cin >> P[i];
    }
    int ans = 0;
    for (int i = 0; i <= 101; i++)
    {
        bool ok = true;
        for (int j = 0; j < N; j++)
        {
            if(P[j] == i){
                ok = false;
            }
        }
        if(abs(X - i) < abs(X -ans) && ok){
            ans = i;
        }
    }
    cout << ans << endl;
}


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

int main(void){
  
  int N;
  cin >> N;
  
  
  vector<int> vec(N); // a box for an integer sequence A of length N

  // input for the box
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int absoluteMaxDifference = vec.at(vec.size() - 1) - vec.at(0); //Find the maximum absolute difference
  
  cout << absoluteMaxDifference << endl; 
}

Measured memory_bytes: 256
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))



x = II()
m = 100
i = 0
while(1):
	if m >= x:
		break
	m *= 1.01
	m = int(m)
	i += 1
print(i)

Measured memory_bytes: 68296
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

bool is_prime(int64_t x) {
    for(int64_t i = 2; i * i <= x; i++) {
        if(x % i == 0) return false;
    }
    return true;
}

int main(void) {
    vector<int> ans(100001);
    for(int i=3; i<ans.size(); i+=2) {
        if(is_prime(i) && is_prime((i+1)/2)) {
            ++ans[i];
        }
    }

    partial_sum(ans.begin(), ans.end(), ans.begin());

    int Q;
    cin >> Q;
    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << ans[r] - ans[l-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
fn main() {
  use std::io::Read;
  let mut input = String::new();
  std::io::stdin().read_to_string(&mut input).unwrap();
  let mut tok = input.split_whitespace();
  let n : usize = tok.next().unwrap().parse().unwrap();
  let t : usize = tok.next().unwrap().parse().unwrap();
  let v : Vec<usize> = tok.map(|s| s.parse().unwrap()).collect();
  let mut ans = t;
  for i in 0..n-1 {
    ans += std::cmp::min(t, v[i+1] - v[i]);
  }
  println!("{}", ans);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define Endl '\n'

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    fastio;
    ll ans=0, N;
    cin >> N;
    map<int,int> s;
    rep1(i,N) {
        int t;
        cin >> t;
        int d = i - t;
        if (s.count(d))
            ans += s[d];
        s[t + i]++;
    }
    cout << ans << Endl;
}


Measured memory_bytes: 13004
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k,c=map(int,input().split())
s=input()

l_lst=[0]*k
r_lst=[0]*k

l=-float('inf')
cnt=0
for i in range(n):
    if i-l>c and s[i]!="x":
        l_lst[cnt]=i
        cnt+=1
        l=i
        if cnt==k:
            break
# print(l_lst)
l=float('inf')
cnt=0
for i in range(n)[::-1]:
    if l-i>c and s[i]!="x":
        r_lst[-1-cnt]=i
        cnt+=1
        l=i
        if cnt==k:
            break
# print(r_lst)

for i,j in zip(l_lst,r_lst):
    if i==j:
        print(i+1)

Measured memory_bytes: 79244
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define  f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

ll d[101][100001];

int main(){
	int n;cin>>n;
	ll W;cin>>W;
	
	ll w[n+1],v[n+1];
	
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	
	for(int i=1;i<=n;i++){
		for(ll j=1;j<=W;j++){
			if(j-w[i]>=0){
				d[i][j]=d[i-1][j-w[i]]+v[i];
				
			}
			
			d[i][j]=max(d[i][j],d[i-1][j]);
		}
	}
cout<<d[n][W];
}

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

using namespace std;

#define inf (ll)1e18
#define ll long long
#define all(x) x.begin(), x.end()
#define X first
#define Y second

const int N = 1000060;

const int mod = (int)1e9 + 7;
const int MX = 1000020;


int main(){

    cin.tie(0);
    cin.sync_with_stdio(0);

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

  	int n, a, b;
  	cin >> n >> a >> b;

  	cout << min(b, n * a) << endl;
  	
    return 0;	
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < int(n); ++i)
 
int rab[100];
int ang[100];
 
int main() {
  int n, k, r;
  cin >> n >> k;
  rep (i, k) {
    int m;
    cin >> m;
    rep (j, m) {
      int b;
      cin >> b;
      rab[b] = i;
    }
  }
  cin >> r;
  int res = 0;
  rep (i, r) {
    int p, q;
    cin >> p >> q;
    if (rab[p] == rab[q]) {
      ang[p] = 1;
      ang[q] = 1;
    }
  }
  rep (i, 100) res += ang[i];
  cout << res << endl;
  return 0;
}

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

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

int main(void) {
    int n, m, ans = 0, score = 0;
    string s[100], t[100];

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> s[i];
    }
    cin >> m;
    REP(i, m) {
        cin >> t[i];
    }
    REP(i, n) {
        score = 0;
        REP(j, n) {
            if (s[i] == s[j]) {
                score++;
            }
        }
        REP(j, m) {
            if (s[i] == t[j]) {
                score--;
            }
        }
        
        ans = max(ans, score);
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int nC2 = n * (n - 1) / 2;
		System.out.println(nC2 - n / 2);

		int sum = n;
		if (n % 2 == 0) {
			sum++;
		}

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (i + j != sum) {
					System.out.println(i + " " + j);
				}
			}
		}
	}

}


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

int dp[100005] = {};
vector<vector<int> > XY(100005, vector<int>());

int path(int start)
{
  if (dp[start] != -1)
  {
    return dp[start];
  }
  
  dp[start] = 0;
  for (int i = 0; i < XY[start].size(); i++)
  {
    dp[start] = max(dp[start], path(XY[start][i]) + 1);
  }
  return dp[start];
}

int main()
{
  int N, M;
  cin >> N >> M;
  for (int m = 1; m <= M; m++)
  {
    int x, y;
    cin >> x >> y;
    XY[x].push_back(y);
  }
  
  for (int n = 1; n <= N; n++)
  {
    dp[n] = -1;
  }
  int ans = 0;
  for (int n = 1; n <= N; n++)
  {
    ans = max(ans, path(n));
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7424
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int A[100001],B[100001];
	int pmin=INF,rmax=0;
	scan(N);
	rep(i,N){
		scan(A[i]);scan(B[i]);
		if(A[i]>rmax){
			rmax=A[i];
			pmin=B[i];
		}
	}
	prin(rmax+pmin);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
  
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;
 
       
     
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}



Measured memory_bytes: 2124
import sys
sys.setrecursionlimit(200000)

n = int(input())
edge = [[] for _ in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    edge[u - 1].append((v - 1, w))
    edge[v - 1].append((u - 1, w))
dp = [-1] * n

def dist(x, prev, d):
    dp[x] = d
    for i, j in edge[x]:
        if i == prev:
            continue
        if dp[i] != -1:
            continue
        dist(i, x, d + j)
    return

dist(0, -1, 0)
for i in range(n):
    if dp[i] % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 172192
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            count++;
        }
    }
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 3920
n,m = gets.split.map &:to_i
$abs = Array.new(n).map{ Hash.new }

m.times{
	a,b = gets.split.map &:to_i
	$abs[a-1][b-1] = true
	$abs[b-1][a-1] = true
}

$walked = Array.new(m, false)

def walk(start)
	next_n = [start]
	$walked[start] = true
	size = 1
	
	while next_n.size > 0
		temp = []
		next_n.each{ |node|
			$abs[node].keys.each{ |k|
				if ! $walked[k] then
					temp << k
					$walked[k] = true
					size += 1
				end
			}
		}
		next_n = temp
	end

	#print size
	size
end

max = 1

$abs.each_with_index{ |nodes, i|
	if nodes.size > 0 && $walked[i] == false then
		size = walk(i)
		if max < size then
			max = size
		end
	end
}

puts max


Measured memory_bytes: 68664
input()
s = input()

#west = 西 = 左
#east = 東 = 右

result = 3*10**5

Wcount = 0  #左側で左を向いてる人をカウント
Ecount = s.count("E") #右側で右を向いてる人をカウント

for n,i in enumerate(s):
    Wflag = False
    if i == "W":
        Wflag = True
    else:
        Ecount -= 1
    if result > Wcount+Ecount:
        result = Wcount+Ecount
    if Wflag:
        Wcount += 1

print(result)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region UnionFind
struct UnionFind
{
    vector<int> d;
    // d[x] is the index of the parent of x
    // d[x] is -size if x is a root

    UnionFind(int n) : d(vector<int>(n, -1)) {}
    int root(int x)
    {
        if (d[x] < 0)
        {
            return x;
        }
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
        {
            return false;
        }
        if (d[x] > d[y])
            swap(x, y); // x always bigger tree

        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x) { return -d[root(x)]; }
};
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uft(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uft.unite(a, b);
    }
    int ans = 0;
    rep(i, n)
    {
        ans = max(ans, uft.size(i));
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
  long long int n , a[100010];
  
  cin >> n;
  
  for(int i=0;i<n;i++)
   cin >> a[i];
  
  
  long long int ans = 1000000000000000000;
  long long int res = 1;
  
  for(int i=0;i<n;i++){
     if(a[i] == 0){
      cout << "0" << endl;
      return 0;
    }
  }
  
  for(int i=0;i<n;i++){
    
    ans /= a[i];
    
    if(ans < 1 ){
      cout << "-1" << endl;
      return 0;
    }
    
    res *= a[i];
  }
  
  cout << res << endl;
  
}
    
    

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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N, K;
    cin >> N >> K;
    vvi snuke(N);
    rep(i, K) {
        int t;
        cin >> t;
        rep(j, t) {
            int m;
            cin >> m;
            snuke[m - 1].push_back(i);
        }
    }
    int no = 0;
    rep(i, N) {
        if (snuke[i].empty()) {
            no++;
        }
    }
    cou(no);

}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

int main(void){
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vector<bool> memo(n+100, false);
  memo[0] = true;
  vector<int> a(n);
  REP(i, n){
    cin >> a[i];
    a[i]--;
  }
  vector<int> visit;
  visit.push_back(0);

  int val;
  val = a[0];
  REP(i, n+100){
    if (!memo[val]) {memo[val] = true;
      visit.push_back(val);
      val = a[val];}
    else{
      break;
    }
  }
  int index;
  REP(i, n+100){
    if (visit[i] == val) {index = i;break;}
  }
  ll ans;
  ll size = visit.size();
  if (k < size) ans = visit[k];
  else{
    ll syuki = size - index;
    ll total = k - index;
    int num = total % syuki;
    ans = visit[num+index];
  }
  cout << ans + 1 << endl;
  return 0;
}



Measured memory_bytes: 5160
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p[210000];
int q[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++)scanf("%d",q+i);
	long long ret=0;
	queue<int>Q;
	for(int i=0;i<a;i++){
		if(q[i]>q[(i-1+a)%a]+q[(i+1)%a]){
			Q.push(i);
		}
	}

	while(Q.size()){
		int i=Q.front();

		Q.pop();
	//	for(int i=0;i<a;i++)printf("%d ",q[i]);printf("\n");fflush(stdout);
		if(p[i]>q[i]){
			ret=-1;
			break;
		}
		int am=q[i]%(q[(i-1+a)%a]+q[(i+1)%a]);
		if(p[i]==q[i])continue;
		if(am>=p[i]){
			ret+=q[i]/(q[(i-1+a)%a]+q[(i+1)%a]);
			q[i]=am;
			
		}else if((q[i]-p[i])%(q[(i-1+a)%a]+q[(i+1)%a])==0){
			ret+=(q[i]-p[i])/(q[(i-1+a)%a]+q[(i+1)%a]);
			q[i]=p[i];
			
		}else{
			ret=-1;break;
		}
		if(q[(i-1+a)%a]>(q[i]+q[(i-2+a)%a])&&p[(i-1+a)%a]!=q[(i-1+a)%a]){
			Q.push((i-1+a)%a);
		}
		if(q[(i+1)%a]>(q[i]+q[(i+2)%a])&&p[(i+1+a)%a]!=q[(i+1+a)%a]){
			Q.push((i+1)%a);
		}
	}
	for(int i=0;i<a;i++)if(p[i]!=q[i])ret=-1;
	printf("%lld\n",ret);
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define debug 1

int main() {
	int n,h,hmax=0;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++) {
		scanf("%d",&h);
		if(h>=hmax) {
			ans++;
			hmax=h;
		}
	}
	cout<<ans<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc173/abc173_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  map<string, int> c;
  rep(i, N) {
    string s;
    cin >> s;
    c[s]++;
  }

  vector<string> v = {"AC", "WA", "TLE", "RE"};
  for (auto i : v) {
    printf("%s x %d\n", i.c_str(), c[i]);
  }
}

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

int main() {
//    freopen("input.txt", "r" ,stdin);
//    freopen("output.txt", "w", stdout);
    int t;
    t = 1;
    while(t--){
        ll n, k;
        cin>>n>>k;
        vector<pair<ll, ll>> v;
        for(int i = 0; i < n; i++){
            int a, b;
            cin>>a>>b;
            v.push_back({a, b});
        }

        ll dp[n][k+1];
        for(int i = 0; i < n; i++){
            for(int j = 0; j <= k; j++){
                dp[i][j] = 0;
            }
        }
        
        sort(v.begin(), v.end());
        for(int i = 0; i <= k; i++){
            if(i >= v[0].first){
                dp[0][i] = v[0].second;
            }
        }

        for(int i = 1; i < n; i++){
            for(int j = 0; j <= k; j++){
                if(j < v[i].first){
                    dp[i][j] = dp[i-1][j];
                }
                else{
                    dp[i][j] = max(dp[i-1][j], dp[i-1][j-v[i].first] + v[i].second);
                }
            }
        }

        cout<<dp[n-1][k]<<endl;

    }
    
    return 0;
}

Measured memory_bytes: 81496
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define f first
#define s second
#define inf 1000000007

ll H,W,K;
ll dp[10][110];

ll kukan(ll l, ll r){
    ll len = r-l;
    if (len <= 0) return 1;
    if (len == 1) return 2;
    if (len == 2) return 3;
    if (len == 3) return 5;
    if (len == 4) return 8;
    if (len == 5) return 13;
    if (len == 6) return 21;
    if (len == 7) return 34;
    else return 1;
}

int main() {
    scanf("%lld%lld%lld",&H,&W,&K);
    dp[0][0] = 1;
    repi(i,1,W) dp[i][0] = 0;
    repi(j,1,H+1){
        rep(i,W){
            if (i != 0 && i!=W-1){
                dp[i][j] = (dp[i-1][j-1]*kukan(0,i-2)*kukan(i+1,W-1))%inf;
                dp[i][j] += (dp[i+1][j-1]*kukan(0,i-1)*kukan(i+2,W-1))%inf;
                dp[i][j] += (dp[i][j-1]*kukan(0,i-1)*kukan(i+1,W-1))%inf;
            }
            else if(i == 0){
                dp[i][j] += (dp[i+1][j-1]*kukan(i+2,W-1))%inf;
                dp[i][j] += (dp[i][j-1]*kukan(i+1,W-1))%inf;
            }
            else{
                dp[i][j] += (dp[i-1][j-1]*kukan(0,i-2))%inf;
                dp[i][j] += (dp[i][j-1]*kukan(0,i-1))%inf;
                
            }
                
            
        }
    }
    cout << dp[K-1][H] %inf<< endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int island[14][14];
void field(int x,int y){
	if(island[x][y] == 0)	return;
	island[x][y] = 0;
	field(x+1,y);
	field(x-1,y);
	field(x,y+1);
	field(x,y-1);
}

int main(void){
	int n;  string s;
	
	while(cin>>s){
		bool f = true;
		for(int i = 0 ; i < 12 ; i ++){
			if(!f)	cin>>s;
			for(int j = 0 ; j < 12 ; j ++){
				island[i + 1][j + 1] = s[j]-'0';
			}
			f = false;
		}
		
		int cnt = 0 ;
		for(int i = 1 ; i < 13 ; i ++){
			for(int j = 1; j < 13 ; j ++){
				if(island[i][j] == 1){
					field(i,j);
					cnt ++;
				}
			}
		}
		cout<<cnt<<endl;
		getline(cin, s);
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
int main(){
	long long n, mod = 1e9+7, ans = 1, x = 1, y = 1; 
	std::cin >> n;
	for(int i = 0; i < n; i++) 
		ans = (ans*10)%mod, x = (x*9)%mod, y = (y*8)%mod;
	ans = (ans - 2*x + y)%mod;
	if(ans<0) ans += mod;
	std::cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3620
(* Vicfred
 * https://atcoder.jp/contests/abc148/tasks/abc148_c
 * math
 * *)
open Printf
open Scanf

let rec gcd a b =
    if b == 0 then a
    else gcd b (a mod b)

let lcm a b = (a / gcd a b) * b

let main = scanf "%d %d" lcm |> printf "%d\n"



Measured memory_bytes: 3780
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let mut p: Vec<f64> = read_vec();
    p.insert(0, 0.0);

    let mut dp: Vec<Vec<f64>> = vec![vec![0.0; n+1]; n+1];
    for i in 0..n+1 {
      for j in 0..i+1 {
        if i == 0 && j == 0 {
          dp[i][j] = 1.0 - p[i];
        }
        else if i > 0 && j == 0 {
          dp[i][j] = (1.0 - p[i]) * dp[i-1][j];
        }
        else if i > 0 && j > 0 {
          dp[i][j] = p[i] * dp[i-1][j-1] + (1.0 - p[i]) * dp[i-1][j];
        }
      }
    }

    let mut res: f64 = 0.0;
    let m: usize = n / 2 + 1;
    for i in m..n+1 {
      res += dp[n][i];
    }
    println!("{}", res);
}


Measured memory_bytes: 90364
#include <iostream>
#include <queue>
using namespace std;
int main(){
	long long n;
	cin>>n;
	if(n%2==1||n==0){
		cout<<0<<endl;
	}else{
		long long ans=0;
		ans+=n/10;
		n/=10;
		while(n){
			ans+=n/5;
			n/=5;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){

   int A, B, C, D;
   cin >>A >>B >>C >>D;
  
   if((A+B) > (C+D)){
     cout << "Left" << endl;
   }
   else if ((A+B) < (C+D)){
     cout << "Right" << endl;
   }
   else{
     cout << "Balanced" << endl;
   }
}

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

using namespace std;

int main(){
  
  bool flag = true;//最後まで折られなければYesを出力
  int N; cin >> N; vector<string> vec(N); 
    
  for(int i = 0; i < N; i++){
    string S;  cin >> S;  
    if(count(vec.begin(),vec.end(),S) > 0){ flag = false; break;}
    //すでにSが存在していれば、フラグを折る
    vec[i] = S;//存在していなかったら、追加して再びfor文へ
  }
  

  
  for(int j = 0; j < N - 1; j++){
    if(vec[j].back() != vec[j+1].front()){flag = false; break;}}
 //前の単語の最後の文字と、次の単語の最初の文字が等しくなければ、フラグを折る
  if( !flag){ cout << "No" << endl;}
  else{cout << "Yes" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    REP(i,3) cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[0]+a[1]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

void swap(int *, int *);

int main(void) {
	int w, n;
	int bou[30];
	int a;
	int b;
	int i;
	
	scanf("%d", &w);
	scanf("%d", &n);
	for (i = 0; i < w; i++)
		bou[i] = i + 1;
	for (i = 0; i < n; i++) {
		scanf("%d,%d", &a, &b);
		swap(&bou[a-1], &bou[b-1]);
	}
	for (i = 0; i < w; i++)
		printf("%d\n", bou[i]);
	return 0;
}

void swap(int *a, int *b) {
	int c;
	c = *a;
	*a = *b;
	*b = c;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll X;
  cin >> X;
  // k買う
  FOR(k, 1, 1001) {
    ll p = X - 100 * k;
    if (p < 0) break;
    if ((p + 4) / 5 <= k) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<int> dh = {-1,-1,-1,0,0,0,1,1,1};
  vector<int> dw = {-1,0,1,-1,0,1,-1,0,1};
  vector<vector<char>> S(H,vector<char>(W));
  rep(i,H){
    rep(j,W){
      cin >> S.at(i).at(j);
    }
  }
  rep(i,H){
    rep(j,W){
      if(S.at(i).at(j)=='#'){
        cout << '#';
      }else{
        int cnt = 0;
        rep(k,9){
          int nh = i + dh.at(k);
          int nw = j + dw.at(k);
          if(0<=nh&&nh<H&&0<=nw&&nw<W&&S.at(nh).at(nw)=='#'){
            ++cnt;
          }
        }
        cout << cnt;
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    int res = 1;
    while(res*2 <= N) {
      res *= 2;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=1000000;



main(){
    ll n=lin(),m=lin();
    ll l=0,r=1e17;
    while(l<r-1){
        ll mid=(l+r)/2;
        ll c=mid*2,s=mid;
        ll S=n+(m-c)/2;
        if(S>=s && m>=c)l=mid;
        else r=mid;
    }
    cout<<l<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
 public static void main(String[] args) throws Exception {
  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  int value;
  value = Integer.parseInt(in.readLine());
  System.out.println(value*value*value);
  in.close();
 }
}

Measured memory_bytes: 24316
N = int(input())
d = [int(input()) for i in range(N)]
d = sorted(d,reverse=True)
start = d[0]
ans=0
cnt=1
for i in range(1, N):
    x = d[i]
    if start<=x:
        continue
    else:
        cnt+=1
    start = x
ans=cnt
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,a,b,c=0,d=0;
  char s;
  cin>>n>>a>>b;
  for(;cin>>s;){
    if(s=='a'&&c<a+b){cout<<"Yes"<<endl;c++;}
    else if(s=='b'&&c<a+b&&d<b){cout<<"Yes"<<endl;c++;d++;}
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 640