akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(i * 500 + j * 100 + k * 50 == x){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    double v;
    
    while((cin>>v)){
        double t = v/9.8;
        double y = 4.9*t*t;
        double h = (y + 5.0)/5.0;
        cout<<ceil(h)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1276
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    A = input([int, N])
    yesno(len(A) == len(set(A)), upper=True)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 38632
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    a,b,c = map(int, sys.stdin.readline().split())
    print(int(a*b/2))

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i, n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    repa(i, A) cin >> i;

    vl B = A, D(N);
    sort(all(B));

    rep(i, N) D[i] = lower_bound(all(B), A[i]) - B.begin();

    ll cnt = 0;
    rep(i, N) if (abs(D[i] - i) % 2) cnt++;

    cout << cnt / 2 << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
	optimizar_io
	int n, m, ans;
		
	cin >> n >> m;
	ans = (n * (n - 1)) + (m * (m - 1));
	cout << ans / 2 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
     
int main() {
  int num[3];
  std::cin >> num[0] >> num[1] >> num[2];
  
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 3; j++) {
      if (num[i] > num[j]) {
        int tmp = num[i];
        num[i] = num[j];
        num[j] = tmp;
      }
    }
  }

  std::cout << num[0] << " " << num[1] << " " << num[2] << std::endl;

  return 0;
} 


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
const int N = 10010;
int fa[N];
int findfa(int x){
    if(x == fa[x]) return x;
    return fa[x] = findfa(fa[x]);
}
int main(){
    int n, q;
    scanf("%d %d", &n, &q);
    for(int i = 0; i < n; i++) fa[i] = i;
    for(int time = 0; time < q; time++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        if(a == 1){
            printf("%d\n", findfa(b) == findfa(c) ? 1 : 0);
        }else{
            fa[findfa(b)] = findfa(c);
        }
    }
    return 0;
}



Measured memory_bytes: 3316
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=1e5+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
int n,a[N];
int ans;

int main()
{
	read(n);
	Rep(i,1,n-1)read(a[i]);
	a[0]=1e9+5;
	a[n]=a[n-1];
	Rep(i,1,n)ans+=min(a[i],a[i-1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
deque<int> dq;
int n,a;
int main()
{
	scanf("%d",&n);
	if(n%2==1)
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a);
			if(i%2==1)
			{
				dq.push_front(a);
			}else
			{
				dq.push_back(a);
			}
		}
	}else
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a);
			if(i%2==1)
			{
				dq.push_back(a);
			}else
			{
				dq.push_front(a);
			}
		}
	}
	while(!dq.empty())
	{
		printf("%d ",dq.front());
		dq.pop_front();
	}
}

Measured memory_bytes: 4620
// https://atcoder.jp/contests/abc159/tasks/abc159_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "unordered_map"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  VL cts(N + 1);

  for (auto a : as) ++cts[a];

  ll all_ct = 0;

  for (auto ct : cts) {
    all_ct += ct * (ct - 1) / 2;
  }

  for (auto a : as) {
    ll res = all_ct;
    ll ct = cts[a];
    res -= ct * (ct - 1) / 2;
    res += (ct - 1) * (ct - 2) / 2;
    cout << res << "\n";
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 5760
il = list(map(int,input().split()))

k = il[0]
x = il[1]

minusLimit = x - k + 1
plusLimit = x + k - 1

i = minusLimit

s = ""

while minusLimit <= i <= plusLimit :
  s =  s + str(i) + " "
  i = i + 1
s[:-1]
print(s)

Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
    char a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    if((a < c) && (a < b ) && (b < c))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2052
n = int(input())
a = input()
b = input()
MOD = 1000000007

ans = 3 * ((a[0] != b[0])+1)
tate = (a[0] == b[0])+0
skip = (a[0] != b[0])+0
for x, y in zip(a[1:], b[1:]):
    if skip:
        skip = 0
        continue
    if x == y:
        now_tate = 1
    else:
        now_tate = 0
        skip = 1

    if tate:
        ans *= 2
    else:
        if now_tate:
            ans *= 1
        else:
            ans *= 3
    tate = now_tate
    ans = ans % MOD
print(ans % MOD)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), i, g=0, h, ans=0;
        int[] array = new int[101];
        for(i=0;i<n;i++){
            array[i] = sc.nextInt();
            g+=array[i];
        }
        h = Math.round((float)g/n);
        for(i=0;i<n;i++)
            ans += Math.pow(h-array[i],2);
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
import heapq
#printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
#inm   = lambda:      map(int, input().split())
DBG = True  and False
#def ddprint(x):
#  if DBG:
#    print(x)

