akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main()
{
    int A,B,C;
    scanf("%d %d",&A,&B);
   if(1<=A && A<=9 && 1<=B && B<=9)
    {
      C=A+B;
       if(C<=9)printf("%d",C);
       else printf("error");
    }

    return 0;
}

Measured memory_bytes: 1724
#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(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)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int dist(int a,int b,int c,int d){
    return abs(a - c) + abs(b - d);
}

int main(void) {
    int i,j;
    int n, m;
    cin >> n >> m;
    vi a(n),b(n),c(m),d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];
    rep(i,n){
        int ans = 0;
        rep(j,m){
            if(dist(a[i],b[i],c[j],d[j]) < dist(a[i],b[i],c[ans],d[ans]))ans = j;
        }
        cout << ans + 1 << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int count(int y, int m, int d){
        int ret=0;
        ret+=590 * ((y-1)/3) + 195 * ((y-1)%3);
        For(i, 1, m){
                if(y%3==0) ret+=20;
                else ret+=19 + (i%2);
        }
        ret+=d;
        return ret;
}

int main(){
        int n;
        scanf("%d", &n);
        int a=count(1000, 1, 1);
        rep(i, n){
                int y, m, d;
                scanf("%d%d%d", &y, &m, &d);
                printf("%d\n", a-count(y, m, d));
        }
}


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

struct Stone
{
  int height;
  int shortestPath;
};

int main()
{
  int nbStones, K;
  cin >> nbStones >> K;
  vector<Stone> stones;
  for (int i = 0; i < nbStones; i++)
  {
    int height;
    cin >> height;
    stones.push_back({height, 0});
  }
  stones[nbStones - 2].shortestPath = abs(stones[nbStones - 1].height - stones[nbStones - 2].height);
  for (int j = nbStones - 3; j >= 0; j--)
  {
    stones[j].shortestPath = stones[j+1].shortestPath + abs(stones[j].height - stones[j+1].height);
    for (int m = 2; m <= min(K, nbStones - j - 1); m++)
      if (stones[j+m].shortestPath + abs(stones[j].height - stones[j+m].height) < stones[j].shortestPath)
	  stones[j].shortestPath = stones[j+m].shortestPath + abs(stones[j].height - stones[j+m].height);
  }
  cout << stones[0].shortestPath << '\n';
}


Measured memory_bytes: 1400
n, k = input().split()
n = int(n)
k = int(k)
c = []
d = [0]*k
for i in range(k):
	d[i] = int(input())
	a = list(map(int, input().split()))
	
	for j in range(d[i]):
		if c.count(a[j]) == 0:
			c.append(a[j])
			
print(n-len(c))
		

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A), greater<>());
    ll ans = 1;
    int cnt = 0;
    rep(i, N-1) {
        if (cnt < 2 && A[i] == A[i+1]) {
            ans *= A[i];
            i++;
            cnt++;
        }
    }
    if (cnt < 2) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include <numeric>
using namespace std;
unsigned long a, b;
#include <stdio.h>
int main(void)  {
    cin >> a >> b;
    unsigned long i;
    i = 1;
    while (true) {
        if ( a * i % b ==0) {
            cout << a * i << endl;
            break;
        }
        i++;
    }
}

Measured memory_bytes: 256
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
 
def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                bar += "#"
            if i < H - 1: print(bar)
            else: print(bar + '\n')
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 5616
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

  ll N,L,ans = 0; cin >> N >> L;
  ll rmv = L;
  for (ll i = 1; i <= N; ++i) {
  	ans += L+i-1;
    if (abs(L+i-1) < abs(rmv)) rmv = L+i-1;
  }
  cout << ans - rmv << endl;
  return 0;
}


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

namespace ALDS1_14_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var T = Console.ReadLine();
            var P = Console.ReadLine();

            RollingHash TS = new RollingHash(T);
            RollingHash TP = new RollingHash(P);

            var matchLeng = P.Length;
            var matchHash = TP.GetRollingHash(0, P.Length);

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i + matchLeng <= T.Length; i++)
            {
                var hash = TS.GetRollingHash(i, i + matchLeng);
                if (hash == matchHash) sb.AppendLine(i.ToString());
            }

            Console.Write(sb);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
    class RollingHash
    {
        const long B = 1000000009;
        string S;
        int N;
        ulong[] Power;
        ulong[] Hash;
        public RollingHash(string s)
        {
            S = s;
            N = s.Length;

            Power = new ulong[N + 1];
            Power[0] = 1;
            for (int i = 0; i < N; i++)
            {
                Power[i + 1] = Power[i] * B;
            }

            Hash = new ulong[N + 1];
            for (int i = 0; i < N; i++)
            {
                Hash[i + 1] = Hash[i] * B + S[i];
            }
        }
        //[l,r)
        public ulong GetRollingHash(int l, int r)
        {
            var hash = Hash[r] - Hash[l] * Power[r - l];
            return hash;
        }
    }

}



