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

int main()
{
	int N, K;
	int64_t sum = 0;
	cin >> N >> K;

	for ( int i = K + 1; i <= N; i++ ) {
		int a = K, b = i - 1;

		while ( a <= N ) {
			sum += min(b, N) - max(a, 1) + 1;
			a += i, b += i;
		}

	}

	cout << sum << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

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;
}

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int N;
    string S;
    cin >> N >> S;

    int cnt = 1;
    char current = S[0];
    for (int i = 1; i < N; i++) {
        if (S[i] != current) {
            cnt++;
        }
        current = S[i];
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;

namespace atcoder
{
    class Class1
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = 3 * A + B;
            int D = C / 2;
            if (0 <= A && A <= 100 && 0 <= B && B <= 100)
            {
                Console.WriteLine(D);
            }
            }
        }
    }

Measured memory_bytes: 13140
def f(N, A):
    B = [0]*(N+1)
    b = 0
    for i in range(N, -1, -1):
        b += A[i]
        B[i] = b


    x = 1
    s = 0

    for i in range(N+1):
        x = min(x, B[i])
        s += x
        
        x = (x - A[i])*2
        if x < 0:
            return -1
        
    if x != 0:
        return -1

    return s


N = int(input())
A = list(map(int, input().split()))
print(f(N, A))


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

using namespace std;