q = inn()
x = inl()
root = x[1]
b = x[2]
tl = []
tr = []
nl = nr = suml = sumr = 0
#ddprint("q " + str(q))
for i in range(1,q):
    #ddprint("i " + str(i))
    x = inl()
    if len(x)==1:
        z = sumr - suml - (root if nr>nl else 0) + b
        print("{} {}".format(root,z))
    else:
        a = x[1]
        b += x[2]
        if nl == nr:
            aa = -heapq.heappushpop(tl,-a)
            suml += a - aa
            if aa<root:
                aa,root = root,aa
            heapq.heappush(tr,aa)
            sumr += aa
            nr += 1
        else:
            aa = heapq.heappushpop(tr,a)
            sumr += a - aa
            if aa>root:
                aa,root = root,aa
            heapq.heappush(tl,-aa)
            suml += aa
            nl += 1
        #ddprint("b {} root {} nl {} nr {} suml {} sumr {}".format(b,root,nl,nr,suml,sumr))
        #ddprint(tl)
        #ddprint(tr)


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

int main(void){
    // Your code here!
    int A,B,H,M; cin >> A >> B >> H >> M;
    double deg = 6*M - 30 * H - M/2.0; // 
    const long double pie = acos(-1.0L);
    double rad = deg * pie/180;
    double coss = cos(rad);
    cout << fixed << setprecision(10);
    cout << sqrt(A*A + B*B -2*A*B*coss) << endl; 
}


Measured memory_bytes: 4180
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
const int maxn = 101;
char g[maxn][maxn];
int d[4][2] = {0 , 1 , 1 , 0 , 0 , -1 , -1 ,0};
void dfs(int si , int sj , int n , int m , char ch)
{
    g[si][sj] = '1';
    for(int i = 0 ; i < 4 ; i ++){
        int x = si + d[i][0];
        int y = sj + d[i][1];
        if(x < 0 || x >= n || y < 0 || y >= m || g[x][y] != ch) continue;
        dfs(x , y , n , m , ch);
    }
}

int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif // DoubleQ
    int n , m;
    while(cin >> n >> m){
        if(n == 0 && m == 0) break;

        string str;
        for(int i = 0 ; i < n ; i ++){
            cin >> str;
            for(int j = 0 ; j < m ; j ++){
                g[i][j] = str[j];
            }
        }
        int cnt = 0;
        /*
        for(int i = 0 ; i < n ;i ++){
            for(int j = 0 ; j < m ; j ++){
                cout << g[i][j] << " ";
            }
            cout << endl;
        }
        */

        for(int i = 0 ; i < n ; i ++){
            for(int j = 0 ; j < m ; j ++){
                if(g[i][j] != '1'){
                    dfs(i , j , n , m , g[i][j]);
                    cnt ++;
                }
            }
        }
        cout << cnt << endl;

    }
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll, ll> pii;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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 A, B, C;
int main()
{
    cin >> A >> B >> C;
    int ans = B / A;
    if (ans >= C)
    {
        ans = C;
    }
    cout << ans << endl;
    //system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int k; cin >> k;
  int res;
  if (k % 2 == 0) {
    res = (k / 2) * (k / 2);
  } else {
    res = (k / 2 + 1) * (k / 2);
  }
  cout << res << endl;
  return 0;
}


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