Measured memory_bytes: 62348
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        ab: [(usize, usize); n],
    }
    let mut a = ab.iter().map(|&(ai, _)| ai).collect::<Vec<_>>();
    let mut b = ab.iter().map(|&(_, bi)| bi).collect::<Vec<_>>();
    a.sort();
    b.sort();

    if n % 2 == 0 {
        let a_m = a[n / 2 - 1] + a[n / 2];
        let b_m = b[n / 2 - 1] + b[n / 2];
        println!("{}", b_m + 1 - a_m);
    } else {
        let a_m = a[n / 2];
        let b_m = b[n / 2];
        println!("{}", b_m + 1 - a_m)
    }
}


Measured memory_bytes: 12924
#include <stdio.h>

int factorize(long long n, long long p[], int m[])
{
	int k;
	long long i;
	for (i = 2, k = 0; i * i <= n; i++) {
		if (n % i != 0) continue;
		p[k] = i;
		for (m[k] = 0; n % p[k] == 0; m[k]++, n /= p[k]);
		k++;
	}
	if (n > 1) {
		p[k] = n;
		m[k++] = 1;
	}
	return k;
}

long long count_divisors(long long n)
{
	int i, k, m[100];
	long long p[100], ans = 1;
	k = factorize(n, p, m);
	for (i = 0; i < k; i++) ans *= m[i] + 1;
	return ans;
}

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long K, n, ans = 0;
	for (K = 2; K * K <= N; K++) {
		if (N % K != 0) continue;
		for (n = N; n % K == 0; n /= K);
		if (n % K == 1) ans++;
	}
	printf("%lld\n", ans + count_divisors(N - 1));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
    Graph x(200005);
    vector<lint> ans;
    void dfs(lint v,lint p=-1){
        for(lint u:x[v]){
            if(u==p)continue;
            ans[u]+=ans[v];
              dfs(u,v);
        }
    }

  int main(){
   lint n,q;
   cin>>n>>q;
   ans.resize(n);
    rep(i,n-1){
       lint a,b;
       cin>>a>>b;
       --a;
       --b;
       x[a].push_back(b);
       x[b].push_back(a);
   }
   rep(i,q){
       lint a,x;
       cin>>a>>x;
        --a;
        ans[a]+=x;
   }
   dfs(0);
   rep(i,n){
       cout<<ans[i]<<endl;
   }
  }
  

Measured memory_bytes: 24320
//Minimum Spanning Tree
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


class UnionFindTree {
private:
    vector<int> p, rank;
public:
    UnionFindTree(int size) {
        p = vector<int>(size);
        rank = vector<int>(size,0);
        for(int i=0; i<size; i++) p[i] = i;
    }

    int findSet(int x) {
        if(p[x] != x) p[x] = findSet(p[x]);
        return p[x];
    }

    void unite(int x, int y) {
        int sx = findSet(x), sy = findSet(y);
        if(rank[sx] > rank[sy]) p[sy] = sx;
        else {
            p[sx] = sy;
            if(rank[sx] == rank[sy]) rank[sx]++;
        }
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }
};

class Edge {
public:
    int s, t, c;
    Edge(int s, int t, int c): s(s), t(t), c(c) {}
    bool operator < (const Edge e) const {return c < e.c;}
};

int kruskal(int n, vector<Edge> &E) {
    UnionFindTree ut(n);

    sort(E.begin(), E.end());
    int d = 0;
    for(auto e: E) {
        if(ut.same(e.s, e.t)) continue;
        d += e.c;
        ut.unite(e.s, e.t);
    }
    return d;
}

int main() {
    int n, m, s, t, c;
    vector<Edge> E;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        cin >> s >> t >> c;
        E.push_back(Edge(s, t, c));
    }

    cout << kruskal(n, E) << endl;

    return 0;
}



Measured memory_bytes: 4540
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define mp make_pair
 
typedef long double DOUBLE;
typedef complex<DOUBLE> COMPLEX;
typedef vector<DOUBLE> VD;
typedef vector<COMPLEX> VC;

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

 
void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}
 
void get(vector<auto> &a)
{
    for (int i = 0; i<(int)a.size(); i++) cin>>a[i];
}
 
const int p = 998244353;
 
 
int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}
 
int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}
 
int sub(int a, int b) {
    int s = (a-b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}
 
int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}
 
int inv(int n)
{
    return po(n, p-2);
}
 
vector<int> Z(vector<int> s)
{
int n = s.size();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}