int main(){
 int n;
  cin>>n;
  int b[n-1];
  for(int i=0;i<n-1;++i){
  	cin>>b[i];
  }
  long long ans=b[0];
  for(int i=1;i<=n-2;i++){
  	ans+=min(b[i],b[i-1]);
  }
  cout<<ans+b[n-2]<<endl;
 return 0;
}


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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  int a, b;
  cin >> a >> b;

  ll ans = lcm(a, b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();

    // input
    let h: usize = read(&mut stdin_lock, &mut buf, b' ');
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0usize; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut sum_a = 0;
    for a in av {
        sum_a += a;
    }

    let ans = if h <= sum_a { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>
#include <cmath>

# define PI 3.14159265358979323846

using namespace std;

int main(void) {
    int card[9];

    for (int i = 0; i < 9; i++) {
        int e;
        cin >> e;
        card[i] = e;
    }

    int n;
    cin >> n;

    while (n--) {
        int b;
        cin >> b;

        for (int i = 0; i < 9; i++) {
            if (card[i] == b)
                card[i] = 0;
        }
    }

    int bingo = 0;
    if (card[0] == 0 && card[1] == 0 && card[2] == 0)
        bingo = 1;
    if (card[3] == 0 && card[4] == 0 && card[5] == 0)
        bingo = 1;
    if (card[6] == 0 && card[7] == 0 && card[8] == 0)
        bingo = 1;
    if (card[0] == 0 && card[3] == 0 && card[6] == 0)
        bingo = 1;
    if (card[1] == 0 && card[4] == 0 && card[7] == 0)
        bingo = 1;
    if (card[2] == 0 && card[5] == 0 && card[8] == 0)
        bingo = 1;
    if (card[0] == 0 && card[4] == 0 && card[8] == 0)
        bingo = 1;
    if (card[2] == 0 && card[4] == 0 && card[6] == 0)
        bingo = 1;

    if (bingo)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;

int cnt_digits(ll N){
    int digits=0;
    while(N>0){
        N/=10;
        digits++;
    }
     /* string keta_a = to_string(a);
      string keta_b = to_string(b);
      int len_a = keta_a.size();
      int len_b = keta_b.size(); 
      int f = max(len_a,len_b);
      ans = min(f,ans);
    */
    return digits;
}

int main(){
  ll n;
  int ans = 100;
  cin >> n;
  
  for(ll a=1LL;a*a<=n;++a){
      if(n%a != 0) continue;
      ll b = n/a;  
      int cur=max(cnt_digits(a),cnt_digits(b));
      if(ans>cur) ans = cur;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define ac(x, i) get<i>(x)
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll ,ll>
#define pli pair<ll, int>
#define ff first
#define ss second
#define trace(x)    cerr << #x << ": " << x << "\n"
#define trav0(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trav1(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trap0(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define trap1(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define travMap(a)  cerr << #a << "[" << sz(a) <<  "] = ["; for (auto i : a) cerr << "(" << i.ff << ", " << i.ss << "), "; cerr << "]\n"
#define traverse(a) cerr << #a << "[" << sz(a) <<  "] = ["; for (auto i : a) cerr << i << ", "; cerr << "]\n"
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
const int infi = 1e9;
const ll infl = 1e18;
const int MOD = 1e9 + 7;
template <typename Map> bool map_compare (Map const &lhs, Map const &rhs) { return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());}
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 mt(seed);
int randint(int p = MOD) { return mt() % p;}
ll randlong(ll p = infl) { return mt() % p;}
#define random_permute(x) shuffle(all(x), mt)
ll log_2 (ll n) { return (n > 1ll)? 1ll + log_2(n/2): 0ll;}
inline void add(ll&a, ll b) {a += b; if (a >= MOD) a -= MOD;}
inline void sub(ll&a, ll b) {a -= b; if (a < 0) a += MOD;}

signed main() {
#ifdef HP
  freopen("input.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
  else cout << "No";
  return 0;
}

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

int main(){
    int n,v;
    cin>>n;
    vector<int> e(100001,0),o(100001,0);
    for(int i=0;i<n/2;i++){
        cin>>v; e[v]++;
        cin>>v; o[v]++;
    }
    pair<int,int> e1,e2,o1,o2;
    e1.first= e2.first=o1.first=o2.first=-1000000;
    for(int i=1;i<=100000;i++){
        if(e[i]>e1.first){
            e2=e1;
            e1=make_pair(e[i],i);
        }else if(e[i]>e2.first){
            e2=make_pair(e[i],i);
        }
        if(o[i]>o1.first){
            o2=o1;
            o1=make_pair(o[i],i);
        }else if(o[i]>o2.first){
            o2=make_pair(o[i],i);
        }
    }
    if(e1.second!=o1.second){
        cout<<n-e1.first-o1.first<<endl;
    }else{
        cout<<min(n-e1.first-o2.first,n-e2.first-o1.first)<<endl;
    }
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define lim 1000000007
#define MAX 10001
#define uomap unordered_map
#define uoset unordered_set
#define pb push_back
#define vec vector
#define mkp make_pair
#define fir first
#define sec second
#define LOG(fmt, args...) fprintf(stdout, fmt, ##args);
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
const ld  pi   = 4.0*atanl(1.0);
const int iinf = 1e9 + 10;
const ll  inf  = 1e18 + 10;
using namespace std;

static int max_points = 200; 
ll dis(ll a, ll b, ll c, ll d){ return abs(a-c)+abs(b-d); }

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int n; cin >> n;  bool flag = false;
    for(int i=0; i<n; i++){
    	ll temp; cin >> temp; 
    	if(temp%2 ==0 && temp%3 != 0 && temp%5 != 0){flag = true;}
    }
    if(flag){cout << "DENIED" << endl;}
    else{cout << "APPROVED" << endl;}
    
    return 0; 
    
}



/*
 * akina.cpp
 * Copyright 2019 Karan Kanojia <karankanojia@Karans-MacBook-Air.local>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  }

}

Measured memory_bytes: 20712
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
ll n,ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	if (n&1) printf("0\n");
	else {
		n/=2;
		while (n) ans+=n/5,n/=5;
		printf("%lld\n",ans);
	}
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        Scanner ss=new Scanner(System.in);
        String moji=sc.nextLine();
        char[] a=moji.toCharArray();
        if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3])){
            System.out.println("Yes");

        }else{
            System.out.println("No");
        }

        
        
        


    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int mod = 1000000007;
    int N;
    long long K;
    cin >> N >> K;
    
    int A[2001];
    rep(i,N){
        cin >> A[i];
    }
    
    int ans = 0;
    long cnt1 = 0;
    long cnt2 = 0;
    rep(i,N){
        for(int j = i + 1; j < N;j++){
            if(A[i] > A[j]) cnt1++;
        }
    }
    
    
    rep(i,N){
        rep(j,N){
            if(A[i] > A[j]) cnt2++;
        }
    }
    
    ans = (((cnt2%mod)*((K-1)*K/2%mod)) + (cnt1*K))%mod;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,s,t;
    cin >> n;
    s=0;
    t=0;
    for(int i=105;i<=n;i+=2){
        for(int j=1;j<=n;j++){
            if(i%j==0) t++;
        }
        if(t==8) s++;
        t=0;
    }
    cout << s <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 
 
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
ordered_set<ll> ors;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ld PI=3.14159265359;
 
ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}
 
ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}
 
ll lp[1000001];
vector<ll> pr;
 
void prime()
{
    repf(i,1,1000001) lp[i]=i;
    repf(i,2,1000001)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<1000001;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
    // repf(i,2,1000001) if(lp[i]==i) pr.pb(i);
}

const ll MX=200001;

vector<ll> v[MX];
ll depth[MX];
ll D[MX][22];
 
void dfs(ll x, ll p, ll h=0) {
    D[x][0]=p;
    depth[x]=h;
    repf(i,1,22)
    {
        if(D[x][i-1]!=-1 && D[D[x][i-1]][i-1]!=-1)
        {
            D[x][i]=D[D[x][i-1]][i-1];
        }
    }
    for(auto i:v[x]) {
        if(i==p) continue;
        dfs(i,x,h+1);
    }
}

ll walk(ll x, ll k)
{
    repf(i,0,22)
    {
        if((1<<i)&k)
        {
            x=D[x][i];
        }
    }
    return x;
}

ll lca(ll x, ll y)
{
    if(depth[x]>depth[y]) x=walk(x,depth[x]-depth[y]);
    if(depth[y]>depth[x]) y=walk(y,depth[y]-depth[x]);
    if(x==y) return x;
    repb(i,21,0)
    {
        if(D[x][i]!=D[y][i])
        {
            x=D[x][i];
            y=D[y][i];   
        }
    }
    return D[x][0];
}

void init() {
    prime();
}

void solve(ll tt) {
   ll n,k;
   cin>>n>>k;
   ll l[k],r[k];
   repf(i,0,k) {
       cin>>l[i]>>r[i];
    }
    ll dp[n+1],pre[n+1];
    pre[0]=0;
    dp[1]=1;
    pre[1]=1;
    repf(i,2,n+1) {
        dp[i]=0;
        repf(j,0,k) {
            ll left=l[j],right=r[j];
            dp[i]=(dp[i]+(pre[max(0LL,i-left)]-pre[max(0LL,i-right-1)]+MOD)%MOD)%MOD;
        }
        pre[i]=(pre[i-1]+dp[i])%MOD;
    }
    cout<<dp[n]<<endl;
} 
 
 
int main()
{
    // IOS;
    init();
    ll t=1;
    // cin>>t;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 19244
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Objects;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ManyRequirements solver = new ManyRequirements();
        solver.solve(1, in, out);
        out.close();
    }

    static class ManyRequirements {
        int n;
        int m;
        int q;
        List<Pair> pairs;
        long result = 0;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 数列の長さ
            n = in.nextInt();
            // 整数の範囲
            m = in.nextInt();
            q = in.nextInt();

            pairs = new ArrayList<>();
            for (int i = 0; i < q; i++) {
                pairs.add(new Pair(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()));
            }

            List<Integer> list = new ArrayList<>();
            for (int i = 1; i <= m; i++) {
                list.add(i);
                dfs(list);
                list.remove(list.size() - 1);
            }
            out.append(String.valueOf(result));
        }

        public void dfs(List<Integer> list) {

            if (list.size() == n) {
                long score = 0;
                for (Pair pair : pairs) {
                    if (list.get(pair.b) - list.get(pair.a) == pair.c) {
                        score += pair.d;
                    }
                }
                result = Math.max(result, score);
                return;
            }

            for (int i = Math.min(list.get(list.size() - 1), m); i <= m; i++) {
                list.add(i);
                dfs(list);
                list.remove(list.size() - 1);
            }
        }

        public class Pair implements Comparable<Pair> {
            int a;
            int b;
            int c;
            int d;

            public Pair(int a, int b, int c, int d) {
                this.a = a - 1;
                this.b = b - 1;
                this.c = c;
                this.d = d;
            }

            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                Pair pair = (Pair) o;
                return a == pair.a &&
                        b == pair.b &&
                        c == pair.c &&
                        d == pair.d;
            }

            public int hashCode() {
                return Objects.hash(a, b, c, d);
            }

            public int compareTo(Pair o) {
                return Integer.compare(a, o.a);
            }

        }

    }
}



Measured memory_bytes: 41616
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);

    rep(i, N) cin >> A[i];

    ll nax = A[0];
    ll ans = 0;
    repd(i, 1, N) {
        if (nax > A[i]) {
            ans += nax - A[i];
        }
        else {
            nax = A[i];
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
string s;
int ans1=0,ans2=0;
int main() {
	cin>>s;
	for(int i=0;i<s.size();i++) {
		if(s[i]=='0' && i%2==0) ans1++;
		if(s[i]=='1' && i%2==1) ans1++;
	}
	for(int i=0;i<s.size();i++) {
		if(s[i]=='1' && i%2==0) ans2++;
		if(s[i]=='0' && i%2==1) ans2++;
	}
	cout<<min(ans1,ans2);
	return 0;
}


Measured memory_bytes: 512
from collections import deque
n = int(input())

graph = [[] for i in range(n)]

for i in range(n-1):
    a, b, c = map(int, input().split())

    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))

q_num, k = map(int, input().split())

seen = [-1 for i in range(n)]
seen[k-1] = 0


q = deque()

q.append((k-1, 0))

while len(q) > 0:
    cur = q.popleft()

    cur_node = cur[0]
    cur_cost = cur[1]

    for nx in graph[cur_node]:
        nx_node = nx[0]
        nx_cost = cur_cost + nx[1]

        if seen[nx_node] < 0:
            seen[nx_node] = nx_cost
            q.append((nx_node, nx_cost))

queries = []

for i in range(q_num):
    queries.append(list(map(int, input().split())))


for query in queries:
    print(seen[query[0]-1] + seen[query[1]-1])


Measured memory_bytes: 68084
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    let t = get().as_bytes();
    
    let mut ans = 0;
    for i in 0 .. 3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 4352
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	K := nextInt()

	fmt.Println(len(strconv.FormatInt(int64(N), K)))
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int a, b;
    cin >> a >> b;
    cout << (int)((a + b) / 2.0 + 0.5) << endl;
    return 0;
}


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

using namespace std;

const int SAVE = 1000000;
int X;
const int ITEM[6] = {100, 101, 102, 103, 104, 105};

int main() {
	cin >> X;
	vector<vector<int> > dp(6, vector<int> (X + 1, -1));
	//dp[i][j] := i番目までで、i番目をdp個残してjにできる

	for (int i = 0; i < 6; i++) {
		dp[i][0] = SAVE;
	}
	for (int i = 0; i < 6; i++) {
		for (int j = 1; j <= X; j++) {
			if (j - ITEM[i] >= 0 && dp[i][j - ITEM[i]] > 0) {
				dp[i][j] = dp[i][j - ITEM[i]] - 1;
			}
			else if (i > 0 && dp[i - 1][j] >= 0) {
				dp[i][j] = SAVE;
			}
			else {
				dp[i][j] = -1;
			}
		}
	}
	if (dp[5][X] >= 0) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 20:50:42 2019

@author: Yamazaki Kenichi
"""

A,B = map(int,input().split())
ans = 0
def a(A,B):
    if (B-A) % 4 <= 1:
        return 0
    else:
        return 1

if A % 2 == 0:
    if B % 2 == 0:
        ans += B ^ a(A,B)
    else:
        ans += 0
        ans += a(A,B+1)
else:
    if B % 2 ==0:
        ans += A ^ B ^ a(A,B)
    else:
        ans += A ^ a(A,B)
if A == B:
    ans = A
print(ans)

#c = 0
#for i in range(A,B+1):
#    c ^= i
#print(c)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

//Circle and Points
public class Main{

	static class P{
		public double x, y;
		public P(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}
	
	static class R implements Comparable<R>{
		public double minx, maxx, miny, maxy;
		public P[] p;
		public int prob;
		boolean[] mark;
		public R(boolean[] u, double minx, double maxx, double miny, double maxy) {
			this.minx = minx;
			this.maxx = maxx;
			this.miny = miny;
			this.maxy = maxy;
			p = new P[4];
			p[0] = new P(minx, miny);
			p[1] = new P(minx, maxy);
			p[2] = new P(maxx, miny);
			p[3] = new P(maxx, maxy);
			mark = new boolean[n];
			prob = 0;
			for(int i=0;i<n;i++){
				if(u[i]){
					if(minx<=q[i].x&&q[i].x<=maxx && miny-1<=q[i].y&&q[i].y<=maxy+1){
						mark[i]=true;
						prob++;
					}
					else if(minx-1<=q[i].x&&q[i].x<=maxx+1 && miny<=q[i].y&&q[i].y<=maxy){
						mark[i]=true;
						prob++;
					}
					else {
						boolean f = false;
						for(int j=0;j<4;j++){
							if(Math.hypot(q[i].x-p[j].x, q[i].y-p[j].y)<=1){
								f = true;
								break;
							}
						}
						if(f){
							mark[i] = true;
							prob++;
						}
					}
				}
			}

		}
		public void find(){
			if(prob<=max)return;
			if(maxx-minx<0.000001){
				max = Math.max(max, prob);
				return;
			}
			R[] r = new R[4];
			double midx = (minx+maxx)/2;
			double midy = (miny+maxy)/2;
			r[0] = new R(mark, minx, midx, miny, midy);
			r[1] = new R(mark, midx, maxx, miny, midy);
			r[2] = new R(mark, minx, midx, midy, maxy);
			r[3] = new R(mark, midx, maxx, midy, maxy);
			Arrays.sort(r);
			for(int i=0;i<4;i++)r[i].find();
		}
		public int compareTo(R o) {
			return o.prob-prob;
		}
	}
	
	static int n;
	static int max;
	static P[] q;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n==0)break;
			q = new P[n];
			for(int i=0;i<n;i++){
				q[i] = new P(sc.nextDouble(), sc.nextDouble());
			}
			boolean[] u = new boolean[n];
			Arrays.fill(u, true);
			max = 0;
			R r = new R(u, 0, 10, 0, 10);
			r.find();
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define mod 1000000007LL
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())
#define sq(x) ((x)*(x))

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL)

#define EPS 1e-7

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 200005

int ans[505][505] ;

void calc(int l, int b, int e)
{
    if( b==e) return ;

    int m = (b+e)/2 ;

    for(int i=b ; i<=m ; i++)
    {
        for(int j=m+1 ; j<=e ; j++) ans[i][j] = l ;
    }
    calc(l+1,b,m) ; calc(l+1,m+1,e) ;
}

int main()
{
    int n ;

    scanf("%d",&n) ;

    calc(1,1,n) ;

    for(int i=1;  i<n ; i++)
    {
        for(int j=i+1 ; j<n ; j++)
        {
            printf("%d ",ans[i][j]) ;
        }
        printf("%d\n",ans[i][n]) ;
    }

    return 0 ;
}


Measured memory_bytes: 1408
import Data.List

main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  hate <- concat . words <$> getLine
  print $ solve n hate

solve :: Int -> String -> Int
solve n hate = let sn = show n
               in if (sn \\ hate) == sn
                    then n
                    else solve (n+1) hate


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 1e5 + 7;
int n, q, f[N];
ll s;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    f[x]++;
    s += x;
  }
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int x, y;
    cin >> x >> y;
    s -= (ll) x * f[x];
    s += (ll) y * f[x];
    f[y] += f[x];
    f[x] = 0;
    cout << s << "\n";
  }
  return 0;
}


Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    string s[n];
    rep(i,n)cin>>s[i];
    vector<int> alls(26,50);
    rep(i,n){
        vector<int> alphabet(26,0);
        rep(j,s[i].size()){
            alphabet[s[i][j]-'a']++;
        }
        rep(k,26)chmin(alls[k],alphabet[k]);
    }
    rep(i,26){
        char c='a'+i;
        rep(j,alls[i])cout<<c;
    }
    cout<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[]) {
	int a,b,c;
	int sum = 0;

	std::cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {
		if (!(c % i)) {
			sum++;
		}
	}
	std::cout << sum << std::endl;

	return 0;
}

Measured memory_bytes: 1164
import numpy as np

N, K = map(int, input().split())
v = list(map(int, input().split()))

mini = min(N, K)

ans = 0
for l in range(mini + 1):
    for r in range(mini + 1 - l):
        take = v[:l] + v[N - r:]
        ret = sorted(list(filter(lambda x: x < 0, take)))[:K-l-r]
        s = sum(take) - sum(ret)
        if s > ans:
            ans = s

print(ans)

Measured memory_bytes: 12500
#include <stdio.h>

int main() {
  char s[4];
  int ans = 0;
  scanf("%s", s);
  
  if (s[0] == 'R') {
    if (s[1] == 'R') {
      if (s[2] == 'R') 
        ans = 3;
      else
        ans = 2;
      }
    else
      ans = 1;
  }
  else if (s[1] == 'R') {
    if (s[2] == 'R')
      ans = 2;
    else
      ans = 1;
  }
  else if (s[2] == 'R')
    ans = 1;
  
  printf("%d", ans);
  return(0);
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    int a,b,c;
    cin >> a >> b >> c;
    bool flag = false;
    REPS(i, b){
        if (a*i%b==c) {
            flag = true;
            break;
        }
    }
    YES(flag);
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
	int a,b,i,j,as=0,bs=0;
	for(i=0;i<4;i++){
	cin>>a;
	as+=a;
	}
	for(j=0;j<4;j++){
	cin>>b;
	bs+=b;
	}
	if(as<bs){
	cout<<bs<<endl;
	}
	else if(as>bs){
	cout<<as<<endl;
	}
	else{
	cout<<as<<endl;
	}
return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

const int BLOCK = 100000;

struct Path
{
	int x, y, cost;
	Path(int _x, int _y, int _cost)
	{
		x = _x; y = _y; cost = _cost;
	}
};

void solve()
{
	int h, w;
	cin >> h >> w;

	vector< vector<int> > initial_maze( h, vector<int>(w, -1) );

	string s;
	for(int i = 0; i < h; ++i)
	{
		cin >> s;
		for(int j = 0; j < w; ++j)
		{
			initial_maze[i][j] = ((s[j] == '.') ? -1 : BLOCK);
		}
	}

	vector< vector<int> > maxPathCost( initial_maze );

	for(int i = 0; i < w; ++i)
	{
		for(int j = 0; j < h; ++j)
		{
			if (initial_maze[j][i] == BLOCK)
			{
				continue;
			}
			vector< vector<int> > maze( initial_maze );

			queue<Path> que;
			Path p(i, j, 0);
			maze[j][i] = max(0, maze[j][i]);
			que.push(p);

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

			while(!que.empty())
			{
				Path now = que.front();
				que.pop();

				for(int k = 0; k < 4; ++k)
				{
					int next_x = now.x + dx[k];
					int next_y = now.y + dy[k];
					if (next_x < 0 || w <= next_x || next_y < 0 || h <= next_y)
					{
						continue;
					}

					if (maze[next_y][next_x] == -1)
					{
						Path next(next_x, next_y, now.cost + 1);
						maze[next.y][next.x] = next.cost;
						que.push(next);
					}
					// cout << "come " << next.x << ", " << next.y << " " << next.cost << endl;
				}
			}

			for(int y = 0; y < h; ++y)
			{
				for(int x = 0; x < w; ++x)
				{
					maxPathCost[y][x] = max( maze[y][x], maxPathCost[y][x]);
				}
			}
		}
	}

	int ans = 0;
	for(int y = 0; y < h; ++y)
	{
		for(int x = 0; x < w; ++x)
		{
			//cout << x << ", " << y << " : " << maxPathCost[y][x] << endl;
			if (maxPathCost[y][x] == BLOCK)
			{
				continue;
			}
			ans = max( ans, maxPathCost[y][x]);
		}
	}

	cout << ans;

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
class dsu(object):
    def __init__(self, n):
        self.n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        assert 0 <= a and a < self.n
        assert 0 <= b and b < self.n
        x = self.leader(a)
        y = self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def leader(self, a):
        assert 0 <= a and a < self.n
        if self.parent_or_size[a] < 0:
            return a
        res = self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return res

    def same(self, a, b):
        assert 0 <= a and a < self.n
        assert 0 <= b and b < self.n
        return self.leader(a) == self.leader(b)

    def size(self, a):
        assert 0 <= a and a < self.n
        return -self.parent_or_size[self.leader(a)]

    def groups(self):
        leader_buf = set()
        for i in range(self.n):
            leader_buf.add(self.leader(i))
        result = {d: [] for d in leader_buf}
        for i in range(self.n):
            result[self.leader(i)].append(i)
        return result


if __name__ == "__main__":
    import sys
    input = sys.stdin.buffer.readline
    sys.setrecursionlimit(10 ** 7)
    N, Q = map(int, input().split())
    d = dsu(N)
    for _ in range(Q):
        t, u, v = map(int, input().split())
        if t == 0:
            d.merge(u, v)
            continue
        if d.same(u, v):
            print(1)
        else:
            print(0)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H.at(i) >= H.at(i + 1)) {
      cnt++;
      if (cnt > ans) ans = cnt;
    } else {
      cnt = 0;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
const int MN = 2e5+5, MOD=1e9+7;
ll lcm (ll a, ll b) {return a*b/__gcd(a,b);}
ll multiplyMod(ll a, ll b) { return (a % MOD * b % MOD) % MOD; }
ll addMod(ll a, ll b) { return (a % MOD + b % MOD) % MOD; }
ll subMod(ll a, ll b) { return (a % MOD - b % MOD) % MOD; }
ll fpow(ll b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
vector<string> strs;
int n;
unordered_map<string, int> freq;
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i<n;i++) {
        string s;
        cin >> s;
        if (freq.find(s) == freq.end()) {
            freq[s] = 1;
            strs.pb(s);
        }
        else {
            freq[s]++;
        }
    }
    sort(strs.begin(), strs.end());
    int maxfreq = 0;
    for (string x : strs) {
        maxfreq = max(maxfreq, freq[x]);
    }
    for (string x : strs) {
        if (freq[x] == maxfreq) { cout << x << '\n'; }
    }

    return 0;

}

Measured memory_bytes: 24248
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int n,k;
vector<bool> A(1000000000,false);

int main(){
    cin>>n;

    int ans=0;
    rep(i,0,n){
        int a;cin>>a;
        if(A[a-1]){
            A[a-1]=false;
            ans--;
        }else{
            A[a-1]=true;
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 122368
#include <stdio.h>
int main(void){
    int a,i,max,mini,n;
    long long int sum;
    max=-1000000;
    mini=1000000;
    sum=0;
    scanf("%d",&n);
 
    for (i=1 ; i<=n ; i=i+1){
        scanf("%d",&a);
        if(mini>a) mini=a;
        if(max<a) max=a;
        sum=sum+a;
    }
    printf("%d %d %lld\n",mini,max,sum);
    return 0;
}


Measured memory_bytes: 2100
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  val MOD = 1000000007
  def solve(N: Int): Long = {
    val f = {
      val f: ArrayBuffer[Int] = ArrayBuffer.empty
      for {
        i <- 1 to N
      } f ++= factorize(i)
      f.sorted
    }

    var res: Long = 1
    var i = 0
    while(i < f.length) {
      var j = i
      while (j < f.length && f(i) == f(j)) j += 1
      val len = j - i
      res = res * (len + 1) % MOD
      i = j
    }

    res
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    println(solve(sc.nextInt()))
  }

  def factorize(n: Int): Array[Int] = {
    // 見つからなかったら-1
    def minFactor(n0: Int, i: Int): Int = {
      if (i > n0) -1
      else if (n0 % i == 0) i
      else minFactor(n0, i + 1)
    }

    def step(n0: Int, acc: List[Int]): List[Int] = {
      minFactor(n0, 2) match {
        case -1 => acc
        case f => step(n0 / f, f :: acc)
      }
    }

    step(n, Nil).toArray
  }
}


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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector <int>
#define vvi         vector <vi>
#define pii         pair <int,int>
#define vii         vector <pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         1000000007
#define PI          3.1415926535897932

signed main()
{
        IO;
        int n;
        cin >> n;
        int take = 1000 - n % 1000;
        take %= 1000;
        cout << take;
}



Measured memory_bytes: 3640
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 100001
typedef long long ll;
using namespace std;


int main(){
    string S,T;
    cin >> S >> T;
    ll rev=0;
    for(ll i = 0 ; i < S.length() ; i++){
        if(S[i] != T[i]){
            rev++;
        }
    }
    cout << rev << endl;
    return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const ll BIGMOD = 1e9 + 7;
using namespace std;
// 順列
ll Permutation(ll n, ll r) {
  if (n < r) return 0;
  ll ans = 1;
  for (ll i = n; i > n - r; --i) ans *= i;
  return ans;
}  // End_Func

// 組み合わせ
ll Combination(ll n, ll r) {
  if (n < r) return 0;
  ll ans = 1;
  for (ll i = n; i > n - r; --i) ans *= i;
  for (ll i = 1; i <= r; ++i) ans /= i;
  return ans;
}  // End_Func

int main() {
  int n, m;
  cin >> n >> m;
  cout << Combination(n, 2) + Combination(m, 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
const int MAXN = 200100;
const int mod = 998244353;
typedef long long LL;
typedef pair<int, int> PII;
int n, a[MAXN], h[MAXN], g[MAXN], low[MAXN], dfn[MAXN], be[MAXN], num, tim;
bool in[MAXN];
vector<int> G[MAXN];
stack<int> st;
bool cmp(const int &o, const int &p) { return a[o] < a[p]; }
void build(int o, int L, int R) {
	G[o].clear();
	be[o] = dfn[o] = low[o] = 0;
	if (o > 1) {
		G[o].push_back(o / 2);
		// cout << o << "->" << o / 2 << endl;
	}
	if (L + 1 == R) {
		g[h[L] ^ 1] = o;
		return;
	}
	build(ls, L, mid);
	build(rs, mid, R);
}
void update(int o, int L, int R, int l, int r, int v) {
	if (l <= L && R <= r) {
		G[o].push_back(v);
		// cout << o << "->" << v << endl;
		return;
	}
	if (l < mid) update(ls, L, mid, l, r, v);
	if (r > mid) update(rs, mid, R, l, r, v);
}
void trjan(int x) {
	// cout << x << " ";
	low[x] = dfn[x] = ++tim;
	st.push(x);
	in[x] = 1;
	for (auto &i : G[x]) {
		if (!dfn[i]) {
			trjan(i);
			low[x] = min(low[x], low[i]);
		} else if (in[i])
			low[x] = min(low[x], dfn[i]);
	}
	if (low[x] == dfn[x]) {
		int y;
		num++;
		do {
			y = st.top();
			st.pop();
			be[y] = num;
			in[y] = false;
		} while (x != y);
	}
}
bool check(int o) {
	build(1, 0, n + n);
	num = tim = 0;
	int L = 0;
	for (int i = 0; i < n + n; ++i) {
		while (L < i && a[h[i]] >= a[h[L]] + o) {
			L++;
		}
		if (L < i) update(1, 0, n + n, L, i, g[h[i]]);
	}
	int R = n + n - 1;
	for (int i = n + n - 1; i >= 0; --i) {
		while (R > i && a[h[i]] + o <= a[h[R]]) {
			R--;
		}
		if (R > i) update(1, 0, n + n, i + 1, R + 1, g[h[i]]);
	}
	for (int i = 0; i < n + n; ++i) {
		if (!dfn[g[i]]) trjan(g[i]);
	}
	for (int i = 0; i < n; ++i) {
		if (be[g[i << 1]] == be[g[i << 1 | 1]]) {
			// cout << be[g[i << 1]] << " " << be[g[i << 1 | 1]] << endl;
			return false;
		}
	}
	return true;
}
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d%d", &a[i << 1], &a[i << 1 | 1]);
	for (int i = 0; i < n + n; ++i) h[i] = i;
	sort(h, h + n + n, cmp);
	int L = 0, R = a[h[n + n - 1]];
	// cout << check(4) << endl;
	while (R - L > 1) {
		// cout << L << " " << R << endl;
		if (check(mid)) {
			L = mid;
		} else {
			R = mid;
		}
	}
	printf("%d\n", L);
	return 0;
}

Measured memory_bytes: 17400
#include <iostream>
#include <vector>
#include <map>

using namespace std;
using int64 = long long;
using V = vector<int>;
using VV = vector<V>;
using P = pair<int,int>;

void dfs(const int& u, const int& p, const int64& d, const VV& g,  map<P,int64>& edges, vector<int64>& dist) {
    if (dist[u] >= 0) return;
    dist[u] = d;

    for (auto v : g[u]) {
        if (v == p) continue;
        dfs(v,u,d+edges[P(u,v)], g, edges, dist);
    }

}

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

    VV g(n+1);
    map<P,int64> edges;
    for (int i=0; i<n-1; i++) {
        int u,v,w;
        cin >> u >> v >> w;
        g[u].push_back(v);
        g[v].push_back(u);
        edges[P(u,v)] = w;
        edges[P(v,u)] = w;
    }

    vector<int64> dist(n+1,-1);
    dfs(1, -1, 0, g, edges, dist);

    for (int i=1; i<=n; i++) {
        cout << dist[i] % 2 << endl;
    }
}

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

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

}


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

#define int long long

signed main() {
    int N, K;
    cin >> N >> K;
    int tmp = (N - 1) * (N - 2) / 2;
    if (tmp < K) {
        cout << -1 << endl;
        return 0;
    }
    int remain = tmp - K;
    cout << remain  + N  - 1<< endl;
    for (int i = 0; i < N - 1; i++) {
        cout << i + 1 << " " << N << endl;
    }
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (remain <= 0) return 0;
            cout << i + 1 << " " << j + 1 << endl;
            remain --;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<utility>
#define LL long long

using namespace std;



int main() {
	int N;
	string S;
	cin >> N >> S;
	if(N%2)cout << "No" << endl;
	else{
		for(int i=0; i<N/2; i++){
			if(S[i]!=S[N/2+i]){
				cout << "No" << endl;
				break;
			}
			if(i==N/2-1)cout << "Yes" << endl;
		}
	
	}


	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	for (int i = 0; i < 200; i++) {
			C -= B;
			if (C <= 0) {
				cout << "Yes" << endl;
				break;
			}
			else if (A > 0) {
				A -= D;
				if (A <= 0) {
				cout << "No" << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3584