int main(){
  string s;
  int sum = 0;
  cin >> s;
  for(int i = 0; i < s.size(); ++i){
    if(s[i] == '+') ++sum;
    else --sum;
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

using P = pair<int, int>;

P rotate90(const P& p1, const P& p2) {
    return P(p1.second - p2.second, p2.first - p1.first);
}

int main() {
    P p1, p2;
    cin >> p1.first >> p1.second >> p2.first >> p2.second;
    P p3 = rotate90(p1, p2);
    p3.first += p2.first;
    p3.second += p2.second;
    P p4 = rotate90(p2, p3);
    p4.first += p3.first;
    p4.second += p3.second;
    cout << p3.first << ' '
         << p3.second << ' '
         << p4.first << ' '
         << p4.second << endl;
}


Measured memory_bytes: 256
from collections import deque

H,W=map(int,input().split())
field=[]
spos=deque([])
for i in range(H):
  s=list(input())
  for j in range(W):
    if s[j]=="#":
      spos.append((j,i))
  field.append(s)
  

dx=[1,0,-1,0]
dy=[0,1,0,-1]

ans=-1
while spos:
  for _ in range(len(spos)):
    x,y=spos.popleft()
    for i in range(4):
      nx=x+dx[i]
      ny=y+dy[i]
      if nx<0 or nx>=W or ny<0 or ny>=H:
        pass
      elif field[ny][nx]==".":
        field[ny][nx]="#"
        spos.append((nx,ny))
  ans+=1

print(ans)


Measured memory_bytes: 116572
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
using namespace std;
int main() {
	long long int  n, m, r, R[10], a, b, c, dis[210][210], inf = 1e9;
	for (int i = 0; i < 210; i++) {//距離の初期化
		for (int j = 0; j < 210; j++) {
			dis[i][j] = inf;
		}
		dis[i][i] = 0;
	}
	cin >> n >> m >> r;
	for (int i = 0; i < r; i++)cin >> R[i];
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		if (c > dis[a][b])continue;
		dis[a][b] = dis[b][a] = c;
		for (int j = 1; j <= n; j++) {//ワーシャルフロイド
			for (int k = 1; k <= n; k++) {
				dis[j][k] = min(dis[j][k], min(dis[j][a] + dis[b][k], dis[j][b] + dis[a][k]) + c);
			}
		}
	}
	sort(R, R + r);
	ll yan, ans = 1e9;
	do {//ねくすとっ☆ぱーみゅてーしょん！！
		yan = 0;
		for (int i = 0; i < r - 1; i++)yan += dis[R[i]][R[i + 1]];
		ans = min(yan, ans);
	} while (next_permutation(R, R + r));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import numpy as np

def min_steps_v2(n, a, b):
    n = np.int64(n)
    a = np.int64(a)
    b = np.int64(b)

    if (b - a) % 2 == 0:
        return np.int64(int(b - a) // 2)
 
    # odd case
    a_diff = a - 1
    b_diff = n - b
 
    if a_diff > b_diff:
      steps_to_even = n - b + 1
      remain_steps = min_steps_v2(n, a + (n - b) + 1, n)
    else:
      steps_to_even = a
      remain_steps = min_steps_v2(n, 1, b - a)
 
    return steps_to_even + remain_steps

numbers = input().split(' ')
 
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
 
print(min_steps_v2(n, a, b))


Measured memory_bytes: 22024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

map<ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  int n;
  cin>>n;
  vl A(n),B(n);
  map<ll,int> prime;
  rep(i,n)cin>>A[i];

  rep(i,n){
    auto res = prime_factor(A[i]);
    for(auto it: res){
      prime[it.fi] = max(prime[it.fi],it.se);
    }
  }
  mint d = 1;
  for(auto it:prime){
    d*=pow(it.fi,it.se);
  }

  mint ans = 0;
  rep(i,n){
    ans+= d/A[i];
  }
  print(ans.x);
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, x;
    cin >> n >> x;
    int sm = 0, mn = 999999;
    imfor(i, n) {
        int m;
        cin >> m;
        sm += m;
        mn = min(mn, m);
    }
    x -= sm;
    cout << n + (x / mn) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			String digit = Integer.toString(a + b);
			System.out.println(digit.length());
		}
	}
}


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

typedef struct{
  int x;
  int y;
} Point;

int main(){
  int h, w, d;
  int mas[300][300];
  Point p[90001];
  cin >> h >> w >> d;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cin >> mas[i][j];
    }
  }

  for(int i = 0; i < h;i++){
    for(int j = 0;j < w;j++){
      p[mas[i][j]].x = j;
      p[mas[i][j]].y = i;
    }
  }

  int rui[100001] = {};
  for(int i = 1;i <= h*w;i++){
    int tmp = i-d;
    if(tmp > 0){
      rui[i] = rui[tmp] + abs(p[i].x - p[tmp].x) + abs(p[i].y - p[tmp].y);
    }
  }

  int q;
  cin >> q;
  int l,r;
  for(int i = 0;i < q;i++){
    cin >> l >> r;
    cout << rui[r] - rui[l] << endl;
  }
  return 0;
}