mt19937 rnd(time(0));

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

    int n, a, b, c, d;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    a--;
    b--;
    c--;
    d--;
    for (int i = a+1; i<c; i++) if (s[i]=='#'&&s[i+1]=='#') {cout<<"No"; return 0;}
    for (int i = b+1; i<d; i++) if (s[i]=='#'&&s[i+1]=='#') {cout<<"No"; return 0;}    
    if (d>c) {cout<<"Yes"; return 0;}
    for (int i = b; i<=d; i++) if (s[i]=='.'&&s[i-1]=='.'&&s[i+1]=='.') {cout<<"Yes"; return 0;}
    cout<<"No";
    

}

Measured memory_bytes: 892
n = gets.to_i
pa = gets.split(" ").map(&:to_i)
qa = gets.split(" ").map(&:to_i)
p,q = 0,0

l = (1..n).to_a
n.times do |i|
  s = l.count {|j| j < pa[i]}
  if s != 0 then
    t = (1..(n-i-1)).to_a.inject(1) {|k, m| k*m}
    p += t * s
  end
  l.delete(pa[i])
end

l = (1..n).to_a
n.times do |i|
  s = l.count {|j| j < qa[i]}
  if s != 0 then
    t = (1..(n-i-1)).to_a.inject(1) {|k, m| k*m}
    q += t * s
  end
  l.delete(qa[i])
end

print (p-q).abs

Measured memory_bytes: 1788
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)

int32_t main()
{
    int n;
    cin >> n;
    int a, b;
    vector<pair<int, int>> pt;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        pt.push_back(make_pair(a, b));
    }
    int cnt = 0;
    bool found = false;
    for (int i = 0; i < n - 3 + 1; i++)
    {  cnt = 0;
        if (pt[i].first == pt[i].second)
        {
            cnt++;
            int j = i + 1;
            while (j < n && pt[j].first == pt[j].second)
            {
                cnt++;
                j++;
            }
            if (cnt >= 3)
            {
                found = true;
                break;
            }
        }
    }
    if (found)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define N 200123
#define ll long long
using namespace std;

ll n, lista[N-1], v[N];

