akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair< int ,int > pii;
typedef istringstream iss;
typedef ostringstream oss;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define ln length()
#define rep(i,n) for(int i=0;i<n;i++)
#define fu(i,a,n) for(int i=a;i<=n;i++)
#define fd(i,n,a) for(int i=n;i>=a;i--)
#define all(a)  a.begin(),a.end()
#define ESP (1e-9)

#define gi(n) scanf("%d",&n)
#define gl(n) cin >> n
#define pi(n) printf("%d",n)
#define pl(n) cout << n
#define ps printf(" ")
#define pn printf("\n")
#define dg(n,s); printf("%s %d",s,n)
#define imax numeric_limits<int>::max()
#define imin numeric_limits<int>::min()
#define lmax numeric_limits<ll>::max()
#define lmin numeric_limits<ll>::min()

template <typename T> inline T square(T x){return x*x;}
template < class T > inline T max_(T a,T b) {return a > b ? a : b ;}
template < class T > inline T min_(T a,T b) {return a < b ? a : b ;}
template < class T > inline T gcd(T a,T b) {if(a < 0) return gcd(-a,b); if(b < 0)return gcd(a,-b); return (b == 0) ? a : gcd(b ,a % b);}
template < class T > inline T lcm(T a,T b) {if(a < 0) return lcm(-a,b); if(b < 0)return lcm(a,-b); return a * (b / gcd(a , b));}

#define L1 1000000000000LL

int main(){
    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<(a-b)%c;
    return 0;
}














Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll mod = 1e9+7;


int main(){
  int n; cin >> n;
  vector<int> p(n);
  vector<int> sortp(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    sortp[i] = p[i];
  }
  sort(sortp.begin(),sortp.end());
  
  int cnt = 0;
  for(int i=0;i<n;i++){
    if(sortp[i] != p[i]){
      cnt++;
    }
  }
  if(cnt>2){ 
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;

}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: u64,
    };

    let mut p = vec![];
    let mut m = n;
    for i in 2.. {
        if i * i > m {
            break;
        }
        let mut count = 0;
        while m % i == 0 {
            count += 1;
            m /= i;
        }
        p.push((i, count));
    }
    if m != 1 {
        p.push((n, 1));
    }
    let mut count = 0;
    for i in 1.. {
        let mut used = false;
        for p_i in p.iter_mut() {
            if p_i.1 >= i {
                p_i.1 -= i;
                used = true;
                count += 1;
            }
        }
        if !used {
            break;
        }
    }

    let ans = count;
    println!("{}", ans);
}