Measured memory_bytes: 2560
import sys
from networkx.utils import UnionFind
def input(): return sys.stdin.readline().rstrip()
def main():
    h, w = map(int, input().split())
    s = [list(input()) for i in range(h)]
    uf = UnionFind()
    for i in range(h):
        for j in range(w):
            if i != h-1:
                if s[i][j] != s[i+1][j]:
                    uf.union((i*w)+j, (i*w)+j+w)
            if j != w-1:
                if s[i][j] != s[i][j+1]:
                    uf.union((i*w)+j, (i*w)+j+1)
    ans=0
    for item in uf.to_sets():
        A=0
        B=0
        for grid in item:
            i,j=divmod(grid,w)
            if s[i][j]=='.':
                A+=1
            else:
                B+=1
        ans+=A*B
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 84804
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	
	if(abs(a - c) <= d){
		cout << "Yes" << endl;
	}
	else{
		if(abs(a-b) <= d && abs(b-c) <= d){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	return 0;
}

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

using namespace std;

int a,b,c,d;

int main()
{
	ios::sync_with_stdio(false);
	
	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;
	
	return 0; 
}

Measured memory_bytes: 256
#[allow(dead_code)]
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()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let mut taro = 0;
    let mut hanako = 0;
    for _ in 0..n {
        let v = read_vec::<String>();
        let t = &v[0];
        let h = &v[1];

        if t == h {
            taro += 1;
            hanako += 1;
        } else if t < h {
            hanako += 3;
        } else {
            taro += 3;
        }
    }
    println!("{} {}", taro, hanako);
}



Measured memory_bytes: 5048
from collections import Counter


def main():
    S = input()

    c = Counter(S)

    if len(c) == 2 and list(c.values())[0] == 2 and list(c.values())[1] == 2:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64880
N, M = map(int, input().split())
c = {}
d = {}
for i in range(1, N + 1):
	c[i] = []
	d[i] = 0
AB = []
for i in range(N - 1 + M):
	A, B = map(int, input().split())
	AB.append((A, B))
	c[A].append(B)
	d[B] += 1
s = []
for i in range(1, N + 1):
	if d[i] == 0:
		s.append(i)
t = []
while s != []:
	x = s.pop()
	t.append(x)
	for i in c[x]:
		d[i] -= 1
		if d[i] == 0:
			s.append(i)
p = {}
for i in range(N):
	p[t[i]] = i
ans = {}
for A, B in AB:
	if B in ans:
		if p[A] > p[ans[B]]:
			ans[B] = A
	else:
		ans[B] = A
for i in range(1, N + 1):
	if i in ans:
		print(ans[i])
	else:
		print(0)

Measured memory_bytes: 107356
import Data.List (tails)

main :: IO ()
main = readLn >>= print . solve

solve :: Int -> Int
solve = minimum . diff753s

diff753s :: Int -> [Int]
diff753s = map (diff753 . read) . slices 3 . show

diff753 :: Int -> Int
diff753 = abs . subtract 753

slices :: Int -> [a] -> [[a]]
slices n xs = [take n t | t <- tails xs, length t >= n]


Measured memory_bytes: 508
h = []
w = []
while True:
    a,b = map(int, raw_input().split())
    h.append(a)
    w.append(b) 
    if a == 0 and b == 0:
        break

for h,w in zip(h,w):    
    if h == 0 and w == 0:
        break;
    else:
	c = "#"
	d = "#"
        for x in xrange(w-2):
            c = c + "#"
	    d = d + "."
	c += "#"
	d += "#"
        for x in xrange(h):
	    if x == 0 or x == h-1: 
		print c
	    else:
		print d
    print 

Measured memory_bytes: 6256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, h;
  scanf("%d %d", &n, &h);

  vector<int> a, b;
  int max_a = -1;
  REP(i,n){
    int t1, t2;
    scanf("%d %d", &t1, &t2);
    a.pb(t1); b.pb(t2);
    max_a = max(max_a, t1);
  }

  sort(ALL(b), greater<int>());

  llong ans = 0, damage = 0;
  int i = 0;
  while(damage < h){
    if(max_a < b[i]){
      damage += b[i];
      ans++;
      i++;
    }else{
      ans += ceil((double)(h - damage) / max_a);
      break;
    }
  }

  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 1276
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef pair<int,pii> Pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int n,m;
vector<int>ans(200005,0);
vii adj(200005);
vector<bool>vis(200005,0);
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
		int v,u;
		cin>>v>>u;
		v--;u--;
		adj[v].pb(u);
		adj[u].pb(v);
	}	
	queue<pii>q;
	q.push({0,-1});
	vis[0] = 1;
	while(!q.empty()){
		int v = q.front().fi;
		int u = q.front().se;
		q.pop();
		ans[v] = u;
		for(int x:adj[v]){
			if(!vis[x]){
				vis[x] = 1;
				q.push({x,v});
			}
		}	
	}
	for(int i=0;i<n;i++){
		if(!vis[i]){cout<<"No";return 0;}
	}
	cout<<"Yes"<<'\n';
	for(int i=1;i<n;i++)cout<<ans[i]+1<<'\n';
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;

