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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    set<i64> se;
    REP(i, N) {
        i64 a; cin >> a;
        if (se.count(a) > 0) se.erase(a);
        else se.insert(a);
    }
    cout << se.size() << endl;

    return 0;
}

Measured memory_bytes: 8256
#include <iostream>

using namespace std;

int arr[100001] = {};

int main() {
	int n;
	int count = 0;
	cin >> n;

	int a;

	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (arr[a] == i) {
			count++;
		}
		else {
			arr[i] = a;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 768
def judge(n, k):
    r = 0
    for _ in range(1, n + 1, 2):
        r += 1
        if r >= k:
            return True
    return False


def main():
    n, k = (int(z) for z in input().split())
    if judge(n, k):
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b;
  cin >> a >> b;
  if (a + b >= 10)
    cout << "error" << endl;
  else
    cout << a + b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
 
using namespace std;
 
/////////////////////////////////////////////////////
int H,W,N,sr,sc;
char S[202020],T[202020];
queue<pii> pa[2];
int i,j,k,ans;
char s[] = "RDLURD";
int px[] = {1, 0, -1, 0, 1, 0}, py[] = {0, 1, 0, -1, 0, 1};
int main(){
    scanf("%d%d%d%d%d%s%s", &H,&W,&N,&sr,&sc,S,T);
    int h, w;
    fornum(k,0,4){
        h = sr;
        w = sc;
        fornum(i,0,N){
            if(S[i]==s[k]){
                h += py[k];
                w += px[k];
                if(h==0||w==0||h>H||w>W){
                    printf("NO");
                    return 0;
                }
            }
            if(T[i]==s[k+2]){
                h += py[k + 2];
                w += px[k + 2];
                if(h==0||w==0||h>H||w>W){
                    h -= py[k + 2];
                    w -= px[k + 2];
                }
            }
        }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		long ans = 0;
		for(int i = 1; i <= n; i++) {
			
			if(i % 3 == 0 || i % 5 == 0) {
				continue;
			}
			ans += i;
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32896
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    
    unordered_set<int> us;
    rep(i, d.size()) us.emplace(d[i]);
    put(us.size());

    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    private static long MOD = 998244353;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int S = sc.nextInt();
        int[] A = new int[N];
        long[] now = new long[S+1];
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        now[0] = 1;
        //mps.get(A[0]).put(1,1L);//1 ko de 1 toori
        for(int i=0;i<N;i++){
            long[] addArr = new long[S+1];
            for(int j=S;j>=0;j--){
                addArr[j] += now[j];
                if(j+A[i] > S){continue;}
                addArr[j+A[i]] += now[j];
            }
            for(int j=0;j<=S;j++){
                now[j] += addArr[j];
                now[j] %= MOD;
            }
        }
        System.out.println(now[S]);
    }


}


Measured memory_bytes: 54928
using namespace std;
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return pow(x * x , n / 2);
	else
		return x * pow(x, n - 1);
}
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rip(i, n)cin >> a[i];
	int q;
	cin >> q;
	vector<int>b(q);
	vector<int>c(q);
	rip(i, q)cin >> b[i] >> c[i];
	sort(all(a));
	ll sum = 0;
	rip(i, n)sum += a[i];
	vector<int>kosuu(100001, 0);
	rip(i, n)kosuu[a[i]]++;
	rip(i, q) {
		int sa = c[i] - b[i];
		sum += kosuu[b[i]] * sa;
		kosuu[c[i]] += kosuu[b[i]];
		kosuu[b[i]] = 0;
		cout << sum << endl;
	}
}

Measured memory_bytes: 4840
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
#define MOD 1000000007
#define MAX 100100
inline ll read()
{
	ll x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int n,f[MAX],s[MAX];
ll A,B,a[MAX];
int main()
{
	n=read();A=read();B=read();if(A>B)swap(A,B);
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=n-2;++i)
		if(a[i+2]-a[i]<A){puts("0");return 0;}
	f[0]=s[0]=1;
	for(int i=1,p=0,lim=0;i<=n;++i)
	{
		while(p<i&&a[i]-a[p+1]>=B)++p;
		if(lim<=p)add(f[i],(s[p]+MOD-(lim?s[lim-1]:0))%MOD);
		add(s[i],s[i-1]+f[i]);
		if(i>1&&a[i]-a[i-1]<A)lim=i-1;
	}
	int ans=0;
	for(int i=n;~i;--i)
	{
		add(ans,f[i]);
		if(i<n&&a[i+1]-a[i]<A)break;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1792
n,a,b = gets.split(" ").map!{|i| i.to_i}
max = 0
min = 0
if a>= b
 max  =b
else max = a
end
if a + b >= n
 min = (a+b-n).abs
else
 min = 0
end
puts "#{max} #{min}"


Measured memory_bytes: 3836
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 
// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********
// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}
inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}
inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}
ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}
ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
ll modinv(ll n)
{
	return modexp(n,mod-2);
}
// ******** GLOBAL VARIABLES ********
// ******** GLOBAL VARIABLES ********
void dfs(ll i,bool vis[],vll g[]){
	vis[i]=true;
	for(auto it:g[i]){
		if(!vis[it])
			dfs(it,vis,g);
	}
}
void solve(){
	ll n,m;
	cin>>n>>m;
	vll g[n];
	ll c=0;
	REP(i,m){
		ll x,y;
		cin>>x>>y;
		--x,--y;
		g[x].pb(y);
		g[y].pb(x);
	}
	bool vis[n];
	init(vis,false);
	REP(i,n){
		if(!vis[i]){
			c++;
			dfs(i,vis,g);
		}
	}
	cout<<c-1<<endl;
}  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 10780
#include<stdio.h>
//#define N 100
int main(void)
{

    int i,t,j,v,N;
    int A[100];
    scanf("%d", &N);
    for(i=0; i<N; i++){
      scanf("%d", &A[i]);
    }
    for(i=0; i<N; i++){
      if(i==N-1){printf("%d\n", A[i]);
    }else{printf("%d ", A[i]);
  }
    }
    for(i=1; i<=N-1; i++){
      v = A[i];
      j = i -1;
      while(j>=0 && A[j]>v){
        A[j+1] = A[j];
        j--;
      }
      A[j+1] = v;
      for(t=0; t<N; t++){
          if(t==N-1){printf("%d\n", A[t]);
        }else if(i==N-1){
          printf("%d ", A[t]);
        }else if(i==N-1 && t==N-1){
          printf("%d", A[t]);
        }else{printf("%d ", A[t]);
        }
      }
    }
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N,A;
    cin>>N>>A;
    cout<<N*N-A<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String ans = "No";
		if(N == M){
			ans = "Yes";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
H, N = map(int,input().split())
#A = [0]*N
A = list(map(int,input().split()))	
if sum(A) >=H:
    print("Yes")
else:
    print("No")
    





Measured memory_bytes: 13964
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
int main(){
  
  string str;
  int n;
  cin >>n;
  for(int i=0;i<n;i++){
    set<string> s;
    cin >> str;
    for(int j=1;j<str.size();j++){
      string str1=str.substr(0,j);
      string str2=str.substr(j);
      string str3=str1;
      string str4=str2;
      reverse(str3.begin(),str3.end());
      reverse(str4.begin(),str4.end());
      s.insert(str1+str2);    
      s.insert(str1+str4);    
      s.insert(str2+str1);    
      s.insert(str4+str1);    
      s.insert(str3+str2);    
      s.insert(str3+str4);    
      s.insert(str2+str3);    
      s.insert(str4+str3);    
    }      
    cout << s.size() << endl;
  }
  return 0;
}

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

int main(){
    int n;cin >> n;
    int p[n];
    for(int i = 0; i<n; i++){
        cin >>p[i];
    }
    int count = 0;
    for(int l = 0; l < n-2;l++){
        if(p[l] > p[l+1] && p[l+1] > p[l+2]){
            count++;
        }
        if(p[l] < p[l+1] && p[l+1] < p[l+2]){
            count++;
        }
    } 
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int N;
	double x;
	char u[3];
	scanf("%d",&N);
	int a;
	double sum=0;
	for(a=0;a<N;a++){
		scanf("%lf %s",&x,u);
		if(u[0]=='J'){
			sum+=x;
		}else{
			sum+=(x*380000.0);
		}
	}
	printf("%.8f",sum);
return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from heapq import heapify, heappop, heappush
 
N = int(input())
INF = float("inf")
d = [INF for n in range(N)]
d[0] = 0
adj = [[] for _ in range(N)]
 
searched = [False for _ in range(N)]
searched[0] = True
 
for n in range(N):
    inp = tuple(map(int, input().split()))
    assert n == inp[0]
    adj[n] = list(zip(inp[2::2], inp[3::2]))
 
heap = [[0, 0]]
 
while len(heap):
    pcost, p = heappop(heap)
    searched[p] = True
     
    if d[p] < pcost:
        continue
     
    for v, c in adj[p]:
        if not searched[v]:
            new_cost = pcost + c
            if new_cost < d[v]:
                d[v] = new_cost
                heappush(heap, [new_cost, v])
 
for n in range(N):
    print("{} {}".format(n, d[n]))

Measured memory_bytes: 70368
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int N, W;
int w[101], v[101];
ll dp[101][100001];
//dp[i][j] : 1~i를 고려하고 가치가 j일 때 최소 무게

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> W;
	for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];
	for (int i = 0; i <= N; i++)
		for (int j = 0; j <= 100000; j++) {
			if (i == 0) dp[i][j] = j == 0 ? 0 : 2e18;
			else {
				dp[i][j] = dp[i - 1][j];
				if (j - v[i] >= 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
			}
		}

	int ans = 0;
	for (int i = 0; i <= 100000; i++) if (dp[N][i] <= W) ans = max(ans, i);
	cout << ans << '\n';
	return 0;
}

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


int get_divisor(int n) {
  int cnt = 0;
  for (int i=1; i<=n; i++) {
  	if ((n % i) == 0) cnt++;
  }
  return cnt;
}

int main() {
  int N;
  cin >> N;
  
  int cnt=0;
  for (int i=1; i<=N; i++) {
    int divisor = get_divisor(i);
    if ((divisor == 8) && ((i % 2) != 0)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

import sys

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

h = [None] * N

if T[-1] != A[0]:
    print(0)
    sys.exit()

odd = False
h[0] = T[0]
for i, (a, b) in enumerate(zip(T[1:], T[:-1]), 1):
    if a != b:
        h[i] = a
    if a < b:
        odd = True
        break

if odd is True:
    print(0)
    sys.exit()

if h[-1] is None:
    h[-1] = A[-1]
elif h[-1] != A[-1]:
    print(0)
    sys.exit()

for i, (a, b) in enumerate(zip(A[::-1][1:], A[::-1][:-1]), 1):
    if a != b:
        if h[N-i-1] is None:
            h[N-i-1] = a
        elif h[N-i-1] != a:
            odd = True
            break
    if a < b:
        odd = True
        break

if odd is True:
    print(0)
    sys.exit()

i = 1
a, b = 0, 0
cnt = 0
ans = 1
flag = False
while i < N-1:
    if h[i] is None:
        flag = True
        a = h[i-1]
        cnt = 0
        while h[i] is None:
            i += 1
            cnt += 1
        b = h[i]
        # print(a, b, cnt)
        ans = (ans * (min(a, b) ** cnt)) % (10 ** 9 + 7)
        # print(ans)
    else:
        i += 1

# check
# print(h)
odd = False
for i in range(N):
    if h[i] != None:
        cm = h[i]
    if T[i] < cm:
        # print(i, cm, T[i])
        odd = True
        break
cm = None
for i in range(N):
    if h[N-i-1] != None:
        cm = h[N-i-1]
    if A[N-i-1] < cm:
        # print('hoge')
        # print(N-i-1, cm, A[N-i-1])
        odd = True
        break
if odd is True:
    print(0)
    sys.exit()

print(ans)


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

int main()
{
  int64_t n;
  cin >> n;
  
  int64_t a[n+1];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  a[n] = 100000001;
    
  sort(a,a+n);
  int64_t ans = 0,count = 1;
  for(int i = 0; i < n; i++){
    if(a[i] == a[i+1]){
      count++;
    }else{
      if( (count % 2) == 1){
        ans++;
      }
      count = 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4432
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = sum(b) - sum(a)
ac = 0
bc = 0
for i in range(n):
    if a[i] < b[i]:
        if (b[i] - a[i]) % 2 == 0:
            ac += (b[i]-a[i])//2
        elif (b[i] - a[i]) % 2 == 1:
            ac += (b[i]-a[i])//2 + 1
            bc += 1
    elif a[i] > b[i]:
        bc += a[i]-b[i]
if ac > cou or bc > cou:
    print("No")
else:
    if cou - bc == (cou-ac)*2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4596
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < 100; i++) {
            int p = i + 1;
            int count = 0;
            for (int j = 0; j < n; j++) {
                count += (a[j] - p) * (a[j] - p);
            }

            ans = Math.min(ans, count);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;
//  map<int,int>mm1,mm2;
// int pre[200015];

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

     clock_t clk;
 	clk = clock();
 
// -------------------------------------Code starts here--------------------------------------------------------------------- 

    int n;
    cin>>n;
    cout<<(n*n);

// -------------------------------------Code ends here------------------------------------------------------
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	int n,a,b;
	cin>>n>>a>>b;
	int k=n/(a+b);
	n%=(a+b);
	int sum=k*a;
	if(a>=n)
	{
		sum+=n;
	}
	else
		sum+=a;
	cout<<sum<<endl;






}


Measured memory_bytes: 256
#include <stdio.h>



#define MOD 1000000007
typedef long long int ll;

//dp solution
ll grid1_dp( ll H, ll W, ll cols, char arr[][cols]){

	ll dp[H][W];
	
	for(int h=0;h<H;h++){
		for(int w=0;w<W; w++){
		
			if(h<0||w<0) dp[h][w]=0;

			else if(h==0 && w==1 && arr[h][w]=='.')
				dp[h][w]=1;
			else if(h==0 && w==1 && arr[h][w]=='#')
				dp[h][w]=0;
				
			else if(h==1 && w==0 && arr[h][w]=='.')
				dp[h][w]=1;
				
			else if(h==1 && w==0 && arr[h][w]=='#')
				dp[h][w]=0;
				
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]= (dp[h-1][w]%MOD+dp[h][w-1]%MOD)%MOD;
				
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='#' && h-1>=0 && w-1>=0)
				dp[h][w]=dp[h-1][w]%MOD;
			
			else if(arr[h-1][w]=='#' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]=dp[h][w-1]%MOD;
			
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]= (dp[h-1][w]%MOD+dp[h][w-1]%MOD)%MOD;
				
				
			else if(h==0 && w-1>=0 && arr[h][w]=='.'){
				dp[h][w]=dp[h][w-1]%MOD;
			}
			
			else if(h-1>=0 && w==0 && arr[h][w]=='.'){
				dp[h][w]=dp[h-1][w]%MOD;
			}
			else dp[h][w]=0;
			
		}
	
	}
	
	return dp[H-1][W-1];

}



//recursive solution
ll grid1( ll h, ll w, ll cols, char arr[][cols]){
	if(h<0||w<0) return 0;

	else if(h==0 && w==1 && arr[h][w]=='.')
		return 1;
	else if(h==0 && w==1 && arr[h][w]=='#')
		return 1;
		
	else if(h==1 && w==0 && arr[h][w]=='.')
		return 1;
		
	else if(h==1 && w==0 && arr[h][w]=='#')
		return 0;
		
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return ((grid1(h-1, w,cols, arr))%MOD+(grid1( h, w-1, cols, arr))%MOD)%MOD;
		
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='#' && h-1>=0 && w-1>=0)
		return (grid1(h-1, w, cols, arr))%MOD;
	
	else if(arr[h-1][w]=='#' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return (grid1(h, w-1, cols, arr))%MOD;
	
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return ((grid1(h-1, w,cols, arr))%MOD+(grid1( h, w-1, cols, arr))%MOD)%MOD;
		
		
	else if(h==0 && w-1>=0 && arr[h][w]=='.'){
		return (grid1( h, w-1, cols, arr))%MOD;
	}
	
	else if(h-1>=0 && w==0 && arr[h][w]=='.'){
		return (grid1( h-1, w, cols, arr))%MOD;
	}
	else return 0;
}

int main(){
	ll h, w,cols;
	scanf("%lld%lld", &h, &w);
	char arr[h][w];
	cols = w;
	ll i=0,j=0;
	char c;
	while(i<h){
		j=0;
		while(j<w){
			
			scanf("%c", &c);
			
			if(c!='\n'){
				arr[i][j]=c;
				j++;
			}
			
			
		}
		i++;
		
	}
			
	
			
	printf("%lld\n", grid1_dp( h, w,cols,  arr));
	

}

Measured memory_bytes: 8960
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//SOLVE
void solve(void)
{
  int N,T; cin>>N;cin>>T;
  int MIN = INF;
  for (int i = 0; i < N; i++)
  {
    int X,Y;
    cin>>X>>Y;
    if(Y <= T)
    {
      chmin(MIN,X);
    }
  }
  if(MIN == INF)
  {
    cout<<"TLE"<<endl;
    return;
  }
   
  cout<<MIN<<endl;
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int main() {
	// your code goes here
	ll n,k;
	cin>>n;
	cin>>k;
	ll arr[100001],dp[10000001],i,ans;
	for(i=0 ; i<n ; i++)
	{
		cin>>arr[i];
	}
	dp[0]=0;
	for(i=1;i<100001;i++)
	{
		dp[i]=1e9;
	}
	for(i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			dp[i+j]=min(dp[i+j],abs(arr[i]-arr[i+j])+dp[i]);
		}
	
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 3840
use std::io::*;
use std::str::FromStr;
use std::cmp::{min, max};

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin_lock = stdin.lock();
    let s = stdin_lock
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let (N, Y): (i32, i32) = (read(), read());

    let mut ok = false;

    for x in 0..N+1 {
        for y in 0..N+1 {
            let z = N - x - y;

            if z < 0 {
                continue;
            }

            if 10000 * x + 5000 * y + 1000 * z == Y {
                println!("{} {} {}", x, y, z);
                return;
            }
        }
    }

    println!("-1 -1 -1");
}

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

int main( void )
{
    char s[ 4 ];
    char t[ 4 ];
    cin >> s >> t;
    int ans = 0;
    for ( int i = 0; i < 3; i++ )
    {
        if ( s[ i ] == t[ i ] )
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

int main(){
	long a, b, c, i = 1, total = 0;
	std::cin >> a >> b >> c;
	while (total < c) {
		total += a;
		if (i != 0 && ((i % 7) == 0)) total += b;
		i++;
	}

	std::cout << i - 1 << std::endl;
	return 0;
}


Measured memory_bytes: 3108
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if N%2 == 1:
        if A[0] != 0:
            return 0
        for i in range(1,N,2):
            if (A[i]==i+1 and A[i+1]==i+1)==False:
                return 0
        return (2**(N//2))%(10**9+7)
    else:
        for i in range(0,N,2):
            if (A[i]==i+1 and A[i+1]==i+1)==False:
                return 0
        return (2**(N//2))%(10**9+7)

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 14008
#include <iomanip>
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1 -= x2;
	y1 -= y2;
	cout << fixed << setprecision(5) << sqrt(x1*x1 + y1*y1) << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

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

int main(){
    ll n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;
    ll l = lcm(n, m);
    ll g = gcd(n, m);
    rep(i, g){
        if(s[n / g * i] != t[m / g * i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << endl;
    return 0;
}


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

void bubbleSort(int *a, int n, int &ans) {
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int j = n - 1; 0 < j; --j) {
            if (a[j] < a[j - 1]) {
                int tmp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = tmp;
                flag = 1;
                ++ans;
            }
        }
    }
}

int main() {

    int n;
    cin >> n;

    int *a = new int[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int ans = 0;
    bubbleSort(a, n, ans);

    int _n = n - 1;
    for (int i = 0; i < n; ++i) {
        if (i != _n) cout << a[i] << " ";
        else cout << a[i] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1188
n,*a=map(int,open(0).read().split())
m=max(a)+10
li=[0]*m
for x in a:
	li[x]+=1
ans=0
for i in range(1,m):
	if li[i]:
		if li[i]==1:
			ans+=1
		for j in range(i,m,i):
			li[j]=0
print(ans)

Measured memory_bytes: 118792
import java.util.*;

public class Main{
  public static int total(int t){
    int sum = 0;
    while (t != 0){
      sum += t % 10;
      t /= 10;
    }
    return sum;
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int result = 0;
    for (int i = 1; i <= N; i++){
      if ( A <= total(i) && total(i) <= B) result += i;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 35660
#include<iostream>
#include <algorithm>
#include<vector>
#include<map>
#include <set>
#include<string>
#include <queue>
#include <stack>
#include <random>
#define INF 1000000001
#include<iostream>
#include<vector>
using ll = long long;

ll gcd(const ll x, const ll y){
    if(x % y == 0) return y;
    return gcd(y, x%y);
}

ll lcm(const ll x, const ll y){
    return x / gcd(x,y) * y;
}

int main()
{    

    ll N;
    std::cin >> N;
   ll ans = 1;
   for(ll i = 0; i < N; ++i){
    ll t;
    std::cin >> t;
    ans = lcm(ans, t);
   }

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



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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

ll n;
string a[200000 + 5];
ll sum[200000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    n += n - 1;
    rep(i, n) cin >> a[i];
    sum[0] = ll(stoi(a[0]));
    rep2(i, 1, n) {
        if(i % 2 == 0) continue;
        if (a[i] == "+") sum[i + 1] = sum[i - 1] + ll(stoi(a[i + 1]));
        else sum[i + 1] = sum[i - 1] - ll(stoi(a[i + 1]));
    }
    ll ans = ll(stoi(a[0]));
    rep2(i, 1, n) {
        if (i % 2 == 0) continue;
        if (a[i] == "+") ans += ll(stoi(a[i + 1]));
        else ans -= ll(stoi(a[i + 1]));
    }
    ll plus = 0;
    ll minus = 0;
    rrep2(i, n - 1, -1) {
        if (a[i] == "+") continue;
        if (a[i] == "-") {
            ans = max(ans, sum[i - 1] + plus + minus);
            plus += -minus;
            minus = 0LL;
        }
        else minus -= ll(stoi(a[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 12800
#include <stdio.h>
#include <stdlib.h>
  
#define MAX 100
  
int pop();
void push(int);
  
int stack[MAX];
int top = 0;
  
int main(){
  
  int a, b, d;
  char c[7];
  
  while((scanf("%s", &c))!= EOF){
  
    if(c[0] == '+' || c[0] == '-' || c[0] == '*'){
  
      switch(c[0]){
  
      case '+':
        
    a = pop();
        
    b = pop();
        
    push(a + b);
        
    break;
  
  
      case '-':
        
    a = pop();
        
    b = pop();
  
    push(b - a);
  
    break;
  
  
      case '*':
       
    a = pop();
        
    b = pop();
  
    push(a * b);
  
    break;
  
  
      default:
  
    break;
      
      }
    }
  
    else{
  
      d = atoi(c);
  
      push(d);
  
    }
  
  }
  
  printf("%d\n", pop());
    
  return 0;
  
}
  
int pop(){
  
  if(top <= 0)
    return 0;
  else
    top = top - 1;
  
  
  return stack[top + 1];
   
}
  
void push(int data){
  
  top++;
    
  stack[top] = data;
    
}

Measured memory_bytes: 548
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    long int N; cin >> N;
    long int a = pow(N, 0.5);
    long int b, c;
    while(1){
        if(N % a == 0){
            b = a; c = N / a;break;
        }
        a--;
    }
    cout << b + c - 2<< endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int n;
  int s1,s2,s3;
  int temp;
  
    scanf("%d",&n);

  for(int i = 0;i < n;i++){
    scanf("%d %d %d",&s1,&s2,&s3);
    if(s1 < s2){
      temp = s1;
      s1 = s2;
      s2 = temp;
    }
    if(s1 < s3){
      temp = s1;
      s1 = s3;
      s3 = temp;
    }
    if(s1 * s1 == s2 *s2 + s3 * s3){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }

  return 0;
}

Measured memory_bytes: 2512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    int max = 0;
    int ans = 0;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < n; i++){
        if(max <= h[i]){
            ans++;
            max = h[i];
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
const ll MOD=1000000007LL;
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a-b<0){
    cout<<"No"<<endl;
    return 0;
  }
  if(c*c+a*a+b*b-2*a*c-2*b*c+2*a*b>4*a*b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

//ユークリッドの互除法で最大公約数を求める
int gcd( int p, int q ) {
	if( q == 0 ) return p;
	return gcd( q, p % q );
}

int main(void){

	/*
		睡眠の周期はa+b分
		睡眠と山手線の周期はlcm( a+b, 60 )
		0からlcm( a + b, 60 )までを調べれば十分？
	*/

	int a, b, c, lcm;
	int ans = -1;

	cin >> a >> b >> c;
	lcm = ( a + b ) * 60 / gcd( ( a + b ) , 60 );

	for( int t = 0; t <= lcm; t += ( a + b ) ) {
		for( int i = 0; i <= a; i++ )
			if( ( t + i ) % 60 == c ) 
				ans = t + i;
		if( ans > 0 ) break;
	}

	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1164
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int n,ans=0;cin>>n;
	int l[n];rep(i,n)cin>>l[i];sort(l,l+n);
	rep(i,n)rep(j,i){
		ans+=(int)(lower_bound(l,l+n,l[i]+l[j])-l)-i-1;
	}
	dans;
}


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

int main()
{int A, B, C;
 cin >> A >> B >> C;
 bool can=false;
 int cnt = A%B;
 for(int i=2;i<=B; i++){
   int ans = cnt*i;
   if (ans%B==C)
     can = true;}
 if(can) cout << "YES" << endl;
 else cout << "NO" << endl;
     
 }

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

int main() {
string S;
cin >> S;
if (S == "Sunny") {
    cout << "Cloudy" << endl;
}
if (S == "Cloudy") {
    cout << "Rainy" << endl;
}
if (S == "Rainy") {
    cout << "Sunny" << endl;
}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int t = sc.nextInt();

      int minCost = Integer.MAX_VALUE;
      for(int i = 0; i < n; i++) {
        int cost = sc.nextInt();
        int time = sc.nextInt();
        if(time <= t)
          minCost = Math.min(minCost, cost);
      }
      System.out.println(minCost == Integer.MAX_VALUE ? "TLE" : minCost);
  }
}

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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i != n - 1) {
			if (x >= a[i]) x -= a[i], ans++;
		} else {
			if (x == a[i]) ans++;
			else break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int64_t n, m;
	cin >> n >> m;
	priority_queue<int64_t> pq;
	for (int i = 0; i < n; i++) {
		int64_t a_in;
		cin >> a_in;
		pq.push(a_in);
	}

	for (int i = 0; i < m; i++) {
		int64_t max = pq.top();
		max /= 2;
		pq.pop();
		pq.push(max);
	}

	int64_t sum = 0;
	for (int i = 0; i < n; i++) {
		sum += pq.top();
		pq.pop();
	}
	cout << sum << endl;
}


Measured memory_bytes: 1400
using System;

namespace abc055_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 0, y = 0, N = 0;
            N = Convert.ToInt32(Console.ReadLine());
            x = N * 800;
            y = (N / 15) * 200;
            Console.WriteLine(x - y);
        }
    }
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++)
  {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()),d.end());
  cout << d.size() << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

class UFT {
private:
  vector<int> data, rnk;

public:
  UFT(int size)
    : data(size), rnk(size) {
    iota(all(data), 0);
  }

  int root(int x) {
    return data[x] == x ? x : data[x] = root(data[x]);
  }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    if (rnk[a] < rnk[b]) swap(a, b);
    data[b] = a;
    if (rnk[a] == rnk[b]) rnk[a]++;
  }
};

void solve() {
  int n, q;
  cin >> n >> q;
  UFT uft(n);
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) {
      cout << (uft.root(x) == uft.root(y)) << endl;
    } else {
      uft.unite(x, y);
    }
  }
}

Measured memory_bytes: 3212
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	int res = 1;
	int min = 100000000;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = abs(a * 1000 - (t * 1000 - h[i - 1] * 6));
		if (min > ans) {
			min = ans;
			res = i;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  vector<bool> used(N, false);
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (!used[i]){
      used[i] = true;
      ans++;
      queue<int> Q;
      Q.push(i);
      while (!Q.empty()){
        int v = Q.front();
        Q.pop();
        for (int w : E[v]){
          if (!used[w]){
            used[w] = true;
            Q.push(w);
          }
        }
      }
    }
  }
  cout << ans - 1 << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> X(N);
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        vec[i] = X[i];
    }
    sort(vec.begin(), vec.end());
    vector<int> ans(N);

    for (int i = 0; i < N; i++) {
        if (X[i] <= vec[(N/2)-1]) ans[i] = vec[N/2];
        else if (X[i] >= vec[N/2]) ans[i] = vec[(N/2)-1];
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4608
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;



char buffer[1000];
int str2int(int s,int t){
    int ret = 0;
    for (int i = s; i < t; ++i)
        ret = ret*10 + (buffer[i]-'0');
    return ret;
}

int main(){
    int64 A;
    cin >> A >> buffer;
    int idx = 0;
    while(buffer[idx] != '.')    ++idx;
    int n = strlen(buffer);
    int B = str2int(0,idx);
    int C = str2int(idx+1,n);
    int64 ans = A*B+A*C/100;
    printf("%lld\n",ans);
}


Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		long N=scan.nextLong();
		long K=scan.nextLong();
		long min=N;
		N=N%K;
		min=N;
		while(min>Math.abs(N-K)){
			N=Math.abs(N-K);
			min=Math.min(min,N);
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 23252