akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

vector<vector<int> > g;

void dfs( int par, int curr, ll cnt[2] )    // cnt[0]:Bの場合   cnt[1]:Wの場合
{
    int i;
    int siz=(int)g[curr].size();
    cnt[0]=1;
    cnt[1]=1;
    for(i=0; i<siz; i++) {
        int next=g[curr][i];
        if(next==par) continue;

        ll cnt0[2];
        dfs(curr, next, cnt0 );
        cnt[0] = (cnt[0] * cnt0[1]) %MOD;
        cnt[1] = (cnt[1] * (cnt0[0]+cnt0[1])) %MOD;
    }

    return;
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    g.resize(n);
    int i;
    for(i=0; i<n-1; i++) {
        int a,b;
        scanf("%d%d", &a, &b);
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }

    ll cnt[2];
    dfs(-1, 0, cnt);

    printf("%lld\n", (cnt[0]+cnt[1])%MOD);
    return 0;
}


Measured memory_bytes: 14080
'''input
3
abb
4
abcd
'''
import collections
n = int(input())
s = input()
MOD = int(1e9 + 7)
d = collections.Counter(s)
ans = 1
for k, v in d.items():
	ans = ans * (v + 1)
print((ans - 1) % MOD)

Measured memory_bytes: 40048
def bfs(start, maze, visited):
    queue = [start]
    visited[start[0]][start[1]] = True
    dist = {(start[0], start[1]): 0}
    max_dist = 0
    while queue:
        y, x = queue.pop(0)
        for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            x_, y_ = x + i, y + j
            if y_ >= 0 and y_ < h and x_ >= 0 and x_ < w and maze[y_][x_] == "." and not visited[y_][x_]:
                queue.append((y_, x_))
                visited[y_][x_] = True
                dist[y_, x_] = dist[y, x] + 1
                max_dist = max(max_dist, dist[y_, x_])
    return max_dist


h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]
max_dist = 0
for sy in range(h):
    for sx in range(w):
        if maze[sy][sx] == ".":
            visited = [[False for _ in range(w)] for _ in range(h)]
            max_dist = max(max_dist, bfs((sy, sx), maze, visited))
print(max_dist)


Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d %d", $N, $K);
fscanf(STDIN, "%d %d %d", $R, $S, $P);
fscanf(STDIN, "%s", $T);
$ans = 0;
for ($i = 0; $i < $K; $i++) {
    $prev = '';
    for ($j = $i; $j < $N; $j += $K) {
        //echo $T[$j] . " ";
        if ($prev === $T[$j]) {
            $prev = '';
        } else {
            switch($T[$j]) {
                case 'r':
                    $ans += $P;
                    break;
                case 's':
                    $ans += $R;
                    break;
                case 'p':
                    $ans += $S;
                    break;
            }
            //printf("%d\n", $ans);
            $prev = $T[$j];
        }
    }
    //echo PHP_EOL;
}
printf("%d", $ans);


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
#include <queue>
#include <type_traits>
#include<cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    int count=0;
    for(int i=0;i<N;i++){
        int w;
        cin >> w;
        vec[i]=w;
        count+=w;
    }

    int ave =count/2;

    int min=1e9;
    int tasu=0;
    int j=0;
    while(1){
        tasu = tasu+vec[j];
        if(min>abs(ave - tasu)){
            min=abs(ave - tasu);
            j++;

        }else{
            tasu = tasu-vec[j];
            break;
        }
    }
    cout << abs((count-tasu)-tasu) << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	int a = 0;
	int z = 0;
	for(int i=0; i<s.length();i++) {
		if(s.charAt(i) == 'A') {
			a = i;
			break;
		}
	}
	for(int j=1; j<=s.length(); j++) {
		if(s.charAt(s.length() - j) == 'Z') {
			z = s.length() - j;
			break;
		}
	}
	System.out.println(z-a+1);
	}
}

Measured memory_bytes: 25732
#include <cstdio>
#include <map>