const ll INF = 1LL << 60;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int main() {
    ll h, w; cin >> h >> w;
    ll ch, cw; cin >> ch >> cw;
    ll dh, dw; cin >> dh >> dw;
    V<string> s(h);
    for(int i = 0; i < h; i++) cin >> s[i];
    ch--, cw--, dh--, dw--;

    V<V<ll> > cnt(h, V<ll>(w, INF));
    queue<P<ll, ll> > q, visited;
    q.push({ch, cw});
    cnt[ch][cw] = 0;

    while(!q.empty() || !visited.empty()){
        ll nowx = 0, nowy = 0;
        if(!q.empty()){
            auto p = q.front();
            q.pop();
            nowy = p.first;
            nowx = p.second;
            visited.push({nowy, nowx});
            for(int i = 0; i < 4; i++){
                ll ny = nowy + dy[i];
                ll nx = nowx + dx[i];
                if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
                if(s[ny][nx] == '#') continue;
                if(cnt[nowy][nowx] < cnt[ny][nx]){
                    cnt[ny][nx] = cnt[nowy][nowx];
                    q.push({ny, nx});
                }
            }
        }else{
            auto p = visited.front();
            visited.pop();
            nowy = p.first;
            nowx = p.second;
            for(int i = -2; i <= 2; i++){
                for(int j = -2; j <= 2; j++){
                    ll ny = nowy + i;
                    ll nx = nowx + j;
                    if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
                    if(s[ny][nx] == '#') continue;
                    if(cnt[nowy][nowx] + 1 < cnt[ny][nx]){
                        cnt[ny][nx] = cnt[nowy][nowx] + 1;
                        q.push({ny, nx});
                    }
                }
            }
        }
    }

    if(cnt[dh][dw] == INF) cout << -1 << endl;
    else cout << cnt[dh][dw] << endl;


    return 0;
}


Measured memory_bytes: 13520
# 入力
N = int(input())
s = list(map(int, input().split()))

M = N - 1
opt = 0
# 各 A - D について解候補を全探索する
for d in range(1, M // 2 + 1):
    U = {0, M}
    q = M // d
    r = M % d
    acc = 0
    for i in range(1, M // d):
        x = i * d
        y = (q - i) * d + r
        if x == y or x in U or y in U:
            break
        U.add(x)
        U.add(y)
        acc += s[x] + s[y]
        opt = max(opt, acc)

ans = opt
# 出力
print(ans)


Measured memory_bytes: 85780
N = int(input())
List = [i for i in input().split(" ")]
Dict = {}
flag=0
for i in range(N):
    try:
        Dict[List[i]] += 1
    except KeyError:
        Dict[List[i]] = 1
        
list2 = list(Dict.values())
for j in range(len(list2)):
    if list2[j]>1:
        flag=1
if flag==1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 38736
#include <stdio.h>

int gcd(unsigned int a, unsigned int b)
{
	return ((b > 0)? gcd(b, a % b) : a);
}

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

int main(void)
{
	unsigned int a, b;
	
	while (scanf("%d %d", &a, &b) != EOF){
		printf("%d %d\n", gcd(a, b), lcm(a, b));
	}
	
	return (0);
}

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

const int MAX = 1000000;
vector<int> D(MAX+1);

void pre(){
    for(int i=1;i<=MAX;i++)
        D[i] = i;

    vector<bool> is_prime(MAX+1,true);
    for(int i=2;i*i<=MAX;i++){
        if(!is_prime[i]) continue;
        else{
            for(int j=i;j<=MAX;j+=i){
                is_prime[j] = false;
                D[j] = min(D[j],i);
            }
        }
    }
}

bool judge_pairwise(int N,vector<int>& A){
    vector<bool> primes(MAX+1,false);
    for(int i=0;i<N;i++){
        int a = A[i];
        while(a > 1){
            if(primes[D[a]])
                return false;
            else{
                int t = D[a];
                primes[t] = true;
                do{ a /= t; }while(D[a] == t);
            }
        }
    }
    return true;
}

bool judge_setwise(int N,vector<int>& A){
    int tmp = A[N-1];
    while(N > 1){
        tmp = gcd(tmp,A[N-2]);
        if(tmp == 1) return true;
        else N--;
    }
    return false;
}

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++)
        cin >> A[i];

    pre();
    bool is_pairwise = judge_pairwise(N,A);
    bool is_setwise = judge_setwise(N,A);

    if(is_pairwise)
        cout << "pairwise coprime";
    else if(is_setwise)
        cout << "setwise coprime";
    else
        cout << "not coprime";

    return 0;
}