Measured memory_bytes: 17768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	ll n; cin >> n;
	VI a(n); REP(i,n) cin >> a[i];
	VI p(n+1,0);
	REP(i,n) p[a[i]]++;
	ll sum=0;
	REP(i,n) sum+=(p[i+1]*(p[i+1]-1))/2;
	REP(i,n){
		ll ans=sum;
		ll s=p[a[i]];
		ans-=(s*(s-1))/2;
		s--;
		ans+=(s*(s-1))/2;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll X;
    cin>>X;
    ll money=100;
    ll cnt=0;
    while(money<X){     //最大でも3760
        money+=money/100;
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3624
package main

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

var groups = [3][]int{
	{1, 3, 5, 7, 8, 10, 12},
	{4, 6, 9, 11},
	{2},
}
var x, y int

func main() {
	x = getInt()
	y = getInt()

	ans := isMatched()
	fmt.Println(ans)
}

func isMatched() string {
	for _, g := range groups {
		flagx := false
		flagy := false
		for _, v := range g {
			if v == x {
				flagx = true
			}
			if v == y {
				flagy = true
			}
		}
		if flagx && flagy {
			return "Yes"
		}
	}
	return "No"
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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


int main(){
    int N;
    cin >> N;
    int H[N];
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }

    int counter = 0;
    for(int i = 0; i < N; ++i){
        bool canSee = true;
        for(int j = 0; j < i+1; j++){
            if(H[j] > H[i]){
                canSee = false;
            }
        }
        if (canSee){
            counter++;
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
int ans = 0;

int main() {
	while (cin >> N) {
		vector<int> x(N), y(N);
		for (int i = 0; i < N; i++) {
			cin >> x[i] >> y[i];
		}
		map<pair<int, int>, int> mp;

		for (int i = 0; i < N; i++) {
			for (int j = i+1; j < N; j++) {
				int p = x[j] - x[i];
				int q = y[j] - y[i];
				if (p < 0) {
					p *= -1;
					q *= -1;
				}
				else if (p == 0 && q < 0) {
					q *= -1;
				}
				pair<int, int>pq = { p,q };
				mp[pq]++;
			}
		}
		for (auto i = mp.begin(); i != mp.end(); i++) {
			ans = max(ans, i->second);
		}
		cout << N - ans << endl;
	}
}


Measured memory_bytes: 256
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

  ll a[200001];
  ll sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  ll ans = 0;
  ll min_num = 2000000001;
  REP(i, n - 1) {
    ans += a[i];
    ll other = sum - ans;
    ll kotae = abs(other - ans);

    if (kotae <= min_num) min_num = kotae;
  }

  cout << min_num << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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 MOD = 1000000000+7;

int main(){
    int a[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> b(n, 0);
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(b[i] == a[j][k]){
                    a[j][k] = 0;
                    continue;
                }
            }
        }
    }

    if(a[0][0] == a[0][1] && a[0][1] == a[0][2]){
        cout << "Yes" << endl;
        return 0;
    }

    if(a[0][0] == a[1][0] && a[1][0] == a[2][0]){
        cout << "Yes" << endl;
        return 0;
    }

    if(a[1][0] == a[1][1] && a[1][1] == a[1][2]){
        cout << "Yes" << endl;
        return 0;
    }

    if(a[2][0] == a[2][1] && a[2][1] == a[2][2]){
        cout << "Yes" << endl;
        return 0;
    }

    if(a[0][1] == a[1][1] && a[1][1] == a[2][1]){
        cout << "Yes" << endl;
        return 0;
    }

    if(a[0][2] == a[1][2] && a[1][2] == a[2][2]){
        cout << "Yes" << endl;
        return 0;
    }

    if(a[0][0] == a[1][1] && a[1][1] == a[2][2]){
        cout << "Yes" << endl;
        return 0;
    }

    if(a[0][2] == a[1][1] && a[1][1] == a[2][0]){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


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

int fc(int x){
    int ans;
    if (x % 2 == 0){
        ans = x / 2;
    }
    else {
        ans = x * 3 + 1;
    }
    return ans;
}

int main(void){
    int s;
    cin >> s;
    vector<int> log(1000005, 0);
    bool flag;
    int i = 1, m;
    log.at(0) = s;
    while (flag==false){
        log.at(i) = fc(log.at(i - 1));
        for (int j = 0; j < i; j++)
        {
            if(log.at(i)==log.at(j)){
                m = i + 1;
                cout << m << endl;
                return 0;
            }
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	bool ok = false;
	unsigned long long ans = 1,test = 1e18;
	long long res;	
	while(n--)
	{
		unsigned long long x;
		cin>>x;
		if(x==0)
			ok = true, res = 0;
		if(!ok)
		{
			if(log10(ans)+log10(x)<=18.0)
			{
				ans *= x;
				if(ans>test)
					ok = true, res = -1;
				else res = ans;
			}
			else ok = true, res = -1;
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3896
n = int(input())
s = [ int(i) for i in input().split() ]
t = sorted(s)
med = (t[n//2-1] + t[n//2])/2
# print(t)
for i in s:
    if i < med:
        print(t[n//2])
    else:
        print(t[n//2-1])


Measured memory_bytes: 25220
#include <bits/stdc++.h>
using namespace std;
int n,k,s,ans[100004];
int main(){
	int go=1e9;
	cin>>n>>k>>s;
	if(s<1e9){
		for (int i=1;i<=k;i++) cout<<s<<" ";
		for (int i=k+1;i<=n;i++) cout<<go<<" ";
	}else{
		for (int i=1;i<=k;i++) cout<<s<<" ";
		for (int i=k+1;i<=n;i++) cout<<1<<" ";
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;


ll dp[3005][3005][4];

int main() {
  int r, c, k;
  cin >> r >> c >> k;

  vector<vector<ll>> v(r, vector<ll>(c, 0));

  rep(i, k) {
    int r, c, vv;
    cin >> r >> c >> vv;
    r--; c--;
    v[r][c] = vv;
  }

  rep(i, r) {
    rep(j, c) {
      for (int k = 2; k >= 0; k--) {  // 今いるマスで拾う
        chmax(dp[i][j][k+1], dp[i][j][k] + v[i][j]);
      }
      rep(k, 4) {
        if (i + 1 < r) chmax(dp[i+1][j][0], dp[i][j][k]);
        if (j + 1 < c) chmax(dp[i][j+1][k], dp[i][j][k]);
      }
    }
  }

  ll ans = 0;
  rep(k, 4) chmax(ans, dp[r-1][c-1][k]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 355404
// finish date: 2018/07/19
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    N++;
    vi t(N);
    vi v(N);
    FOR(i, 1, N) {
        cin >> t[i];
        if (i != 0) t[i] += t[i - 1];
    }
    int sizeT = t[N - 1];
    FOR(i, 1, N) cin >> v[i];
    vd T(sizeT * 2 + 1, INF);
    //順方向
    rep(i, N - 1) {
        rep(j, t[i] * 2) {
            T[j] = min(T[j], v[i + 1] + (t[i] * 2 - j) * 0.5);
        }

        FOR(j, t[i] * 2, t[i + 1] * 2) {
            T[j] = min(T[j], (double) v[i + 1]);
        }

        FOR(j, t[i + 1] * 2, T.size()) {
            T[j] = min(T[j], v[i + 1] + (j - t[i + 1] * 2) * 0.5);
        }
    }

    rep(i, T.size()) {
        T[i] = min(T[i], i * 0.5);
        T[i] = min(T[i], sizeT - 0.5 * i);
    }

    double ans = 0;
    FOR(i, 1, T.size()) {
        ans += (T[i] + T[i - 1]) * 0.25;
//        ans += T[i] * 0.5;
//        if (T[i] > T[i - 1]) {
//            ans -= 0.125;
//        } else if (T[i] < T[i - 1]) {
//            ans += 0.125;
//        }
    }
    printf("%.4f\n", ans);


    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<math.h>

using namespace std;
int main(){
   int n;
   std::cin>>n;
   int x[n],y[n];
   int i;
   int mul=1;
   for(i=0;i<n;i++){
       std::cin>>x[i]>>y[i];
   }
   
   
   int j;
   float sum=0;
   for(i=0;i<n-1;i++){
       for(j=i+1;j<n;j++){
           float dis=sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]));
           sum+=2*dis;
       }
   }
   
   sum=sum/n;
   std::cout << std::fixed;
    std::cout << std::setprecision(6);
   std::cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int i,n,c=0,d=0,p;
    char a[100];
    cin>>a;
    n=strlen(a);

    for(i=0 ; i<n ; i++)
    {
    if(i%2==0)
    {
        if(a[i]=='R' || a[i]=='U' || a[i]=='D')
            c=c+1;


    }
    else
    {
        if(a[i]=='L' || a[i]=='U' ||a[i]=='D')
            d=d+1;
    }
    }
    p=c+d;
    if(p==n)
            cout<<"Yes";
    else
            cout<<"No";



}

Measured memory_bytes: 256
use strict;
use warnings;
use utf8;

use feature qw(say);
use Data::Dumper;

my $n = <STDIN>;
my $input = <STDIN>;
chomp $input;

my $array = [split / /, $input];
$array = [sort { $a <=> $b } @$array];

my $count = 0;

for (my $i = 0; $i < $n; $i++) {
    my $num = $array->[$i];
    for (my $second_index = $i+1; $second_index < $n; $second_index++) {
        my $second_num = $array->[$second_index];
        for (my $third_index = $second_index+1; $third_index < $n; $third_index++) {
            my $third_num = $array->[$third_index];

            if ($num + $second_num > $third_num && $num != $second_num && $second_num != $third_num) {
                $count++;
            }
        }
    }
}

say $count;

Measured memory_bytes: 6424
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int kk = sc.nextInt();
		int[][] dp = new int[h + 1][w];
		dp[0][0] = 1;
		for (int i = 1; i <= h; i++) {
		    for (int j = 0; j < (1 << (w - 1)); j++) {
		        boolean flag = true;
		        for (int k = 0; k < w - 2; k++) {
		            if ((j & (1 << k)) != 0 && (j & (1 << (k + 1))) != 0) {
		                flag = false;
		                break;
		            } 
		        }
		        if (!flag) {
		            continue;
		        }
		        for (int k = 0; k <= w - 1; k++) {
		            if (k == 0) {
		                if ((j & (1 << k)) != 0) {
		                    dp[i][k] += dp[i - 1][k + 1];
		                } else {
		                    dp[i][k] += dp[i - 1][k];
		                }
		            } else if (k == w - 1) {
		                if ((j & (1 << (k - 1))) != 0) {
		                    dp[i][k] += dp[i - 1][k - 1];
		                } else {
		                    dp[i][k] += dp[i - 1][k];
		                }
		            } else {
		                if ((j & (1 << k)) != 0) {
		                    dp[i][k] += dp[i - 1][k + 1];
		                } else if ((j & (1 << (k - 1))) != 0) {
		                    dp[i][k] += dp[i - 1][k - 1];
		                } else {
		                    dp[i][k] += dp[i - 1][k];
		                }
		            }
		            dp[i][k] %= MOD;
		        }
		    }
		}
		System.out.println(dp[h][kk - 1]);
    }
}



Measured memory_bytes: 22740
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
long long mod = 1e9 + 7;
const int N = 3e5 + 500;

long long n, m, u, v, k, t, q, a, h;

string str;

int P[N];

int find(int x) {
   if (x == P[x]) return x;
   else return P[x] = find(P[x]);
}

void unite(int x, int y) {
   x = find(x);
   y = find(y);
   if (x == y) return;
   else P[x] = y;
}


int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   
   cin >> n >> m;
   
   for (int i = 1; i <= n; ++i) P[i] = i;
   
   for (int i = 1; i <= m; ++i) {
      cin >> u >> v >> k;
      unite(u, v);
   }
   
   int sol = 0;
   
   for (int i = 1; i <= n; ++i) if (i == find(i)) sol++;
   
   cout << sol << endl;
   
}






Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)

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

    string s,t;
    cin >> s >> t;
    int ans=s.length(),c;
    F0R(i, s.length()-t.length()+1) {
      c=0;
      F0R(j,t.length()) {
        if(s[i+j]!=t[j]) c++;
      }
      ans = min(ans,c);
    }
    cout << ans;

    return 0;
  }

Measured memory_bytes: 3624
c = [list(map(int, input().split())) for i in range(3)]

for i in range(c[0][0]+1):

    a = [0]*3
    b = [0]*3
    a[0] = i
    b[0] = c[0][0] - i

    for j in range(1,3):
        a[j] = c[j][0] - b[0]
        b[j] = c[0][j] - a[0]
    flag = True
    for k in range(3):
        for l in range(3):
            if c[k][l] != a[k] + b[l]:
                flag = False
    if flag:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    ll n;
    cin>>n;
    ll arr[n],i;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    if(is_sorted(arr,arr+n))
    {
        cout<<"YES"<<endl;
    }
    else
    {
        vector<ll>v;
        for(i=0;i<n;i++)
        {
            v.pb(arr[i]);
        }
        sort(arr,arr+n);
        ll ct=0;
        for(i=0;i<n;i++)
        {
            if(arr[i]!=v[i])
            {
                ct++;
            }
        }

        if(ct==2)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
}


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

int main(){
    uint64 x; cin >> x;
    vector<int> ans(32,0);
    vector<int> v(32,0);
    int i = 0;
    while( x > 0 ){
        ans[i] = x % 2;
        x/= 2;
        ++i;
    }
    reverse(ans.begin(),ans.end());
    copy(ans.begin(),ans.end(),v.begin());
    rep(i , 32){
        cout << ans[i];
    }
    cout << endl;
    rep(i , 32){
        cout << (ans[i] == 1 ? 0 : 1);
    }
    cout << endl;
    for(int i=1 ; i < 32 ; ++i){
        ans[i-1] = ans[i];
    }
    ans[31] = 0;
    rep(i , 32){
        cout << ans[i];
    }
    cout << endl;
    for(int i=31 ; i > 0 ; --i){
        v[i] = v[i-1];
    }
    v[0] = 0;
    rep(i , 32){
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

#define EPS 1e-10

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

typedef double Type;

int sign(Type x)
{
    return x<-EPS?-1:(x>EPS?1:0);
}

struct Point
{
    Type x,y;
    Point(Type x,Type y):x(x),y(y) {}
    Point() {}
    void read()
    {
        scanf("%lf %lf",&x,&y);
    }
    bool operator==(const Point& p) const
    {
        return sign(x-p.x)==0&&sign(y-p.y)==0;
    }
    Point operator-(const Point& p) const
    {
        return Point(x-p.x,y-p.y);
    }
    Point operator*(const Type t) const
    {
        return Point(t*x,t*y);
    }
    Point operator+(const Point & p) const
    {
        return Point(x+p.x,y+p.y);
    }
    bool operator<(const Point& p) const
    {
        return sign(x-p.x)==0?sign(y-p.y)<0:sign(x-p.x)<0;
    }
};

ostream& operator<<(ostream& out,Point p)
{
    out<<p.x<<" "<<p.y;
    return out;
}

typedef Point Vector;

struct Line
{
    Point a,b;
    Line() {}
    Line(Point a,Point b):a(a),b(b) {}
};

typedef Line SegMent;

//叉?
Type Cross(Vector a,Vector b)
{
    return a.x*b.y-a.y*b.x;
}

//点?
Type Dot(Vector a,Vector b)
{
    return a.x*b.x+a.y*b.y;
}

//?度
Type Length(Vector v)
{
    return sqrt(v.x*v.x+v.y*v.y);
}

int ccw(Point p0,Point p1,Point p2)
{
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(Cross(a,b)>EPS)
        return COUNTER_CLOCKWISE;
    if(Cross(b,a)>EPS)
        return CLOCKWISE;
    if(Dot(a,b)<-EPS)
        return ONLINE_BACK;
    if(Length(a)<Length(b))
        return ONLINE_FRONT;
    if(Length(a)>Length(b))
        return ON_SEGMENT;
}

int main()
{
    Point p0,p1,p2;
    p0.read();
    p1.read();
    int q;
    scanf("%d",&q);
    while(q--)
    {
        p2.read();
        int flag=ccw(p0,p1,p2);
        if(flag==COUNTER_CLOCKWISE)
            puts("COUNTER_CLOCKWISE");
        if(flag==CLOCKWISE)
            puts("CLOCKWISE");
        if(flag==ONLINE_BACK)
            puts("ONLINE_BACK");
        if(flag==ONLINE_FRONT)
            puts("ONLINE_FRONT");
        if(flag==ON_SEGMENT)
            puts("ON_SEGMENT");
    }
    return 0;
}

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

struct st {
	int score, pen, id, wrong[10];
};
int main() {
	int t, p, r;
	while (scanf("%d%d%d", &t, &p, &r), t) {
		st team[50]{};
		rep(i, t)team[i].id = i + 1;
		rep(i, r) {
			int tid, pid, time; string mes;
			scanf("%d%d%d", &tid, &pid, &time);
			tid--; pid--;
			cin >> mes;
			if (mes == "WRONG")team[tid].wrong[pid]++;
			else {
				team[tid].pen += team[tid].wrong[pid] * 1200 + time;
				team[tid].score++;
			}
		}
		sort(team, team + t, [](st a, st b) {
			if (a.score != b.score)return a.score > b.score;
			if (a.pen != b.pen)return a.pen < b.pen;
			return a.id < b.id;
		});
		rep(i, t) {
			printf("%d %d %d\n", team[i].id, team[i].score, team[i].pen);
		}
	}
}

Measured memory_bytes: 3304
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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(b<a) { a=b; return 1; } return 0; }

int main(){
  int n,m; cin >> n >> m;
  vi cnt(n,1);
  set<int> st = {0};
  rep(i,m){
    int x,y; cin >> x >> y;
    x--; y--;
    if(st.count(x)) st.insert(y);
    cnt[x]--; cnt[y]++;
    if(cnt[x] == 0) st.erase(x);
  }
  cout << st.size();
  cout << "\n";
  return 0;
}


Measured memory_bytes: 8116
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int S1 = Integer.parseInt(S.substring(5,7));

	if (S1 < 5) {
	  System.out.println("Heisei");
	} else {
	  System.out.println("TBD");
	}

  }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


bool f(string s){
    if(s[0]!='A') return false;
    int c=0;
    for(int i=1;i<s.length();i++){
        if(s[i]=='C'){
            c++;
            if(c==2) return false;
            if(i<2||i==s.length()-1) return false;
        }
        else{
            for(int j=0;j<26;j++){
                if(s[i]=='A'+j) return false;
            }
        }
    }
    if(c==0) return false;
    return true;
}

int main(){
    string s;
    cin >> s;
    if(f(s)) puts("AC");
    else puts("WA");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void merge(int s[], int low, int middle, int high)
{
 int i;
 int lowarray[100005];
 int higharray[100005];
 int lowcount;
 int highcount;
 int start;

 for(i=low; i<=middle; i++)
 { 
   lowarray[i-low]=s[i];
 }
 for(i=middle+1; i<=high; i++)
 { 
  higharray[i-middle-1]=s[i];
 }

 lowcount=0;
 highcount=0;
 for(i=low; i<=high; i++)
 {
  if(lowarray[lowcount]<=higharray[highcount])
  {
   s[i]=lowarray[lowcount];
   lowcount++;
  }else{
   s[i]=higharray[highcount];
   highcount++;
  }
  start=i;
  if((lowcount==(middle-low+2))|(highcount==(high-middle+1))) break;
 }

 if(lowcount==(middle-low+2))
 {
  for(i=start;i<=high;i++)
  {
     s[i]=higharray[highcount];
     highcount++;
  }
 }

 if(highcount==(high-middle+1))
 {
   for(i=start;i<=high;i++)
   {
      s[i]=lowarray[lowcount];
      lowcount++;
   }
 }
 
}

void mergesort( int s[], int low, int high)
{
 int i;
 int middle;

 if (low<high) 
 {
   middle = (low+high)/2;
   mergesort(s,low,middle);
   mergesort(s,middle+1,high);
   merge(s,low,middle,high);
 }
}


int main()
{
 int N;
 int a[100005];
 int count[100005];
 int occur[100005];
 int i;
 int oc=0;
 int maxtotal=0;
 int mytotal;

 scanf("%d",&N);
 for(i=0; i<N; i++) scanf("%d",&a[i]);
 mergesort(a,0,N-1);

 for(i=0;i<N;i++)  occur[i]=-1;
 for(i=0;i<N;i++) count[i]=0;
 occur[oc]=a[0];
 for(i=0;i<N;i++) 
 {
  if(a[i]==occur[oc])
  {
   count[oc]++;
  }else{
    oc++;
    count[oc]=1;
    occur[oc]=a[i];
  }
 }

 for(i=0;i<=oc;i++)
 {
   mytotal=count[i];
   if(i<oc)
   {
     if((occur[i+1]-occur[i])==1) mytotal+=count[i+1];
   }
   if(i>0)
   { 
     if((occur[i]-occur[i-1])==1) mytotal+=count[i-1];
   }
   if(mytotal>maxtotal) maxtotal=mytotal;
 }
 printf("%d\n",maxtotal); 
 return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007�
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(5)<<fixed;
	ll n;
	cin>>n;
double a[n],sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=1.0/a[i];
	}
	sum=1.0/sum;
	cout<<sum<<endl; 	
	return 0;
}


Measured memory_bytes: 256
fun main(arr: Array<String>) {
    val s = readLine()!!
    println(getVariation(s, 0).map { it.split("+").map { it.toLong() }.sum() }.sum())
}

fun getVariation(s:String, idx:Int):List<String> {
    if (idx == s.lastIndex) {
        return listOf(s[idx].toString())
    }
    val ans = mutableListOf<String>()
    val ret = getVariation(s, idx + 1)
    ans.addAll(ret.map { s[idx].toString() + it })
    ans.addAll(ret.map { s[idx].toString() + "+$it" })
    return ans
}


Measured memory_bytes: 37008
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String m[] = s.split("");
    int ans = 0;
    for (int i = 0; i < s.length(); i++){
      if (m[i].equals("+")){
        ans++;
      }else{
        ans--;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35484
#include <stdio.h>
#include <string.h>
#define M 1046527
#define L 14
#define NIL (-1)
char H[M][L];
int getChar(char alg)
{
	if(alg=='A')return 1;
	else if(alg=='C')return 2;
	else if(alg=='G')return 3;
	else if(alg=='T')return 4;
}
long long getKey(char moji[])
{
	long long sum=0,p=1,i;
	for(i=0;i<strlen(moji);i++)
  {
		sum+=p*(getChar(moji[i]));
		p*=5;
	}
	return sum;
}
int h1(int key)
{
  return key%M;
}
int h2(int key)
{
  return 1+(key%(M-1));
}
int find(char str[])
{
	long long key, i = 0, h;
	key=getKey(str);
	while (1) {
		h=(h1(key)+i*h2(key))%M;
		i++;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0)return 0;
	}
	return 0;
}
int insert(char str[])
{
	long long key,i=0,h;
	key=getKey(str);
	while(1)
  {
		h=(h1(key)+i*h2(key))%M;
		i++;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0)
    {
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main()
{
	int i,n,h;
	char str[L],com[9];
	for(i=0;i<M;i++)H[i][0]='\0';
	scanf("%d", &n);
	for(i=0;i<n;i++)
  {
		scanf("%s %s",com,str);

		if(com[0]=='i')
    {
			insert(str);
		}
		else{
			if(find(str))
      {
				printf("yes\n");
			}
			else
      {
				printf("no\n");
			}
		}
	}
	return 0;
}



Measured memory_bytes: 16104
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto ip = readln.split.to!(int[]), N=ip[0], K=ip[1];
	auto S = readln.chomp.to!(dchar[]);

	S[K-1] += 0x20;

	writeln(S);
}

Measured memory_bytes: 256
#include <iostream>

#define long long long

using namespace std;

int n, last[20];

int main()
{
    cin >> n;
    int mx = 0; long ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        int x; cin >> x;
        for (int j = 0; j < 20; ++j)
            if ((x >> j) & 1)
            {
                mx = max(mx, last[j]);
                last[j] = i;
            }
        ans += i - mx;
    }
    cout << ans;
    return 0;
}


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

lnt a[10];
lnt n,m;
lnt arr[10][10];
lnt p[10];
lnt ans = 0;
lnt k[10];
lnt perm(lnt c)
{   //cout<<c<<endl;
    if(c==n)
    {
        //cout<<endl;
        lnt tem=0;
        for(int i=0;i<m;i++)
        {   lnt p1=p[i]%2;
            lnt cnt = 0;
            for(int j=0;j<k[i];j++)
            {
                if(a[arr[i][j]]==1)
                {
                    cnt++;
                }

            }
            if(cnt%2==p1)
            {
                tem++;
            }
            else
            {
                break;
            }

        }
        if(tem==m)
        {
            ans++;
        }
        return 0;

    }
    a[c]=1;
    perm(++c);
    a[c-1]=0;
    perm(c);
}

int main()
{

    cin>>n>>m;
    for(int i=0;i<m;i++)
    {

        cin>>k[i];
        for(int j=0;j<k[i];j++)
        {
            cin>>arr[i][j];
            arr[i][j]--;
        }
    }
    for(int i=0;i<m;i++)
    {

        cin>>p[i];
    }
    perm(0);
    cout<<ans;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	int a[105];
	int ans,m,M;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	m=100000;
	M=-1;
	for(int i=0;i<n;i++){
		m=min(m,a[i]);
		M=max(M,a[i]);
	}
	cout<<M-m<<endl;
}

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

using namespace std;

typedef long long ll;

const int maxN = 2e5 + 1;

ll pw[maxN];

int ciclos(int x){
	if(x == 0) return 0;
	int bits = __builtin_popcount(x);
	return 1 + ciclos(x % bits);
}

int main(){
	int n;
	string s;
	cin >> n >> s;
	reverse(s.begin(), s.end());
	int unos = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1') unos++;
	}
	ll mod = unos + 1;
	if(unos - 1 > 0) mod *= (unos - 1);
	pw[0] = 1;
	for(int i = 1; i < n; i++) pw[i] = (pw[i - 1] * 2) % mod;
	ll tot = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1'){
			tot = (tot + pw[i]) % mod;
		}
	}

	for(int i = n - 1; i >= 0; i--){
		if(s[i] == '1'){
			if(unos == 1){
				cout << 0 << '\n';
			}else{
				int queda = (tot - pw[i] + mod) % (unos - 1);
				cout << 1 + ciclos(queda) << '\n';
			}
		}else{
			int queda = (tot + pw[i] + mod) % (unos + 1);
			cout << 1 + ciclos(queda) << '\n';
		}
	}
}


Measured memory_bytes: 5280
l = [int(input()) for i in range(5)]
mod = [l[i] % 10 for i in range(5)]
time = 0
if max(mod) == 0:
    print(sum(l))
else:
    min = 0
    for i in range(5):
        if mod[i] != 0:
            time += l[i] + (10 - mod[i])
            if min < 10 - mod[i]:
                min = 10 - mod[i]
        else:
            time += l[i]
    print(time - min)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

double ze(double a) {
	if (a < 0) return -a;
	else return a;
}

int main() {
	double n, t, a, h[100000];
	int tmp = 0;
	
	cin >> n >> t >> a;
	for (size_t i = 0; i < n; i++) {
		cin >> h[i];
		h[i] = t - h[i] * 0.006;
		if (ze(a-h[i]) < ze(a - h[tmp])) tmp = i;
	}

	cout << tmp+1;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n,m;
priority_queue<long long> q;
long long a;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a;
		q.push(a);
	}
	for(int i=1;i<=m;i++){
		int frt=q.top();
		q.pop();
		q.push(frt/2LL);
	}
	long long res=0;
	while(!q.empty()){
		res+=q.top();
		q.pop();
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <ostream>
using namespace std;
typedef long long ll;
int main()
{
#ifdef LOCAL
    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL

    int sx,sy,tx,ty;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    int h,w;
    h=ty-sy,w=tx-sx;
    for(int i=0;i<h;i++)
        putchar('U');
    for(int i=0;i<w;i++)
        putchar('R');
    for(int i=0;i<h;i++)
        putchar('D');
    for(int i=0;i<w+1;i++)
        putchar('L');
    for(int i=0;i<h+1;i++)
        putchar('U');
    for(int i=0;i<w+1;i++)
        putchar('R');
    putchar('D');
    putchar('R');
    for(int i=0;i<h+1;i++)
        putchar('D');
    for(int i=0;i<w+1;i++)
        putchar('L');
    putchar('U');
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MOD 1000000007
#define MAX 55
#define PMAX 55
#define PRECISION 0.00000000001
#define INF 2000000000
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    int a,b,c,k;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    int cnt=0;
    while(b<=a)
    {
        b=b*2;
        cnt++;
    }
    while(c<=b)
    {
        c=c*2;
        cnt++;
    }
    if(cnt<=k)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


#define int ll


int n,k,x;

signed main(){
    cin>>n>>k;
    int cnt=0;
    repe(i,1,n){
        if(i<=k)continue;
        cnt+=(n/i)*(i-k);
        int y=(n/i)*(i-k);
        x=n%i-k+1;
        if(x>0){
            if(x+y<=n)cnt+=x;
            else cnt+=n-y;
        }
        
    }
    cout<<cnt<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size(), ans = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] != t[i]) ++ans;
    }
    cout << ans << endl;
}

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

int main(void) {
    int64_t N,A;
    cin >> N;
    A = sqrt(N);
    for(int64_t i=A;i>=1;i--){ 
        if((N % i) == 0) {
            cout << i + (N/i) - 2 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.V = list(range(N))
        self.E = [[] for _ in range(N)]

    def add_edge(self, edge):
        """辺を加える。edgeは(始点, 終点、重み)からなるリスト
        重みがなければ、重み1とする。
        """
        if len(edge) == 2:
            edge.append(1)
        elif len(edge) != 3:
            print("error in add_edge")
            pass

        s, t, w = edge
        self.E[s].append([t, w])
        self.E[t].append([s, w])  # 無向グラフを仮定。逆向きにも辺を張る

        pass

    def remove_edge(self, edge):
        if len(edge) == 2:
            edge.append(1)
        elif len(edge) != 3:
            print("error in add_edge")
            pass

        s, t, w = edge
        for tt, ww in self.E[s]:
            if tt == t:
                break
        if tt == t:
            self.E[s].remove([t, ww])
            self.E[t].remove([s, ww])
        pass


def Warshall_Floyd(g: Graph):
    """ワーシャルフロイド法により、全節点対の最短距離を求める。O(V^3)
    https://ja.wikipedia.org/wiki/%E3%83%AF%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E2%80%93%E3%83%95%E3%83%AD%E3%82%A4%E3%83%89%E6%B3%95
    """
    N = g.N
    dist = [[INF]*N for _ in range(N)]
    for from_, toweights in enumerate(g.E):
        for to_, w in toweights:
            dist[from_][to_] = w

    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    return dist


def solve(N: int, A: "List[List[int]]"):

    g = Graph(N)
    for i in range(N):
        for j in range(i+1, N):
            g.add_edge([i, j, A[i][j]])

    B = Warshall_Floyd(g)

    counter = 0
    for i in range(N):
        for j in range(i+1, N):
            if B[i][j] < A[i][j]:
                print(-1)
                return

            flag = True
            for k in range(N):
                if B[i][j] == B[i][k]+B[k][j]:
                    flag = False
            if flag == True:
                counter += B[i][j]
    print(counter)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(N)]
         for _ in range(N)]  # type: "List[List[int]]"

    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 109404
N = gets.to_i
S = Array.new N 
res = {}
N.times do |i|
    r = gets.chomp
    res[r] ||= 0
    res[r] += 1
end
["AC", "WA", "TLE", "RE"].each do |r|
    puts "#{r} x #{res[r] || 0}"
end

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n;	
	cin >> n;	
	
	multiset<int> s;
	rep(i,n){
		int x;
		cin >> x;
		auto itr = s.lower_bound(x);
		if(itr == s.begin()){
			s.insert(x);
			continue;
		}
		itr--;
		s.erase(itr);
		s.insert(x);
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 8136
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <numeric>

using namespace std;

int u[111];

typedef long long ll;
const int maxn = (int) 1e5 + 1;
const int inf = (int)1e9+7;


double a[111], b[111];

int cnt[maxn];

string s, t;

int ans = 0, sum1, sum2, sum3;

int n, k;

int dp[maxn];

vector < int > v;

bool isprime(int x){
    if(x < 100){
        return 0;
    }
    for(int i = 2; i <= sqrt(x); i++){
        if(x % i == 0)
            return 0;
    }
    return 1;
}

int now = 0;

int GCD(int u, int v) {
    while ( v != 0) {
        int r = u % v;
        u = v;
        v = r;
    }
    return u;
}
int main(){
    cin >> n;
    k = n / 2 + (n % 2);

    cout << fixed << setprecision(10) << double(double(k) / double(n));
}

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

int main () {
    int x;
    cin >> x;
    int ans =  (x / 500) * 1000 + ((x % 500)  / 5 ) * 5;
    printf("%d\n",ans);
}

Measured memory_bytes: 256
<?php
  function to_i($e) {
    return (int)$e;
  }

  function calc_gcd($a, $b) { 
    if($b > 0) {
      return calc_gcd($b, $a % $b);
    }
    else {
      return $a;
    }
  }
  
  function calc_lcm($a, $b) {
    return (($a / calc_gcd($a, $b)) * $b);
  }

  while($f = fgets(STDIN)) {
    $arr = explode(" ", $f);
    $arr = array_map("to_i", $arr);
    $gcd = calc_gcd($arr[0], $arr[1]);
    $lcm = calc_lcm($arr[0], $arr[1]);
    echo $gcd." ".$lcm."\n";
  }

Measured memory_bytes: 15160
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n, x, t;
    scanf("%d%d%d", &n, &x, &t);
    printf("%d\n", (n - 1 + x) / x * t);


    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


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

int j,y;

void search(int J,int Y,char *d){
	if(J==j&&Y==y){ printf("%s\n",d); return; }
	char n[2][20];
	int i;
	for(i=0;d[i]!=0;i++) n[0][i]=n[1][i]=d[i];
	if(J!=j&&((!(J==4&&y!=Y))||(J==4&&Y==4))){ n[0][i]='A'; n[0][i+1]=0; search(J+1,Y,n[0]);}
	if(Y!=y&&((!(Y==4&&J!=j))||(J==4&&Y==4))){ n[1][i]='B'; n[1][i+1]=0; search(J,Y+1,n[1]);}
}

int main(){
	scanf("%d%d",&j,&y);
	char d[20];
	d[0]=0;
	search(0,0,d);
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;

typedef pair<int,int> P;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int x;

int main()
{
	cin >> n >> x;
	if(n == 2)
	{
		if(x == 1 || x == 3)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
			cout << 1 << endl;
			cout << 2 << endl;
			cout << 3 << endl;
		}
		return 0;
	}
	int MAX = 2 * n - 1;
	if(1 <= x - 1 && x + 2 <= MAX)
	{
		cout << "Yes" << endl;
		queue<int> able;

		rep(i,1,MAX)
		{
			if(x - 1 <= i && i <= x + 2)
				continue;
			able.push(i);
		}
		rep(i,1,n - 3)
		{
			cout << able.front() << endl;
			able.pop();
		}
		cout << x + 2 << endl;
		cout << x - 1 << endl;
		cout << x << endl;
		cout << x + 1 << endl;
		rep(i,n + 2,MAX)
		{
			cout << able.front() << endl;
			able.pop();
		}
	}
	else if(1 <= x - 2 && x + 1 <= MAX)
	{
		cout << "Yes" << endl;
		queue<int> able;

		rep(i,1,MAX)
		{
			if(x - 2 <= i && i <= x + 1)
				continue;
			able.push(i);
		}
		rep(i,1,n - 3)
		{
			cout << able.front() << endl;
			able.pop();
		}
		cout << x - 1 << endl;
		cout << x + 1  << endl;
		cout << x << endl;
		cout << x - 2 << endl;
		rep(i,n + 2,MAX)
		{
			cout << able.front() << endl;
			able.pop();
		}
	}
	else 
	{
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 2304