int main()
{
  int n;
  scanf("%d", &n);
  std::map<long long, long long> mp;
  long long sum = 0;
  mp[0]++;
  for (int i = 0; i < n; ++i)
  {
    long long a;
    scanf("%lld", &a);
    sum += a;
    mp[sum]++;
  }
  long long ans = 0;
  for (auto &p : mp)
  {
    ans += p.second * (p.second - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 12672
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	int a=sc.nextInt();
	int b=sc.nextInt();
	int d=a/b;
	int r=a%b;
	double f= (double)a/b;
	System.out.print(d+" "+r+" ");
	System.out.printf("%.5f", f );
	System.out.println();
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 26516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,k=0;
  cin >> N;
  vector<int> x(N);
  
  for(int i=0;i<N;i++)
    cin >> x.at(i);
  
  sort(x.begin(),x.end());
  
  for(int i=0;i<N-1;i++){
    if(x.at(i)!=x.at(i+1))
      k++;
  }
  
  cout << k+1 << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define sz 100002
using namespace std;
int f[10];
int main()
{
int n,m,x;

   cin>>n>>m>>x;
   f[n]++;
   f[m]++;
   f[x]++;
   if(f[5]==2&&f[7]==1)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;

    return 0;



}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const static int MOD = 1000000007;

int main(){
    int N, x;
    scanf("%d %d", &N, &x);
    int a[N+1];
    for(int i = 0; i < N; ++i){
        scanf("%d", a + i + 1);
    }
    a[0] = 0;
    ull answer = 0;
    for(int i = 0; i < N; ++i){
        if(a[i] + a[i+1] > x){
            int eat = a[i] + a[i+1] - x;
            a[i+1] -= eat;
            answer += (ull)eat;
        }
    }
    printf("%llu\n", answer);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
    int i,j;
    int n, c;
    cin >> n >> c;
    int d[30][30];
    rep(i,c)rep(j,c) cin >> d[i][j];
    int num[3][35]={};
    rep(i,n)rep(j,n){
        int in;
        cin >> in;
        num[(i+j)%3][in-1]++;
    }
    int ans = INF;
    rep(i,c)rep(j,c)rep(k,c){
        if(i==j || j==k || i==k)continue;
        int tmp = 0;
        rep(x,c) tmp += num[0][x] * d[x][i];
        rep(x,c) tmp += num[1][x] * d[x][j];
        rep(x,c) tmp += num[2][x] * d[x][k];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

int main() {
    int N, fx;
    cin >> N;
    for (int i = 0; i < 8; i++) {
        fx += (N % (int)pow(10, i+1)) / (int)pow(10, i);
    }
    if (N % fx == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using ll = long long;

ll isqrt(ll x)
{
    ll sh = __builtin_ctzll(x);
    x >>= (sh&~1);

    if (x&6) return -1;

    ll i;
    const int ITERATIONS = 5;
    ll z = (3-x)>>1, y=x*z;
    for (i=0; i<ITERATIONS; i++)
    {
        ll w = (3 - z*y) >> 1;
        y *= w;
        z *= w;
    }
    assert(x==0 || (y*z == 1 && x*z == y));

    if (y & (1ull<<62)) y = -y;
    y &= ~(1ull<<63);

    if (y >= 1ull<<32) return -1;

    return y<<(sh/2);
}

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

    ll n, m;
    cin >> n;

    for (ll i = n; i >= 1; i--)
    {
        ll s = isqrt(i);
        if (s == -1) continue;
        else
        {
            m = i;
            break;
        }
    }

    cout << m << endl;

    return 0;
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(rALL(a));
    int ans = 0;
    rep(i,n) ans += (i % 2 == 0 ? a[i] : -a[i]);
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    N, X = inl()
    L = inl()
    cnt = 1
    d = 0
    for i in range(N):
        d += L[i]
        if d > X:
            break
        cnt += 1

    return cnt


print(solve())



Measured memory_bytes: 9172
#include <iostream>
#include <cstring>
#include <algorithm>
#include <list>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e5+5;
ll n = 0, a[MAXN], BIT[MAXN];

ll largest(ll a, ll b){
	return (a<b)?b:a;
}
int smallest(ll a, ll b){
	if(a < b)return a;
	return b;
}

int main() {
	ll x = 0, y = 0;
	cin >> x >> y;
	if(llabs(x-y)<=1){
		cout << "Brown" << endl;
	}
	else{
		cout << "Alice" << 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++)
typedef long long ll;

int main() {
    ll n,m;
    cin>>n>>m;
    
    vector<ll> mm;
    for(ll i=1;i<=sqrt(m);i++){
        if(m%i==0){
             mm.push_back(i);
             if(i*i!=m) mm.push_back(m/i);
        }
    }
    ll ans=0;
    for(ll i=0; i<mm.size(); i++){
        if(mm[i]<=(m/n)) ans=max(ans,mm[i]);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

int main(void){

  int n;
  std::cin >> n;

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

  std::vector<llint> cost(100, 0);

  for(const auto& elem: X){
    for(int i=0; i<cost.size(); i++){
      cost[i] += (elem-i-1)*(elem-i-1);
    }
  }

  /**
  for(const auto& elem: cost){
    std::cout << elem << " ";
  }
  std::cout << std::endl;
  **/
  
  llint result = std::accumulate(cost.begin(), cost.end(), 99999999L, [](llint acc, llint i){ return std::min(acc, i);});
  std::cout << result << std::endl;

  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <sstream>
#include <deque>
#include <queue>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>

using namespace std;

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define graph vector<vector<int>>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define f first
#define s second
#define hashmap unordered_map
#define hashset unordered_set
#define eps 1e-9
#define mod 1000000007
#define inf 3000000000000000007ll
#define sz(a) signed(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#ifdef DEBUG
    mt19937 gen(857204);
#else
    mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

template<class T, class U> inline void checkmin(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void checkmax(T &x, U y) { if (y > x) x = y; }
template<class T, class U> inline bool ifmax(T &x, U y) { if (y > x) return x = y, true; return false; }
template<class T, class U> inline bool ifmin(T &x, U y) { if (y < x) return x = y, true; return false; }
template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline void rsort(T &a) { sort(rall(a)); }
template<class T> inline void reverse(T &a) { reverse(all(a)); }
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.f >> p.s; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }
template<class T> inline T sorted(T a) { sort(a); return a; }

signed main() {
    FAST; FIXED;
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    map<int, int> cnt;
    for (auto i : a) cnt[i]++;
    ll sum = 0;
    for (auto i : cnt) sum += i.s * (ll)(i.s - 1) / 2;
    for (auto i : a) cout << sum - cnt[i] * (ll)(cnt[i] - 1) / 2 + (cnt[i] - 2) * (ll)(cnt[i] - 1) / 2 << '\n';
    #ifdef DEBUG
        cerr << "Runtime is: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x,res=0;
    cin>>x;
    int y=x/500;
    res+=y*1000;
    x-=y*500;
    cout<<res+(x/5)*5;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c,d,m,s;
	cin >> a;cin >> b;cin >> c;cin >> d;
	d=a+b+c+d;
	m=d/60;
	d=d-60*m;
	s=d;
	cout << m << endl;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    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
}

int fast_pow(long long base, long long n, long long M)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return base;
    long long halfn = fast_pow(base, n / 2, M);
    if (n % 2 == 0)
        return ( halfn * halfn ) % M;
    else
        return ( ( ( halfn * halfn ) % M ) * base ) % M;
}

int findMMI_fermat(int n, int M)
{
    return fast_pow(n, M - 2, M);
}

int32_t main() {

    zeus();

    int x[5];

    int ans;

    forn(i, 0, 5) {
        cin >> x[i];
    }

    forn(i, 0, 5) {
        if (x[i] == 0) {
            ans = i + 1;
            break;
        }
    }
    cout << ans << endl;


}




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

int main(void)
{
	bool a[30] = {false};
  int n, i;
  
  for(i = 0; i < 28; i++){
    cin >> n;
    a[n] = true;
    }
  for(i = 1; i <= 30; i++){
    if(a[i] == false){
      cout << i << endl;
      }
    }
	return (0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
vector<char> S(10);
int N;
void doukei(int n){
  if(n==N-1){
    if(n==0){
      cout << 'a' << endl;
    }else{
      char m='a';
      for(int i=0;i<n;i++){
        m=max(m,S.at(i));
      }
      for(char i='a';i<=m+1;i++){
        S.at(n)=i;
        for(int j=0;j<N;j++){
          cout << S.at(j);
        }
        cout << endl;
      }
    }
  }else if(n==0){
    doukei(1);
  }else{
    char m='a';
    for(int i=0;i<n;i++){
      m=max(m,S.at(i));
    }
    for(char i='a';i<=m+1;i++){
      S.at(n)=i;
      doukei(n+1);
    }
  }
}
int main(){
  
  cin >> N;
  
  for(int i=0;i<N;i++){
    S.at(i)='a';
  }
  doukei(0);
  
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll K,A,B; cin>>K>>A>>B;
	if(B<=A+2) cout<<K+1;
	else{
		if(K<A+1) cout<<K+1;
		else{
			ll turn=K-A-1;//bis B
			cout<<B+(turn/2)*(B-A)+(turn-(turn/2)*2);
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		if(n < 1200) {
			System.out.println("ABC");
		}else if(n < 2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}
	}
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  set<int> sss;
  vector<int> a(n); cin >> a;
  vector<int> vb(n); cin >> vb;
  deque<int> b;
  for(int i = 0; i < n; ++i){
    sss.insert(vb[i]);
    b.push_back(vb[i]);
  }
  vector<int> v;
  bool f = true;
  for(int j = 0; j < 200; ++j){
    v.clear();
    f = true;
    if(j > 0){
      if(b.front() == b.back()){
	dline;
	f = false;
	break;	
      }
      int x = b.front();
      while(b.front() == x){
	b.pop_front();
	b.push_back(x);
      }
    }
    deque<int> bb = b;
    for(int i = 0; i < n; ++i){
      if(j >= 100){
	if(bb.back() != a[i]){
	  v.push_back(bb.back());
	  bb.pop_back();
	} else if(bb.front() != a[i]){
	  v.push_back(bb.front());
	  bb.pop_front();
	} else {
	  f = false;
	  break;
	}
      } else{
	if(bb.front() != a[i]){
	  v.push_back(bb.front());
	  bb.pop_front();
	} else if(bb.back() != a[i]){
	  v.push_back(bb.back());
	  bb.pop_back();
	} else {
	  f = false;
	  break;
	}
      }
    }
    if(f)break;
  }
  if(f){
    cout << "Yes" << endl;
    for(int i = 0; i < n; ++i){
      if(i)cout << ' ';
      cout << v[i];
    }
    cout << endl;
    return 0;
  }else{
    cout << "No" << endl;
  }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  cout << (A <= 8 && B <= 8 ? "Yay!" : ":(") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define int long long 
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
priority_queue<int>p; //大根堆 存储第1-mid
priority_queue<int,vector<int>,greater<int> >q; //小根堆 存储第mid+1-n
int cnt,t; //cnt为当前序列的数的数量 
int ansp,ansq,cntp,cntq;
void insert(int temp){
    int mid=(q.empty())?0:q.top();
    if(temp>mid) q.push(temp),ansq+=temp,cntq++;
    else p.push(temp),ansp+=temp,cntp++;
    cnt++;
    if((cnt&1)&&p.size()>q.size()){ //大根堆 > 小根堆 
        int temp0=p.top(); ansp-=temp0,cntp--;p.pop();
        q.push(temp0);
        ansq+=temp0;cntq++;
    }
    else if((cnt&1)==0&&q.size()>p.size()){ //小根堆 > 大根堆+1
                int temp0=q.top(); ansq-=temp0,cntq--;q.pop();
                p.push(temp0);ansp+=temp0;cntp++;
    }
}
int qmid(){
	if(cnt&1) return q.top();
    else return p.top();
}
int ansb;
signed main(){
	int q=read();
	for(int i=1;i<=q;i++){
		int opt=read();
		if(opt==1){
			int val=read();insert(val);
			ansb+=read();
		} else{
			int Mid=qmid();
			printf("%lld %lld\n",Mid,(cntp*Mid-ansp)+(ansq-cntq*Mid)+ansb);
		}
	}
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,A,B;
  cin>>N>>A>>B;
  if((B-A)%2==0)
    cout<<(B-A)/2<<endl;
  else if(A+B-1<N*2-(A+B)+1)
    cout<<(B+A-1)/2<<endl;
  else
    cout<<(N*2-(A+B)+1)/2<<endl;
}

Measured memory_bytes: 3632
n = int(input())
str_dict = dict()
for i in range(n):
    s = input()
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] += 1

m = int(input())
for i in range(m):
    t = input()
    if t not in str_dict:
        str_dict[t] = -1
    else:
        str_dict[t] -= 1

res = max(0, sorted(list(str_dict.values()))[-1])
print(res)


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int D;
    cin >> D;
    ll c[26], sum = 0;
    rep(i, 26) {cin >> c[i]; sum += c[i];}
    ll s[D][26];
    rep(i, D){
        rep(j, 26) cin >> s[i][j];
    }
    int pre[26];
    fill(pre, pre+26, -1);
    int t[D];
    rep(i, D){
        ld tmp[26];
        rep(j, 26){
            tmp[j] = s[i][j] + c[j]*(i-pre[j])*((ld)(D-i)*c[j]/(ld)(sum));
        }
        int res = -1;
        ld m = -INF;
        rep(j, 26){
            if(chmax(m, tmp[j])) res = j;
        }
        pre[res] = i;
        t[i] = res;
        //cout << res+1 << endl;
    }
    ll tmp = 0;
    set<int> ids[26];
    rep(i, 26) ids[i].insert(-1);
    rep(i, D){
        //cin >> t[i]; t[i]--;
        tmp += s[i][t[i]];
        pre[t[i]] = i;
        ids[t[i]].insert(i);
        rep(j, 26){
            tmp -= c[j]*(i-pre[j]);
        }
    }
    rep(i, 26) ids[i].insert(D);
    rep(k, 10){
        rep(i, D){
            rep(j, 26){
                int d, q;
                //cin >> d >> q;
                d = i, q = j;
                int p = t[d];
                ll ans = tmp-s[d][p]+s[d][q];
                set<int>::iterator it1, it2;
                it1 = ids[p].upper_bound(d);
                it2 = ids[q].upper_bound(d);
                int a1, a2, b1, b2;
                b1 = *it1, b2 = *it2;
                it1--, it1--, it2--;
                a1 = *it1, a2 = *it2;
                ans -= c[p]*(b1-d)*(d-a1);
                ans += c[q]*(b2-d)*(d-a2);
                if(chmax(tmp, ans)){
                    t[d] = q;
                    ids[p].erase(d);
                    ids[q].insert(d);
                }
            }
        }
    }
    rep(i, D) cout << t[i]+1 << endl;
}

Measured memory_bytes: 3704
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll A, B;
    cin >> A >> B;
    for (ll C = 1; C <= 3; C++) {
        if (A * B * C % 2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x%mod;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res%mod;
}
const int MAXN = (1<<12)+5;
int n,m,k,c,val[MAXN],sta[MAXN],dp[MAXN];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	del(dp,0x3f),dp[0]=0;
	read(n),read(m);
	for(ri i=1;i<=m;++i){
		read(val[i]),read(k);
		for(ri j=1;j<=k;++j) read(c),sta[i]|=(1<<(c-1));
	}
	for(ri i=1;i<=m;++i)
		for(ri j=(1<<n)-1;j>=0;--j)
			dp[j|sta[i]]=min(dp[j|sta[i]],dp[j]+val[i]);
	if(dp[(1<<n)-1]==INF) puts("-1");
	else print(dp[(1<<n)-1]);
	return 0;
}

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

int main() {
	int n, m; cin >> n >> m;
	dsu uf(n);
	while(m--) {
		int a, b; cin >> a >> b;
		--a, --b;
		uf.merge(a, b);
	}
	int ans = -1;
	for(int i = 0; i < n; ++i) {
		if(i == uf.leader(i)) ++ans;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3752
fun main(args: Array<String>) {
    val (w, h, x, y) = readLine()!!.split(' ').map { it.toDouble() }
    val ans1 = w * h / 2.0
    val ans2 = if (x * 2 == w && y * 2 == h) 1 else 0
    println("$ans1 $ans2")
}


Measured memory_bytes: 36428
H,W = list(map(int,input().split()))
a = []
for i in range(H):
    a.append(list(map(str,input().split())))
s = ['#' for i in range(W+2)]
print(''.join(s))
for i in range(H):
    print('#' + ''.join(a[i]) + '#')
print(''.join(s))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
const ll INF = 1e15;

struct Edge {
  int to;
  ll cost;
};

int N;
vector<vector<Edge>> G;

ll prim() {
  vector<ll> mincost(N, INF);
  vector<bool> reached(N, false);
  
  mincost.at(0) = 0;
  
  priority_queue<P, vector<P>, greater<P> > q;
  q.push(P(0, 0));
  
  ll ans = 0;
  
  while (!q.empty()) {
    P p = q.top();
    q.pop();
    
    int v = p.second;
    
    if (reached.at(v)) continue;
    reached.at(v) = true;
    ans += mincost.at(v);
    
    for (Edge e : G.at(v)) {
      if (mincost.at(e.to) > e.cost) {
        mincost.at(e.to) = e.cost;
        q.push(P(mincost.at(e.to), e.to));
      }
    }
  }
  return ans;
}

int main() {
  cin >> N;
  G.resize(N);
  
  vector<P> forX(N);
  vector<P> forY(N);
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    
    forX.at(i) = (P(x, i));
    forY.at(i) = (P(y, i));
  }
  
  sort(forX.begin(), forX.end());
  sort(forY.begin(), forY.end());
  
  ll before = forX.at(0).first;
  int beforeI = forX.at(0).second;
  
  for (int i = 1; i < N; i++) {
    ll x = forX.at(i).first;
    int currentI = forX.at(i).second;
    G.at(currentI).push_back(Edge{beforeI, x - before});
    G.at(beforeI).push_back(Edge{currentI, x - before});
    
    before = x;
    beforeI = currentI;
  }
  
  before = forY.at(0).first;
  beforeI = forY.at(0).second;
  for (int i = 1; i < N; i++) {
    ll y = forY.at(i).first;
    int currentI = forY.at(i).second;
    G.at(currentI).push_back(Edge{beforeI, y - before});
    G.at(beforeI).push_back(Edge{currentI, y - before});
    
    before = y;
    beforeI = currentI;
  }
  
  cout << prim() << endl;
  
  return 0;
}

Measured memory_bytes: 17652
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << max(0, (n-h+1)*(n-w+1)) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  char A;
  bool B=false;
  rep(i,3){
    cin>>A;
    if(A=='7')B=true;
  }
  if(B)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3604
n, m, x, y = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)
ys = gets.split.map(&:to_i)

nowar = false
(x + 1).upto(y) do |z|
  nw = true

  xs.each do |x1|
    nw = false unless x1 < z
  end

  ys.each do |y1|
    nw = false unless z <= y1
  end

  if nw
    nowar = true
    break
  end
end

puts(nowar ? 'No War' : 'War')

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line1 = input.readLine();
        String line2 = input.readLine();

        String[] h1 = line1.split(" ");
        int[] h2 = Arrays.stream(h1).mapToInt(Integer::parseInt).toArray();

        String[] s1 = line2.split(" ");
        int sum = Arrays.stream(s1).mapToInt(Integer::parseInt).sum();
 
        if(h2[0] > sum){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
        
    }
}



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

int main(){
    string n;
    cin >> n;
    if(n[0] =='7' || n[1] =='7' || n[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
from math import cos, radians, sin, sqrt

def g(a, b, c):
    c_rad = radians(c)
    yield a * b * sin(c_rad) / 2
    yield a + b + sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(c_rad))
    yield b * sin(c_rad)

a, b, c = list(map(int, input().split()))

for i in g(a, b, c):
    print("{:.8f}".format(i))

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    vector<int64_t> q(n);
    for (auto i : irange(0L, n)) {
        int64_t p;
        cin >> p;
        q[p - 1] = i + 1;
    }

    const auto* delim = "";
    for (auto i : irange(0L, n)) {
        cout << delim << n * i + q[i];
        delim = " ";
    }
    cout << endl;

    delim = "";
    for (auto i : irange(0L, n)) {
        cout << delim << n * (n - i);
        delim = " ";
    }
    cout << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

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

const int MAX_N=2e5;

ll fact(ll n){
	ll ret=1;
	FOR(i,1,n+1){
		ret*=i;
		ret%=MOD;
	}
	return ret;
}

ll mod_pow(ll n,ll m){
	if (m==0){
		return 1;
	}
	ll ret=mod_pow(n,m/2);
	ret*=ret;
	ret%=MOD;
	if (m%2){
		ret*=n;
		ret%=MOD;
	}
	return ret;
}

ll mod_inv(ll n){
	return mod_pow(n,MOD-2);
}

ll f[MAX_N+1],finv[MAX_N+1];

ll comb(ll n,ll m){
	return f[n]*finv[m]%MOD*finv[n-m]%MOD;
}

int main(){
	ll H,W,A,B;
	cin>>H>>W>>A>>B;
	f[0]=1;
	FOR(i,1,MAX_N+1){
		f[i]=f[i-1]*i%MOD;
	}
	REP(i,MAX_N+1){
		finv[i]=mod_inv(f[i]);
	}
	ll ans=comb(W+H-2,H-1);
	REP(i,B){
		ans-=comb(H-A-1+i,H-A-1)*comb(A-1+W-1-i,A-1)%MOD;
		ans+=MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int lx = 0;
    int ly = 0;
    int rx = w;
    int ry = h;
    rep(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            lx = max(lx, x);
        } else if (a == 2) {
            rx = min(rx, x);
        } else if (a == 3) {
            ly = max(ly, y);
        } else {
            ry = min(ry, y);
        }
    }

    if (rx - lx > 0 and ry - ly > 0) cout << (rx - lx) * (ry - ly) << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int a,b;
  cin>>a>>b;
  if((a+b)>=10){
    cout<<"error";
  }else{
	cout<<a+b;
  }
    return 0;
}

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

class Solution
{
	public:
		int curtains(int totalWidth,int singleWidth)
		{
			int totalCovered=singleWidth*2;
			int open=max(0,totalWidth-totalCovered);
			return open;
}
};
int main()
{
	int a,b;
	cin>>a>>b;
	Solution open;
	cout<<open.curtains(a,b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t a, b, x;
	cin >> a >> b >> x;
	b = b - b % x;
	a = (a + x - 1)/x;
	a *= x;
	cout << (b - a) / x + 1 << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
	char c;
	cin>>c;
	if(isupper(c)) puts("A");
	else puts("a");
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
A = [int(x) for x in input().split()]

mod = 10**9 + 7

cusum = [0]
for i in range(n):
    cusum.append(cusum[i]+A[i])

totalSum = 0
for i in range(n-1):
    sum = (cusum[n] - cusum[i + 1]) % mod
    totalSum += sum * A[i]
    totalSum %= mod

print(totalSum)


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

constexpr std::int_fast64_t f(const std::int_fast64_t n, const std::int_fast64_t counter) {
  return n == 1 || n == 2 || n == 4
    ? counter + 3
    : n % 2 == 0 ? f(n / 2, counter + 1) : f(3 * n + 1, counter + 1);
}

template <int... V> struct sequence {
  template <typename T> using join = typename T::template prepend<V...>;
  template <int... U> using prepend = sequence<U..., V...>;
  static constexpr std::array<int, sizeof...(V)> value = {V...};
};
template <int... V> constexpr std::array<int, sizeof...(V)> sequence<V...>::value;

template <int I, int N> struct answer_range {
  using to_sequence = typename answer_range<I, N / 2>::to_sequence::template join<typename answer_range<I + N / 2, N - N / 2>::to_sequence>;
};
template <int I> struct answer_range<I, 1> {
  using to_sequence = sequence<f(I, 1)>;
};

int main() {
  std::int_fast64_t s;
  std::cin >> s;
  std::cout << answer_range<1, 100>::to_sequence::value[s - 1] << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a<b){
        if(b<c){
            printf("%d %d %d\n", a, b, c);
        }else{
            if(a>c){
                printf("%d %d %d\n", c, a, b);
            }
            else{
                printf("%d %d %d\n", a, c, b);
            }
        }
    }
    else{
        if(a<c){
            printf("%d %d %d\n", b, a, c);
        }
        else{
            if(b>c){
                printf("%d %d %d\n", c, b, a);
            }
            else{
                printf("%d %d %d\n", b, c, a);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
	if(n<=1)return false;
	if(n<=3)return true;
	if(n%2==0||n%3==0)return false;
	for(ll i=5;i*i<=n;i+=6)
	{
		if(n%i==0||n%(i+2)==0)return false;
	}
	return true;
}

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)r=(r*a)%m;
		b = b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
    ll n; cin>>n;
    map<ll,ll>mp;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            ll x = __gcd(i,j);
            mp[x]++;
        }
    }
    ll ans=0;
    for(auto x:mp)
    {
        for(ll i=1;i<=n;i++)
        {
            ll y = __gcd(i,x.fi);
            ans+=(y*x.se);
        }
    }
    cout<<ans<<endl;
	return 0;
}
/*
1
4
4 2
10 3
3 4
9 2
*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    ll L, R; 
    cin >> L >> R;
    int l[61], r[61];
    rep(i, 61){
        l[i] = L%2, r[i] = R%2;
        L /= 2, R /= 2;
    }
    ll dp[61][2][2][2];
    rep(i, 61)rep(j, 2)rep(k, 2)rep(m, 2) dp[i][j][k][m] = 0;
    dp[60][0][0][0] = 1;
    rep3(i, 59, 0){
        rep(j, 2)rep(k, 2)rep(m, 2){
            ll pre = dp[i+1][j][k][m];
            rep(x, 2)rep(y, 2){
                if(x == 1 && y == 0) continue;
                int nj = j, nk = k, nm = m;
                if(x == 0 && l[i] == 1 && j == 0) continue;
                if(x == 1 && l[i] == 0) nj = 1;
                if(y == 1 && r[i] == 0 && k == 0) continue;
                if(y == 0 && r[i] == 1) nk = 1;
                if(x == 0 && y == 1 && m == 0) continue;
                if(x == 1 && y == 1) nm = 1;
                dp[i][nj][nk][nm] += pre;
                dp[i][nj][nk][nm] %= MOD;
            }
        }
    }
    ll ans = 0;
    rep(j, 2)rep(k, 2)rep(m, 2){
        ans += dp[0][j][k][m];
        ans %= MOD;
    }
    cout << ans << endl;
}

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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(10e9-1);
const long long MOD = int(10e9+7);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    int X;
    cin >> X;
    int times = X/100;
    int low = X%100;
    if(low <= times*5){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int T = cin.ReadInt;
            int sumT = 0;
            int oldT = cin.ReadInt;
            int newT = 0;
            int dT = 0;

            for (int i = 1; i < N; i++)
            {
                newT = cin.ReadInt;
                if(newT-oldT < T) sumT += newT-oldT;
                else sumT += T;
              	oldT = newT;
            }
            sumT += T;
            WriteLine(sumT);
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 29088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll MAX_V = 300;
// d[u][v]は辺（u, v)のコスト
vector<vector<ll> > d(MAX_V, vector<ll>(MAX_V, INF));
// 頂点数
ll V;

void warshall_floyd() {
    rep(k, V){
        rep(i, V){
            rep(j, V){
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

// ---------------------------------------------------
// O(|V|^3) すべての２頂点間の最短路を求める(ワーシャル・フロイド法)
// ---------------------------------------------------

int main(){
    ll H, W, cost, a, ans = 0;
    cin >> H >> W;
    V = 10;
    rep(i, V){
        d[i][i] = 0;
    }
    rep(y, 10){
        rep(x, 10){
            cin >> cost;
            d[y][x] = cost;
        }
    }
    warshall_floyd();
    
    rep(h, H){
        rep(w, W){
            cin >> a;
            if(a != -1){
                ans += d[a][1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4356
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=2010;
int n;
int L[MAXN];
int coo(int x,int y)
{
	if(x<y)  return 1;
	return 0;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)  cin>>L[i];
	sort(L,L+n,coo);
	int k;
	long long ans=0;
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			k=L[i]+L[j];
			int p=lower_bound(L+j+1,L+n,k)-L;
			ans+=p-j-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3536