Measured memory_bytes: 11340
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; 
	cin >> N >> M; 
	int A[110] = {}; 
	int odd = 0; 
	int L = 123; int R = 456; 
	for(int i = 0; i < M; i++){
		cin >> A[i]; 
		if(A[i] % 2) odd ++; 
		if((A[i] % 2) && odd == 1) L = i; 
		if((A[i] % 2) && odd == 2) R = i; 
	}
	if(odd > 2){
		cout << "Impossible" << endl; 
	}
	else{
		if(odd == 2){
			swap(A[L], A[0]); 
			swap(A[R], A[M-1]); 
		}
		if(odd == 1){
			swap(A[L], A[0]); 
		}
		for(int i = 0; i < M; i++){
			cout << A[i] << " "; 
		}
		cout << endl; 
     	if(N == 1){
			cout << 1 << endl << 1 << endl; 
		}
		else if(odd == 0 || (N > 1 && M == 1)){
			cout << M+1 << endl; 
			cout << 1 << " "; 
			for(int i = 0; i < M-1; i++){
				cout << A[i] << " "; 
			}
			cout << A[M-1] - 1 << endl; 
		}
		else if(odd == 1 || (odd == 2 && A[M-1] != 1)){
			cout << M << endl; 
			cout << A[0] + 1 << " "; 
			for(int i = 1; i < M-1; i++){
				cout << A[i] << " "; 
			}
			cout << A[M-1] - 1 << endl; 
		}
		else if(odd == 2 && A[M-1] == 1){
			cout << M-1 << endl; 
			cout << A[0] + 1 << " "; 
			for(int i = 1; i < M-1; i++){
				cout << A[i] << " "; 
			}
			cout << endl; 
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e,s;
	cin>>a>>b>>c>>d>>e;

	if(a<40){a=40;}
	if(b<40){b=40;}
	if(c<40){c=40;}
	if(d<40){d=40;}
	if(e<40){e=40;}

	s=(a+b+c+d+e)/5;

	cout<<s<<endl;

	return 0;
}




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

using namespace std;

int main()
{
    int n = 0;
    long x, a = 100;
    cin >> x;

    while( a < x )
    {
        a = ( long )( 1.01 * ( double )( a ));
        n++;
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 3648
/* Author VS_CODE */

#include<bits/stdc++.h>
#define int long long
#define TCI int t;cin>>t;while(t--)
#define run(n) for(int i=1;i<=n;i++)
#define cinl(n) for(int i=0;i<n;i++)
#define ln "\n"
#define vpair vector< pair <int , int > >
#define fr first
#define sc second
#define pb emplace_back
#define vll vector<int>
#define inf 0x3f3f3f3f3f3f3f3fLL
#define Point complex<double>
using namespace std;

void online()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
/* CODE STARTS HERE */

template<typename T>
void debug(T x)
{
	cout<<x<<ln;
}

const int N = 1e5;

void solve()
{
	int n,d;
	cin>>n>>d;
	Point P[n];
	int ans=0;
	cinl(n)
	{
		int x;
		int y;
		cin>>x>>y;
		P[i]={x,y};
		double xx=abs(P[i]);
		// cout<<xx<<ln;
		if(xx<=d)
			ans++;
	}
	cout<<ans<<ln;
}


/* CODE ENDS HERE AND MAIN STARTS */

int32_t main()
{

	online();
	//TCI
	solve();
}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
    ll n,W;cin>>n>>W;
    vector <pair<ll,ll>> vec(n);
    for(int i=0;i<n;i++){
		ll x,y;cin>>x>>y;
		vec[i].first=x;
		vec[i].second=y;
    }
    //vector <vector <ll>> dp(n+1,vector <ll> (W+1,0));
    vector <vector <ll>> dp(W+1,vector <ll> (n+1,0));
    for(int i=1;i<=W;i++){
		for(int j=1;j<=n;j++){
			dp[i][j]=max(dp[i][j],dp[i][j-1]);
			if(i-vec[j-1].first>=0){
				dp[i][j]=max(dp[i][j],vec[j-1].second+dp[i-vec[j-1].first][j-1]);
			}
		}
    }
    /*for(int i=1;i<=n;i++){
		for(int j=1;j<=W;j++){
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			if(j-vec[i-1].first>=0){
				dp[i][j]=max(dp[i][j],vec[i-1].second+dp[i-1][j-vec[i-1].first]);
			}
		}
    }*/
    cout<<dp[W][n]<<endl;
    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b;
  while (cin >> a >> b) {
    cout << (a + b) % 24 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;


int main()
{
	int N, M;
	cin >> N >> M;
	vector<string> S(M);
	vector<int> P(M);
	rep(i, M) {
		cin >> P[i] >> S[i];
		P[i]--;
	}
	vector<int> Ans(N, 0);

	int penalty = 0;
	int ac = 0;
	for (int i = 0; i < M; ++i) {
		if (S[i] ==  "AC" && Ans[P[i]] <= 0) {
			penalty += Ans[P[i]] * -1;
			Ans[P[i]] = 1;
			ac++;
		}
		else {
			if (Ans[P[i]] <= 0) {
				Ans[P[i]]--;
			}
		}
	}
	
	cout << ac << " " << penalty << endl;
	return 0;
} 

Measured memory_bytes: 7140
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

vector<vector<ll>> matmul(vector<vector<ll>>& A, vector<vector<ll>>& B) {
    int n = A.size();
    int inner = B.size();
    int m = B[0].size();
    ll mod = 1e9 + 7;
    vector<vector<ll>> ans(n, vector<ll>(m, 0));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            for(int k = 0; k < inner; k++) {
                ans[i][j] += A[i][k] * B[k][j];
                ans[i][j] %= mod;
            }
            //cout << ans[i][j] << " ";
        }
        //cout << endl;
    }
    //cout << endl;
    return ans;
}
vector<vector<ll>> mat_power(vector<vector<ll>> M, ll k) {
    int n = M.size();
    vector<vector<ll>> res(n, vector<ll>(n, 0));
    for(int i = 0; i < n; i++)
        res[i][i] = 1;
    // ll fac = 1;
    while(k > 0) {
        if (k % 2 == 1)
            res = matmul(res, M);
        k /= 2;
        M = matmul(M, M);
    }
    return res;
}
int main() {
    ll n, k;
    cin >> n >> k;
    static ll mod = 1e9 + 7;
    vector<vector<ll>> mat(n, vector<ll>(n, 0));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++)
            cin >> mat[i][j];
    }
    // compute M*k
    auto mat_k = mat_power(mat, k);
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            ans += mat_k[i][j];
        }
    }
    cout << (ans%mod) << endl;
    return 0;
}



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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()