int main(){
	cin >> n;
	for(int i = 0; i < n-1; i++){
		cin >> lista[i];
		v[lista[i]-1]++;
	}
	for(int i = 0; i < n; i++){
		cout << v[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
#define int long long int

int32_t main(){

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int n;cin>>n;
int sum=0;
for(int i=1;i<=n;i++)
{
    if(i%3==0 || i%5==0)
    {
    continue;
    }
    sum+=i;

}
cout<<sum<<"\n";
}


Measured memory_bytes: 3652
import java.util.*;
class Main{
  	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args) {
    	double D = scan.nextDouble();
      	double T = scan.nextDouble();
      	double S = scan.nextDouble();
      	double reqTime = (D / S);
      	if(reqTime > T) {
        	System.out.println("No");
        }else {
        	System.out.println("Yes");
        }
    }
}

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

#define rep(i,n) for(i=0;i<(n);i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  int i;
  int N; cin >> N;
  int P[N],Q[N],tmp[N];
  int ansP=-1,ansQ=-1;
  rep(i,N){cin >> P[i];}
  rep(i,N){cin >> Q[i];}
  rep(i,N){tmp[i]=i+1;}
  int idx = 0;
  do{
      bool isP=true,isQ=true;
      rep(i,N){
          if(P[i]!=tmp[i]){isP=false;}
          if(Q[i]!=tmp[i]){isQ=false;}
      }
      if(isP){ansP=idx;}
      if(isQ){ansQ=idx;}
      idx++;
  }while(next_permutation(tmp,tmp+N));
  cout << max(ansP,ansQ)-min(ansP,ansQ) << endl;

  return 0;
}


Measured memory_bytes: 3656
N=int(input())
a=list(map(int,input().split()))
M=0
b=[]
M=0
for i in range(N):
    b.append(0)
for j in range(N,0,-1):
    cnt=0
    for k in range(j,N+1,j):
        cnt+=b[k-1]
    if cnt%2!=a[j-1]:
        b[j-1]=1
        M+=1
c=[l+1 for l, x in enumerate(b) if x==1]
c=list(map(str,c))
print(M)
print(' '.join(c))

Measured memory_bytes: 19004
import sys

input = sys.stdin.readline

R, C, K = map(int, input().split())
D = dict()
for _ in range(K):
    r, c, v = map(int, input().split())
    D[(r, c)] = v

dp0 = [[0] * (C + 1) for _ in range(R + 1)]
dp1 = [[0] * (C + 1) for _ in range(R + 1)]
dp2 = [[0] * (C + 1) for _ in range(R + 1)]
dp3 = [[0] * (C + 1) for _ in range(R + 1)]

for r in range(1, R + 1):
    for c in range(1, C + 1):
        m = max(dp0[r - 1][c], dp1[r - 1][c], dp2[r - 1][c], dp3[r - 1][c])
        dp0[r][c] = max(m, dp0[r][c - 1])
        dp1[r][c] = max(m, dp1[r][c - 1])
        dp2[r][c] = max(m, dp2[r][c - 1])
        dp3[r][c] = max(m, dp3[r][c - 1])
        if (r, c) in D:
            dp1[r][c] = max(dp1[r][c], m + D[(r, c)], dp0[r][c - 1] + D[(r, c)])
            dp2[r][c] = max(dp2[r][c], m + D[(r, c)], dp1[r][c - 1] + D[(r, c)])
            dp3[r][c] = max(dp3[r][c], m + D[(r, c)], dp2[r][c - 1] + D[(r, c)])
print(max(dp0[-1][-1], dp1[-1][-1], dp2[-1][-1], dp3[-1][-1]))


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

int main() {
  int a, b, h, m;
  double ang;

  cin >> a >> b >> h >> m;

  ang = 2 * M_PI * ((m / 60.0 + h) / 12.0 - m / 60.0);

  printf("%.15f\n", sqrt(pow(a, 2) + pow(b, 2) - (2.0 * a * b * cos(ang))));
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
#define maxn 100010
typedef long long LL;
const LL mod = 998244353;
LL x[maxn], y[maxn], P[maxn];
int main() {
    LL n;
    scanf("%lld", &n);
    for (int i = 0; i < n; ++i) scanf("%lld%lld", &x[i], &y[i]);
    P[0] = 1;
    for (int i = 1; i <= n; ++i) (P[i] = P[i-1] << 1) %= mod;
    LL ans = P[n] - 1 - n - n*(n-1)/2;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int cnt = 0;
            for (int k = j+1; k < n; ++k) {
                if ((x[j]-x[i]) * (y[k]-y[j]) == (x[k]-x[j]) * (y[j]-y[i])) ++cnt;
            }
            ((ans -= P[cnt]-1) += mod) %= mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      ret.push_back(i);
      if(i*i!=n)ret.push_back(n/i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    vector<ll> yakusuu=divisor(n);
    ans=LINF;
    rep(i,Size(yakusuu)){
        a=yakusuu[i];
        b=n/yakusuu[i];
        s=to_string(a);
        cnt=Size(s);
        s=to_string(b);
        cnt=max(cnt,(ll)Size(s));
        ans=min(ans,cnt);
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	vector<int> dp(n, 0);
	rep(i,n)cin >> h[i];
	dp[0] = 0;;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++){
		int one = dp[i - 1] + abs(h[i] - h[i - 1]);
		int two = dp[i - 2] + abs(h[i] - h[i - 2]);
		dp[i] = min(one, two);
	}
	cout << dp[n- 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

type Combination struct {
	max, mod int
	fact     []int
	factInv  []int
	inv      []int
}

func NewCombination() *Combination {
	c := &Combination{}
	c.max = 200010
	c.mod = int(1e9) + 7
	c.fact = make([]int, c.max)
	c.factInv = make([]int, c.max)
	c.inv = make([]int, c.max)
	return c
}

func (c *Combination) build() {
	c.inv[1], c.fact[0], c.factInv[0] = 1, 1, 1
	var i int
	for i = 2; i < c.max; i++ {
		c.inv[i] = c.inv[c.mod%i] * (c.mod - c.mod/i) % c.mod
	}
	for i = 1; i < c.max; i++ {
		c.fact[i] = c.fact[i-1] * i % c.mod
		c.factInv[i] = c.factInv[i-1] * c.inv[i] % c.mod
	}
}

func (c *Combination) c(n, k int) int {
	if c.inv[0] == 0 {
		c.build()
	}
	if n < 0 || k < 0 || n < k {
		return 0
	}
	return c.fact[n] * c.factInv[k] % c.mod * c.factInv[n-k] % c.mod
}

func (c *Combination) p(n, k int) int {
	if k < 0 || k > n {
		return 0
	}
	return c.fact[n] * c.factInv[n-k] % c.mod
}

func (c *Combination) h(n, k int) int {
	if n == 0 && k == 0 {
		return 1
	}
	return c.c(n+k-1, k)
}

func main() {
	N := nextInt()
	M := nextInt()
	ans := 0
	cmb := NewCombination()
	cmb.build()
	if M > 0 {
		ans += cmb.c(M, 2)
	}
	if N > 0 {
		ans += cmb.c(N, 2)
	}
	fmt.Println(ans)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
     
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i,N) cin >> A[i];
  vector<ll> color(3,0);
  ll ans = 1, id = -1, kouho = 0;  
  REP(i,N){
    id = -1; kouho = 0;     
    REP(j,3) {
      if(A[i] == color[j]) {kouho++; id = j;}
    }
  	if (id == -1) {
	  cout << "0" << endl;
      return 0;
	}
    color[id]++;
    ans *= kouho;
    ans %= MOD;
  }
  cout << ans;
     
  return 0;
}


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

int main(){
	int r,g,b,n;
	cin >> r >> g >> b >> n;
	int new_value, constant;
	int count = 0;
	for(int i = 0; i <= n/r;i++){
		new_value = n - r * i ;
                constant = n - r * i;
		for(int j = 0; j <= constant / g; j++){
			new_value = n - r * i - g * j;
			if (new_value % b == 0){
				count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#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 ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define rep(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

int x,y;cin>>x>>y;
if(y%2==0 && y>=2*x && y<=4*x){
	cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;


return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    int n,cnt;
    
    while (scanf("%d", &n)!=EOF){
        cnt = 0;
        for (int i=0; i<10; i++){
            for (int j=0; j<10; j++){
                for (int k=0; k<10; k++){
                    for (int l=0; l<10; l++){
                        cnt += (i+j+k+l)==n ? 1 : 0;
                    }
                }
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define MAX 100000
#define SENTINEL 2000000000

typedef struct Card
{
  char suit;
  int value;
}card;

card L[MAX/2+2];
card R[MAX/2+2];

void merge(card A[],int n,int left,int mid,int right);
void mergeSort(card A[],int n,int left,int right);
int partition(card A[],int n,int p,int r);
void quickSort(card A[],int n,int p,int r);

int main(void)
{
  int n,i,v;
  card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i = 0;i < n;i++)
    {
      scanf("%s %d",S,&v);
      A[i].suit=B[i].suit=S[0];
      A[i].value=B[i].value=v;
    }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i = 0;i < n;i++)
    {
      if(A[i].suit!=B[i].suit)
	{
	  stable=0;
	}
    }

  if(stable==1)
    {
      puts("Stable");
    }
  else
    {
      puts("Not stable");
    }

  for(i=0;i<n;i++)
    {
      printf("%c %d\n",B[i].suit,B[i].value);
    }

  return 0;
}


void merge(card A[],int n,int left,int mid,int right)
{
  int i,j,k;

  int n1=mid-left;
  int n2=right-mid;

  for(i=0;i<n1;i++)
    {
      L[i]=A[left+i];
    }

  for(i=0;i<n2;i++)
    {
      R[i]=A[mid+i];
    }

  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;

  for(k=left;k<right;k++)
    {
      if(L[i].value<=R[j].value)
	{
	  A[k]=L[i++];
	}
      else
	{
	  A[k]=R[j++];
	}
    }
}


void mergeSort(card A[],int n,int left,int right)
{
  int mid;

  if(left+1 < right)
    {
      mid=(left+right)/2;
      mergeSort(A,n,left,mid);
      mergeSort(A,n,mid,right);
      merge(A,n,left,mid,right);
    }
}

int partition(card A[],int n,int p,int r)
{
  int i,j;
  card t,x;

  x=A[r];
  i=p-1;

  for(j=p;j<r;j++)
    {
      if(A[j].value<=x.value)
	{
	  i++;
	  t=A[i];
	  A[i]=A[j];
	  A[j]=t;
	}
    }

  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;

  return i+1;
}

void quickSort(card A[],int n,int p,int r)
{
  int q;
  if(p<r)
    {
      q=partition(A,n,p,r);
      quickSort(A,n,p,q-1);
      quickSort(A,n,q+1,r);
    }
}



Measured memory_bytes: 4068
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, b, s, a[200005];
int main() {
	int i;
	scanf("%lld", &n);
	for(i=0; i<n; i++) scanf("%d", &a[i]), a[i] -= i;
	sort(a, a+n);
	b = a[n/2];
	for(i=0; i<n; i++) s += abs(a[i] - b);
	printf("%lld", s);
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>



using namespace std;


int n;
int p=0,q=0;
int pp[10],qq[10],nn[10];
vector<int> A;
int cnt=1;
int a=0,b=0;
int nflag = 1;
int inf=1<<21;
int t;

void output_arr(int x[],int n){
    for(int i=0;i<n;i++){
        cout << x[i] << " ";
    }
    cout << endl;
}

bool next_permu(int x[]){
    //output_arr(x,n);
    //cout << "hello" << endl;
    int i=n-2;
    //cout << i << endl;
    while(i>-1 && x[i] > x[i+1]){
        i--; //i-1を常に持っておく 後ろから調べた大きい順でない最初の要素
        //cout << "hello" << endl;
    }
    //cout << "pass" << endl;
    if(i==-1) return false;
    int j=n-1,jj=n-1;
    int minxl=inf;
    while(j>i){
        if(minxl >= x[j] && x[i] < x[j]){
            jj = j;
            minxl = x[j]; 
        }
        j--;
    }
    //cout << i << " " << jj << endl;
    t = x[i];
    x[i] = x[jj];
    x[jj] = t;
    sort(x+i+1,x+n);
    //output_arr(x,n);
    return true;
}
bool check_arr(int x[], int y[], int num){
    for(int i=0;i<num;i++){
        if(x[i] != y[i]) {
            return false;
        }
    }
    return true;
}


int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        nn[i] = i+1;
    }
    for(int i=0;i<n;i++){
        cin >> pp[i];
    }
    for(int i=0;i<n;i++){
        cin >> qq[i];
    }
    int cnt=1;
    while(next_permu(nn)){
        if(check_arr(pp,nn,n)){
            a = cnt;
        }
        if(check_arr(qq,nn,n)){
            b = cnt;
        }
        cnt ++;
    }

    if(a > b){
        cout << a-b << endl;
    }
    else{
        cout << b-a << endl;
    }
return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
a = sorted(list(map(int,input().split())))
amin = a[0]
amax = a[-1]
suma = []
for i in range(amin,amax+1):
    sumb = bisect.bisect_right(a,i+1) - bisect.bisect_left(a,i-1)
    suma.append(sumb)
print(max(suma))

Measured memory_bytes: 14092
from math import gcd
from functools import reduce

MOD = 10 ** 9 + 7

def calc_lcm(x, y):
    return x * y // gcd(x, y)

def calc_lcm_list(numbers):
    return reduce(calc_lcm, numbers, 1)
  
  
N, *A = map(int, open(0).read().split())
lcm = calc_lcm_list(A)
print(sum(lcm * pow(v, MOD - 2, MOD) for v in A) % MOD)


Measured memory_bytes: 75988
S=input()

out=0
l=[0]*2019
x=0
now=1
for i in S[::-1]:
    x+=now*int(i)
    x%=2019
    l[x]+=1

    now*=10
    now%=2019

for i in l:
    out+=(i-1)*i//2
print(out+l[0])

# # 全探索は間に合わない
# D=len(S)-4
# for ii in range(D+1):
#     for i in range(ii+3,len(S)):
#         T=S[ii:i+1]
#         if int(T)%2019==0:
#             out+=1
# print(out)


Measured memory_bytes: 9316
#include <cstdlib>
#include <iostream>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  int a[N], b[N], c[M], d[M];
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> c[i] >> d[i];
  }
  int result[N];
  int temp;
  for (int i = 0; i < N; i++) {
    temp = 300000000;
    for (int j = 0; j < M; j++) {
      if (temp > (abs(a[i] - c[j]) + abs(b[i] - d[j]))) {
        temp = (abs(a[i] - c[j]) + abs(b[i] - d[j]));
        result[i] = j + 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << result[i] << endl;
  }
  return 0;
}

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

#define ll              long long
#define pb              push_back
#define mp              make_pair
#define ff              first
#define ss              second
#define SQ(x)           ((x)*(x))
#define LCM(x,y)        (((x)/gcd((x),(y)))*(y))
#define PI              acos(-1)
#define SZ(x)           x.size() - 1
#define waa             printf("Ripon\n")
#define mem(a,b)        memset(a,b,sizeof(a))
#define rep(i,a,n)      for(int i=(int)(a);i<=(int)(n);i++)
#define per(i,n,a)      for(int i=(int)(n);i>=(int)(a);i--)
#define SC              scanf
#define PF              printf
#define all(v)          v.begin(), v.end()
#define allr(v)         v.rbegin(), v.rend()
#define sc(x)           scanf("%d",&x)
#define scl(x)          scanf("%lld",&x)
#define scc(x,y)        scanf("%d %d",&x,&y)
#define sccl(x,y)       scanf("%lld %lld",&x,&y)
#define sccc(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define scccl(x,y,z)    scanf("%lld %lld %lld",&x,&y,&z)
//Grid tour
int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1 };
int dy[] = { 1, 0, -1, 0, -1, -1, 1, 1 };
int kx[] = { -2, -2, -1, 1, 2, 2, 1, -1 };
int ky[] = { -1, 1, 2, 2, 1, -1, -2, -2 };

#define RW freopen("file.txt","r",stdin); //freopen("out.txt","w",stdout);
#define CPPIO ios_base::sync_with_stdio(0);cin.tie(nullptr);

int overlap(int rs,int re,int qs,int qe){ if(rs>qe or re<qs) return 0; else if(qs<=rs and re<=qe) return 1; else return 2;}

struct DATA{};
#define eps 1e-9
#define inf INT_MAX
#define mx 10000009

void solve(int T) {

    int n,l;
    scc(n,l);

    vector<string> v;

    rep(i,1,n){
        string str;
        cin>>str;
        v.pb(str);

    }


    sort(all(v));

    rep(i,0,SZ(v)){
        cout<<v[i];
    }
    cout<<'\n';



}

int main(){
    //CPPIO

    int T=1;
    for(int t=1;t<=T;t++)   solve(t);
    return 0;
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int n, a, b;

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

  printf("%d\n", (n * a) < b ? (n * a) : b);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int S, a, b;

    cin >> S;

    a = S / 100;
    b = S % 100;

    if(a <= 12 && a != 0 && b <= 12 && b != 0){
        cout << "AMBIGUOUS" << endl;
    }
    else if(a <= 12 && a != 0 && (b > 12 || b == 0)){
        cout << "MMYY" << endl;
    }
    else if((a > 12 || a == 0) && b <= 12 && b != 0){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int X,Y,Z,temp1;
        cin>>X>>Y>>Z;
        temp1= X;
        X = Y;
        Y = temp1;

        temp1 = X;
        X = Z;
        Z = temp1;

        cout<<X<<" "<<Y<<" "<<Z<<endl;
}


Measured memory_bytes: 256
#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 ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;
 
 
 
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    ll d[N+1];
    d[0] = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];  
 
    }
    
    ll ans=0;
    map <int,int> ma;
    for(int j=0;j<N;j++){
        int d = j - A[j];
        ans += ma[d];
        int s = j + A[j];
        ma[s]++;
    }
 
    cout << ans;
    
 
 
 
    return 0;
}

Measured memory_bytes: 21924
#include <stdio.h>

int main(){
	int n;
	int sum=100000;
	int i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		sum*=1.05;
		if(sum%1000!=0){
			sum+=1000;
			sum/=1000;
			sum*=1000;
		}
	}
	
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))
using namespace std;
//#define int long long;

using namespace std;
signed main() {
  ll N;
  cin >> N;
  vector<ll> list0(N);
  rep(i, N) { cin >> list0[i]; }
  vector<ll> list1(N);
  rep(i, N) { cin >> list1[i]; }
  vector<ll> list2(N);
  rep(i, N) { cin >> list2[i]; }
  sort(all(list0));
  sort(all(list1));
  sort(all(list2));

  vector<ll> list3(N);
  vector<ll> list4(N+1);
  //中と下を先にくっつける
  rep(i, N) {
    auto it = upper_bound(all(list2),list1[i]);
    int index = it - list2.begin();
    list3[i] = N - index;
    //list3は中の各々についての候補数
  }

  rep(i, N) {
    //list4は候補数の累積和
    list4[N - i - 1] += list4[N - i]+list3[N - i - 1];
  }
  ll ans = 0;
  rep(i, N) {
    auto it = upper_bound(all(list1), list0[i]);
    int index = it - list1.begin();
    ans += list4[index];
  }
  cout << ans;
}

Measured memory_bytes: 7184
x,k,d = map(int,input().split())
if 0 < x:
    if 0 <  x - d * k:
        print(abs(x - d * k))
    elif x - d * k == 0:
        print(0)
    else:
        judge = x //d
        j1 = x - judge * d
        count = k - judge
        if count % 2 == 0:
            print(abs(j1))
        else:
            print(abs(j1-d))
elif x < 0:
    if x + d * k < 0:
        print(abs(x + d * k))
    elif x + d * k == 0:
        print(0)
    else:
        judge = -x//d
        j2 = x + judge * d
        count = k - judge
        if count % 2 == 0:
            print(abs(j2))
        else:
            print(abs(j2+d))
else:
    if k%2 == 0:
        print(0)
    else:
        print(abs(d))


Measured memory_bytes: 9132
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
words = set(s+t)
ans = 0
for word in words:
    ansi = 0
    ansi += s.count(word)
    ansi -= t.count(word)
    ans = max(ans, ansi)
print(ans)



Measured memory_bytes: 3060
l = ['qwertasdfgzxcvb','yuiophjklnm']
while True:
    s = list(input())
    if s[0]=='#': break
    c,k = 0, 0 if s[0] in l[0] else 1
    for x in s:
        if not(x in l[k]):
            c += 1
            k = abs(k-1)
    print(c)

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

using namespace std;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep1(i,n) for(int i = n-1; i >= 0; i--)

bool check(char a){
    if(a == '#'){
        return false;
    }else{
        return true;
    }
}

int main (void){

    int  H, W;
    cin >> H>> W;
    char c[H][W];
    
    rep(i, H){
        rep(j, W){
            cin >> c[i][j];
        }
    }
    
    int Up[H][W];
    int Down[H][W];
    int L[H][W];
    int R[H][W];
    int max = 0;

    rep(i, H){
        rep(j, W){
            if(i == 0 && check(c[i][j])){
                Up[i][j] = 1;
            }else if(!check(c[i][j])){
                Up[i][j] = 0;
            }else {
                Up[i][j] = Up[i-1][j] +1;
            }

            if(j == 0 && check(c[i][j])){
                L[i][j] = 1;
            }else if(!check(c[i][j])){
                L[i][j] = 0;
            }else {
                L[i][j] = L[i][j-1] +1;
            }
        }
    }


    rep1(i , H){
        rep1(j, W){
             if(i == H-1 && check(c[i][j])){
                Down[i][j] = 1;
            }else if(!check(c[i][j])){
                Down[i][j] = 0;
            }else {
                Down[i][j] = Down[i+1][j] +1;
            }

            if(j == W-1 && check(c[i][j])){
                R[i][j] = 1;
            }else if(!check(c[i][j])){
                R[i][j] = 0;
            }else {
                R[i][j] = R[i][j+1] +1;
            }
        }
    }
    int tem;
    int a, b;
    rep(i, H){
        rep(j, W){
            tem = Up[i][j] + Down[i][j] + L[i][j] + R[i][j] -3;
            if(max < tem){
                max = tem;
                a = i; b = j;
            }
        }
    }
    /*
    rep(i, H){
        rep(j, W){
            cout << L[i][j] << " " ;
        }
        cout << endl;
    }
    */

   cout << max;


}
    


Measured memory_bytes: 66688
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int num_visited=0;
vector<int> G[300000];
vector<int> C[300000];
int visit[300000] = {};
int cnt[300000]={};
int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    map<pair<int,int>,int> p;
    rep(i,n-1){
        cin >> a[i]>>b[i]>>c[i];
        c[i] %=2;
        a[i]--,b[i]--;
        p[make_pair(a[i],b[i])] = c[i];
        p[make_pair(b[i],a[i])] = c[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    //SearchC(0);
    vector<int> ans(n);
    ans[0] = 1; //黒で塗る
    queue <pair<int,int>> q;
    q.push(make_pair(0,1));
    while(!q.empty()){
        int now = q.front().first;
        int color = q.front().second;
        visit[now] = 1;
        q.pop();
        rep(i,G[now].size()){
            int child = G[now][i];
            if(visit[child]){
                continue;
            }
            if(p[make_pair(now,child)]==0){
                q.push(make_pair(child,color));
                ans[child] = color;
            }
            else{
                //color = !color;
                q.push(make_pair(child,!color));
                ans[child] = !color;
            }
            //cout<<child+1<<"を"<<color<<"で塗った"<<endl;
        }
    }
    rep(i,n){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 32512
c = []
for _ in range(3):
    l = list(map(int, input().split()))
    c += l

n = int(input())
for _ in range(n):
    m = int(input())
    if m in c:
        c[c.index(m)]=0

if c[0]==c[1]==c[2]==0 or c[3]==c[4]==c[5]==0 or c[6]==c[7]==c[8]==0 or c[0]==c[3]==c[6]==0 or c[1]==c[4]==c[7]==0 or c[5]==c[8]==c[2]==0 or c[0]==c[4]==c[8]==0 or c[2]==c[4]==c[6]==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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++)
using namespace std;
typedef pair<int, int> P;

int64_t aa[100010];
int main()
{
  int64_t s = 1, n,ans = 1;
  cin >> n;
  rep(i,n){
    cin >> aa[i];
    if(aa[i] == 0){
      s = 0;  
    }
  }
  
  if(s){
    rep(i,n){
      if(1000000000000000000 / ans < aa[i]){
        ans = -1;
        break;
      }
      ans *= aa[i];
    }
  }
  else{
    ans = 0;
  }
  
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 4416
#include <stdio.h>
int main(){
    int a,b,c,d,l,k,h,s;
    scanf("%d%d%d%d",&a,&b,&c,&d);
      k=c*b;
      h=a-b;
      l=d*h;
      s=k+l;
      if(a>b){
      printf("%d\n",s);
    } else{
        printf("%d\n",a*c);
    }
    return  0;
}


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

int main()
{
	int n,count,point,out;
	string s;
	cin >> n;
	while(n--){
		point = count = out = 0;
		while(out < 3){
			cin >> s;
			if(s=="OUT"){
				out++;
			}else if(s=="HIT"){
				count++;
				if(count>3){
					point++;
					count--;
				}
			}else{
				point += count + 1;
				count = 0;
			}
		}
		cout << point << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	int n,a[100],i,j,x,y,min,max;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	min=1000000000;
	for(i=0;i<n;i++){
		if(min>a[i]){
			min=a[i];
		}
	}
	max=-1;
	for(i=0;i<n;i++){
		if(max<a[i]){
			max=a[i];
		}
	}
	x=max-min;
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 128
from collections import deque

def main():
    S = list(input())
    ans = float('inf')
    for i in range(97,123):
        tmp = deque(S)
        cnt = 0
        s = chr(i)
        while len(tmp) > tmp.count(s):
            for j in range(len(tmp)):
                if tmp[j] == s:
                    continue
                if j + 1 < len(tmp) and tmp[j+1] == s:
                    tmp[j] = s
            tmp.pop()        
            cnt += 1
        ans = min(ans, cnt)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 74132