int main(){
    ll n,y;
    cin >> n >> y;

    rep(i,n+1){
        rep(j,n-i+1){
            if(10000*i+5000*j+1000*(n-i-j)==y){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

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

using namespace std;

int main(void) {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d;
  
  /*
    if (abs(c - a) <= d || (abs (a - b) <= d && abs (b - c) <= d)) {
    cout << "Yes";
  } else {
    cout << "Yes";
  } cout << endl;
  */
  e = (abs(a - b) <= d ? 1 : 0)
    + (abs(b - c) <= d ? 1 : 0)
    + (abs(c - a) <= d ? 2 : 0);
  
  cout << (e >= 2 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  int n,a,b,c;
  cin>>n>>a>>b;
  if(a+b>n) c=a+b-n;
  else c=0;
  cout<<min(a,b)<<" "<<c<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long 
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define inf 1e14+1
#define all(a) a.begin(),a.end()
int n;
vector <vector<int>> adj(51,vector<int>(50));
ll k;


vector <vector<int>> multiply(vector <vector<int>> A,vector <vector<int>> B)
{
  vector <vector<int>> final(n,vector<int>(n,0));
  
  fo(i,n)
  {
    fo(j,n)
    {
      fo(x,n)
      {
        final[i][j] = (final[i][j]%M+(1ll*A[i][x]*B[x][j])%M)%M;
      }
    }
  }
  return final;



}


vector <vector<int>> power(vector <vector<int>> mat,ll y)
{
  if ( y == 1)
    return mat;


  if ( y & 1)
    return multiply(mat,power(mat,y-1));

  vector <vector<int>>  temp = power(mat,y/2);
  return multiply(temp,temp);
}


ll solve()
{
   
   vector <vector<int>> temp = power(adj,k);
   ll ans = 0;

   fo(i,n)
   {
    fo(j,n)
    {
      ans = (ans+temp[i][j])%M;
    }

   }
   return ans;   

}

int main()
{ 
  cin >> n >> k;
  fo(i,n)
  {
    fo(j,n)
    cin >> adj[i][j];
  }

  cout << solve() << endl;
 
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MAXN (100005)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef long double ld;

char str[MAXN];
bool chk[MAXN];
int N;

void prans() {
    for(int i = 0; i < N; i++) putchar(chk[i] ? 'S' : 'W');
    puts(""); exit(0);
}
bool f() {
    for(int i = 2; i < N; i++) {
        chk[i] = ('o' == str[i-1]) ^ chk[i-1] ^ chk[i-2];
    }
    for(int i = 1; i+1 < N; i++)
        if(('o' == str[i]) ^ chk[i-1] ^ chk[i] ^ chk[i+1]) return false;
    if(('o' == str[0]) ^ chk[N-1] ^ chk[0] ^ chk[1]) return false;
    if(('o' == str[N-1]) ^ chk[N-2] ^ chk[N-1] ^ chk[0]) return false;
    return true;
}
int main() {
    scanf("%d %s", &N, str);
    if(f()) prans(); chk[1] = true; if(f()) prans();
    chk[0] = true; if(f()) prans(); chk[1] = false; if(f()) prans();
    puts("-1");
    return 0;
}

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

int main() {
  int X;
  cin >>X;
  if(X<600){
    cout <<8;
  } 
  else if(X<=799){
    cout <<7;
  }
  else if(X<=999){
    cout <<6;
  }
else if(X<=1199){
    cout <<5;
  }
else if(X<=1399){
    cout <<4;
  }
else if(X<=1599){
    cout <<3;
  }
else if(X<=1799){
    cout <<2;
  }
else if(X<=1999){
    cout <<1;
  }
}

Measured memory_bytes: 3632
use proconio::{input, fastout};
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        sx: [String; n],
    }

    let mut hs = HashSet::new();

    for s in sx {
        hs.insert(s);
    }

    println!("{}", hs.len());
}

Measured memory_bytes: 24740
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if((b-a)==(c-b)){
			System.out.println("YES");
		}
		else{System.out.println("NO");}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, x[20], y[20], p[20];
bool used[20];
ll ans[20];
set<int> xs, ys;
template<class T> void chmin(T &a, T b){if(a>b) a=b;}
void rec(int i){
	if(i == n){
		int cnt = xs.size() + ys.size() - 2;
		ll sm = 0;
		rep(i,n) if(!used[i]){
			int d = 1e9;
			auto it = xs.lower_bound(x[i]);
			if(it != xs.end()) chmin(d,(*it)-x[i]);
			if(it != xs.begin()) chmin(d,x[i]-*--it);
			it = ys.lower_bound(y[i]);
			if(it != ys.end()) chmin(d,(*it)-y[i]);
			if(it != ys.begin()) chmin(d,y[i]-*--it);
			sm += (ll)d * p[i];
		}
		if(ans[cnt] > sm) ans[cnt] = sm;
	}else{
		if(xs.count(x[i]) || ys.count(y[i])){
			used[i] = true;
			rec(i+1);
			used[i] = false;
		}else{
			rec(i+1);
			used[i] = true;
			xs.insert(x[i]);
			rec(i+1);
			xs.erase(x[i]);
			ys.insert(y[i]);
			rec(i+1);
			ys.erase(y[i]);
			used[i] = false;
		}
	}
}
int main(){
	scanf("%d", &n);
	fill(ans,ans+n+1,(ll)1e15);
	rep(i,n) scanf("%d%d%d", x+i, y+i, p+i);
	xs.insert(0); ys.insert(0);
	rec(0);
	rep(i,n) chmin(ans[i+1], ans[i]);
	rep(i,n+1) printf("%lld\n", ans[i]);
}

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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(n);
    for (int i = 0; i < m; i++)
    {
        cin >> a.at(i);
    }
    int aaa = 0;
    int b = 0;
    for (int i = 0; i < m; i++)
    {
        if (x > a.at(i))
        {
            aaa++;
        }
        if (x < a.at(i))
        {
            b++;
        }
    }

    cout << min(aaa, b) << endl;
}

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

long long n,m,p[100005],rez;
vector<long long> adj[100005];
unordered_set<long long> s,s1,ob;

void dfs(long long x)
{
    ob.insert(x);
    s.insert(x);
    s1.insert(p[x]);
    for(auto u: adj[x])
        if(!ob.count(u))
            dfs(u);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin>>n>>m;
    for(long long i=1;i<=n;i++)
        cin>>p[i];

    for(long long i=1;i<=m;i++)
    {
        long long x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for(long long i=1;i<=n;i++)
    {
        if(ob.count(i)==0)
        {
            dfs(i);
            for(auto u: s1)
                if(s.count(u))
                {
                    rez++;
                    //cout<<u<<endl;
                }
            s.clear();
            s1.clear();
        }
    }

    cout<<rez<<endl;

    return 0;
}


Measured memory_bytes: 26792
fn main() {
    let s = read::<String>();
    let f = s.chars().nth(0).unwrap();
    let (c,_) = s.chars().fold((0,f), |(s,f),c| {
        if f != c { (s+1,c) }
        else { (s,c) }
    });
    println!("{}", c);
}

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()
}


Measured memory_bytes: 4352