akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> cnt(n+1);
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        cnt[a]++;
    }
    vector<ll> v;
    rep(i,0,n+1){
        if(cnt[i])v.emplace_back(cnt[i]);
    }
    sort(all(v));
    ll m = v.size();
    vector<ll> sum(m+1);
    rep(i,0,m) sum[i+1] = sum[i] + v[i];

    auto c = [&](ll x, ll k){
        ll id = upper_bound(all(v), x) - v.begin();
        ll num = min(id, m);
        ll temp = sum.back();
        temp -= sum[m] - sum[id];
        temp += x * (m-id);
        return temp >= k * x;
    };

    rep(k,1,n+1){
        ll ok = 0, ng = n/k+1;
        while(abs(ok - ng) > 1){
            ll x = (ok + ng) / 2;
            if(c(x, k))ok = x;
            else ng = x;
        }
        cout << ok << "\n";
    }

}

Measured memory_bytes: 10176
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K, S;
  cin>>N>>K>>S;
  ll ans[N];
  if(S==1e9) {
    for(int i=0;i<N;++i) {
      if(i<K) ans[i] = S;
      else ans[i] = 1;
    }
  }
  else {
    for(int i=0;i<N;++i) {
      if(i<K) ans[i] = S;
      else ans[i] = S+1;
    }
  }
  for(int i=0;i<N;++i) cout<<ans[i]<<" ";
  cout<<endl;
}



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

int main() {
  char c;
  cin >> c;
  
  string v = "aeiou";
  int is_vowel = 0;
  // ここにプログラムを追記
  for(int i=0; i<v.size(); i++) {
    if(v.at(i) == c) {
        is_vowel = 1;
        break;
    }
  }
  
  if (is_vowel) {
      cout << "vowel";
  } else {
      cout << "consonant";
  }
  cout << endl;

    
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	int a,b,nagasa,menseki;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		menseki = a*b;
		nagasa = a*2+b*2;
		System.out.print(menseki+" "+nagasa);
		System.out.println();
	}
	
    public static void main(String args[]){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17156
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
char str[1000];
int main()
{
    int a, b;
    cin >> a >> b;
    cin >> str;
    int len = strlen(str);
    bool ok = true;
    for(int i = 0; i < len; i++)
    {
        if(i < a)
        if(str[i] < '0' || str[i] > '9')
        ok = false;
        if(i == a && str[i] != '-')ok = false;
        if(i > a)
        if(str[i] < '0' || str[i] > '9')
        ok = false;
    }
    if(len != a+b+1)ok = false;
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma") 
using namespace std;

int main(int argc, char const *argv[])
{
	int k; string s; cin >> k >> s;
	if(k>=s.size()) cout << s;
	else cout << s.substr(0,k) + "...";		
	return 0;
}

Measured memory_bytes: 3560
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        char[][] a = new char[H][W];

        for (int i = 0; i < H; i++) {
            a[i] = sc.next().toCharArray();
        }

        char[][] A = new char[H + 2][W + 2];


        for (int i = 0; i < H + 2; i++) {
            for (int j = 0; j < W + 2; j++) {
                char ch = 0;
                if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
                    ch = '#';
                } else {
                    ch = a[i - 1][j - 1];
                }
                A[i][j] = ch;
            }
        }

        for (int i = 0; i < H + 2; i++) {
            System.out.println(new String(A[i]));
        }


        return;
    }

}

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

int main(){
	int N, X;
	cin >> N >> X;
	vector<int> D(N+1);
	D[0]=0;
	int x;
	for(int i=0; i<N; i++){
		cin >> x;
		D[i+1] = D[i]+x;
	}
	int count=0;
	for(int i=0; i<=N; i++){
		if(D[i]<=X){
			count++;
		}
	}
	cout << count<< endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    from itertools import accumulate
    n, *a = map(int, open(0).read().split())
    m = 10 ** 9 + 7
    *acm, = accumulate(a)
    ans = 0
    for i in range(n):
        rem = acm[-1] - acm[i]
        ans += rem * a[i]
        ans %= m

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31780
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char S[100001];

    scanf("%s", S);

    int len = strlen(S);

    int ans = 0;

    for(int i = 1; i < len; i++){
        if(S[i] != S[i-1]){
            ans++;
        }
    }

    printf("%d\n", ans);

    return 0;
}

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

const long double PI = 3.14159265358979;

struct Point {
	long double px, py;
};

Point Minus(Point p1, Point p2) {
	return Point{ p2.px - p1.px, p2.py - p1.py };
}
long double arg(Point p1, Point p2) {
	// p1 -> p2
	Point V = Minus(p2, p1);
	if (fabs(V.py) < 1e-10 && V.px > 0) return 0.0L;
	if (fabs(V.py) < 1e-10 && V.px < 0) return PI;
	if (V.py > 0) {
		long double E = V.px / sqrtl(V.px * V.px + V.py * V.py);
		return acos(E);
	}
	if (V.py < 0) {
		long double E = V.px / sqrtl(V.px * V.px + V.py * V.py);
		return 2.0L * PI - acos(E);
	}
}

long double dist(Point p1, Point p2) {
	Point V = Minus(p2, p1);
	return sqrtl(V.px * V.px + V.py * V.py);
}

Point p1, p2, p3; long double c1, c2, c3;

int main() {
	cin >> p1.px >> p1.py >> p2.px >> p2.py >> p3.px >> p3.py;

	long double v1a = arg(p1, p2), v1b = arg(p1, p3); c1 = min(abs(v1a - v1b), 2.0L * PI - abs(v1a - v1b));
	long double v2a = arg(p2, p1), v2b = arg(p2, p3); c2 = min(abs(v2a - v2b), 2.0L * PI - abs(v2a - v2b));
	long double v3a = arg(p3, p1), v3b = arg(p3, p2); c3 = min(abs(v3a - v3b), 2.0L * PI - abs(v3a - v3b));

	long double L1 = dist(p1, p2), I1 = 1.0L / tan(0.5L * c1), I2 = 1.0L / tan(0.5L * c2), S1 = L1 / (2.0L + I1 + I2);
	long double L2 = dist(p2, p3), J1 = 1.0L / tan(0.5L * c2), J2 = 1.0L / tan(0.5L * c3), S2 = L2 / (2.0L + J1 + J2);
	long double L3 = dist(p3, p1), K1 = 1.0L / tan(0.5L * c3), K2 = 1.0L / tan(0.5L * c1), S3 = L3 / (2.0L + K1 + K2);
	printf("%.15Lf\n", max({ S1, S2, S3 }));
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=50005;
const int MAXM=100005;
int n,m,T;
namespace solve2
{
	struct edge{int x,y;}E[MAXM];
	int nx[5],cnt[5],ans[MAXM];
	void main()
	{
		if(n==2){pr2(-1);return ;}
		for(int i=1;i<=m;i++)E[i].x=read(),E[i].y=read();
		nx[1]=1;nx[2]=2;nx[3]=3;
		for(int i=m;i>=1;i--)
		{
			if(E[i].x<=3&&E[i].y<=3)
			{
				if(nx[E[i].x]==nx[E[i].y])ans[i]=1;
				else
				{
					memset(cnt,0,sizeof(cnt));
					for(int j=1;j<=3;j++)++cnt[nx[j]];
					if(cnt[nx[E[i].x]]>cnt[nx[E[i].y]])ans[i]=0,nx[E[i].x]=nx[E[i].y];
					else ans[i]=1,nx[E[i].y]=nx[E[i].x];
				}
			}
			else if(E[i].x<=3)ans[i]=1;
		}
		for(int i=1;i<=m;i++)putchar(ans[i]?'^':'v');puts("");
	}
}
namespace solve1
{
	bitset<MAXN> a[MAXN],tmp;
	struct edge{int x,y;}E[MAXM];
	int id[MAXN],ans[MAXM];
	void solve(int u)
	{
		id[u]=1;
		for(int i=m;i>=1;i--)
		{
			if((id[E[i].x]&id[E[i].y])||!(id[E[i].x]|id[E[i].y]))continue;
			if(id[E[i].x])ans[i]=1;id[E[i].x]|=1;id[E[i].y]|=1;
		}
		for(int i=1;i<=m;i++)putchar(ans[i]?'^':'v');puts("");
	}
	void main()
	{
		for(int i=1;i<=m;i++)E[i].x=read(),E[i].y=read();
		for(int i=1;i<=n;i++)a[i][i]=1;
		for(int i=m;i>=1;i--)a[E[i].x]=a[E[i].y]=a[E[i].x]|a[E[i].y];
		for(int i=1;i<=n;i++)tmp[i]=1;
		for(int i=1;i<=n;i++)tmp=tmp&a[i];
		if(!tmp.count()){pr2(-1);return ;}
		for(int i=1;i<=n;i++)if(tmp[i]){solve(i);return ;}
	}
}
int main()
{
	n=read();m=read();T=read();
	if(T==2){solve2::main();return 0;}
	else solve1::main();
	return 0;
}


Measured memory_bytes: 307328
n = int(input())
candidate = {}

for i in range(n):
    s = str(input().split())
    if s not in candidate.keys():
        candidate[s] = 1
    else:
        candidate[s] += 1

ans = 0
for v in candidate.values():
    if v % 2 == 0:
        continue
    else:
        ans += 1

print(ans)

Measured memory_bytes: 17888
#include <iostream>
using namespace std;
int main(void) {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;

  if (A >= K) {
    cout << K << endl;
    return 0;
  }

  if ((A+B) >= K) {
    cout << A << endl;
    return 0;
  }

  K -= (A+B);
  cout << A-K << endl;
  return 0;
}


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

int main(){
    int n;
    vector<int> A;
    cin >> n;
    A.resize(n);
    for(int i = 0; i < n; i++)cin >> A[i];

    int res = 0;
    for(int i = 0; i < n; i++){
        if (res+1 == A[i])res++;
    }
    int ans = -1;
    if (res > 0)ans = n- res;
    cout << ans << endl;
    return 0;
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    str s;
    char ans;
    rep(i,0,3){
        cin >> s;
        if(i==1){
            ans=s[0];
        }
    }
    cout << "A" << ans << "C" << endl;
    return 0;
}




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

using namespace std;

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

    vector<int> t;
    t.reserve(10000);
    int count = 0;

    int in;

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> in;
        t.push_back(in);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> in;
        for (const int& v : t) {
            if (in == v) {
                count += 1;
                break;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B;
  cin >> A >> B;

  if((A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0))
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  
  return 0;
}


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

int main() {
    int ans = 0;
    string s;
    cin >> s;
    for(int i = 0;i<s.size();i++){
        for(int j = i;j<s.size();j++){
            bool flag = true;
            for(int k = i;k<=j;k++){
                if(s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T')flag = false;
            }
            if(flag && j-i+1 > ans)ans = j-i+1;
        }
    }
    cout << ans;
    return 0;
} 

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

from collections import defaultdict, Counter
from math import pi, sqrt
from bisect import bisect_left, bisect_right

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

a = sorted(a)
b = sorted(b)
c = sorted(c)

cnt = 0
for bi in b:
    alen = bisect_left(a, bi)
    clen = bisect_right(c, bi)
    if alen > 0 and clen < len(c):
        cnt += alen * (n - clen)

print(cnt)

Measured memory_bytes: 23520
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int x = sc.NextInt();
        int y = sc.NextInt();


        var ans = new int[n - 1];
        for (int i = 1; i < n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                long a = j - i;
                long b = Math.Abs(x - i) + 1 + Math.Abs(y - j);
                long c = Math.Abs(y - i) + 1 + Math.Abs(x - j);
                long dist = Math.Min(a, Math.Min(b, c));
                ans[dist - 1]++;
            }
        }

        Console.WriteLine(string.Join("\n", ans));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <list>
#include <vector>
#include <map>

using namespace std;


int main(void) {
	int n, a = 0;
	cin >> n;

	for (int i = 0; i < n; i++) a += i + 1;
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = to - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

struct Point {
  int x;
  int y;
};

double dist(Point from, Point to) {
  int dx = to.x - from.x;
  int dy = to.y - from.y;

  double dist = sqrt(dx * dx + dy * dy);
  return dist;
}

int main() {
  int n;
  V<Point> grid;
  cin >> n;
  grid.resize(n);

  rep(i, n) {
    cin >> grid[i].x >> grid[i].y;
  }
  V<int> p(n, 0);
  rep(i, n) {
    p[i] = i;
  }

  double len = 0;
  int count = 0;

  do {
    rep(i, n - 1) {
      int from = p[i];
      int to = p[i + 1];
      len += dist(grid[from], grid[to]);
    }
    count++;
  } while(next_permutation(p.begin(), p.end()));

  double ans = len / count;

  printf("%.9f\n", ans);
}


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

	public static class unionfind{
		int[] parent;
		int[] rank;
		int[] size;
		public unionfind(int n){
			this.parent = new int[n+1];
			this.rank = new int[n+1];
			this.size = new int[n+1];
			for(int i = 1; i <= n; i++) set(i);
		}
		public void set(int i) {
			parent[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
		public int find(int i) {
			if (i == parent[i])
				return parent[i];
			else
				return parent[i] = find(parent[i]);
			
		}
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
		public void unite(int x, int y) {
			int xroot = find(x);
			int yroot = find(y);
			if(xroot == yroot)
				return;
			if(rank[xroot] > rank[yroot]) {
				parent[yroot] = xroot;
				size[xroot] += size[yroot];
			}
			else if(rank[xroot] < rank[yroot]) {
				parent[xroot] = yroot;
				size[yroot] += size[xroot];
			}
			else {
				parent[yroot] = xroot;
				size[xroot] += size[yroot];
				rank[xroot]++;
			}
		}
		public int getsize(int i) {
			return size[find(i)];
		}
		public int groupnum() {
			Set<Integer> parents = new HashSet<>();
			for(int i = 1; i < this.parent.length; i++)
				parents.add(find(i));
			return parents.size();
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		unionfind u = new unionfind(N);
		int ans = 0;
		for(int i = 0; i < M; i++) {
			u.unite(sc.nextInt(), sc.nextInt());
			sc.nextInt();
		}
		System.out.println(u.groupnum());

	}

}

Measured memory_bytes: 92796
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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 <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, M;
  cin >> N >> M;

  vector<P> p;
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    p.pb({a, b});
  }

  SORT(p);

  ll ans = 0;
  ll count = 0;
  rep(i, N) {
    P pp = p[i];
    rep(j, pp.second) {
      ans += pp.first;
      count++;
      if (count == M) {
        COUT(ans);
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 2420
program jss;
var
    n, i, AC, WA, TLE, RE : longint;
    s : ansistring;
begin
    readln(n);
    AC := 0;
    WA := 0;
    TLE := 0;
    RE := 0;
    for i := 1 to n do begin
        readln(s);
        if s = 'AC' then
            AC += 1
        else if s = 'WA' then
            WA += 1
        else if s = 'TLE' then
            TLE += 1
        else if s = 'RE' then
            RE += 1;
    end;
    writeln('AC x ', AC);
    writeln('WA x ', WA);
    writeln('TLE x ', TLE);
    writeln('RE x ', RE);
end.

Measured memory_bytes: 1388
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  ls <- map read . lines <$> getContents
  sequence_ $ reverse $ snd $ foldl f ([],[]) ls
  where
    f ([], acs) v
      | v /= 0 = ([v], acs)
    f (xss@(x:xs), acs) v
      | v == 0    = (xs, print x : acs)
      | otherwise = (v:xss, acs)

Measured memory_bytes: 3880
// DPL1_C
#include <bits/stdc++.h>
#define endl "\n"
#define _GLIBCXX_DEBUG //配列外参照エラー表示,gcc依存
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

vector<int> val(110);
vector<int> wei(110);
vector<vector<ll>> dp(110,vector<ll>(10010,0));
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,w;
    cin>>n>>w;
    for(int i=1;i<=n;i++) cin>>val[i]>>wei[i];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(0<=j-wei[i]) dp[i][j]=max({dp[i-1][j],dp[i][j-wei[i]]+val[i]});
            else dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
    }
    cout<<dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 11888
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int a = 0;
	int b = 0;
	while (1)
	{
		cin >> a >> b;
		if (a == 0 && b == 0)
		{
			break;
		}
		int e = 0;
		double c[1000];
		double d[1000];
		for (int i = 0; i < a; i++)
		{
			cin >> c[i];
		}
		for (int i = 0; i < b; i++)
		{
			cin >> d[i];
		}
		for (int i = 0; i < b; i++)
		{
			e += d[i];
			if (e + 1 >= a)
			{
				cout << i + 1 << endl;
				break;
			}
			e += c[e];
			if (e + 1 >= a)
			{
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3136
x,k,d=map(int,input().split())
x =abs(x)
o =x//d
if (x-d*k) >=0:
    print(x-d*k)
    exit()
else:
    if (k-o)%2==0:
        print(abs(x%d))
        exit()
    else:
        print(abs(x%d-d))
        exit()

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


int main()
{
	string X;
	cin>>X;
	int N=X.size();
	int s=0;
	int dec=0;
	rep(i,N)
	{
		if(X[i]=='S')
		{
			s++;
		}
		else
		{
			if(s>0) 
			{
				dec++;
				s--;
			}
		}
	}
	cout<<N-dec*2<<endl;
	return 0;
}


Measured memory_bytes: 3720
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(c-(a-b)>=0){
        cout<<c-(a-b)<<endl;
    }
    
    else if(c-(a-b)<0){
        cout<<0<<endl;
    }

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var m, f, r int8
	for {
		fmt.Scanln(&m, &f, &r)
		if m == -1 && f == -1 && r == -1 {
			break
		}
		switch {
		case m == -1 || f == -1:
			fmt.Println("F")
		case m+f >= 80:
			fmt.Println("A")
		case m+f >= 65:
			fmt.Println("B")
		case m+f >= 50 || (m+f >= 30 && r >= 50):
			fmt.Println("C")
		case m+f >= 30:
			fmt.Println("D")
		default:
			fmt.Println("F")
		}
	}
	return
}



Measured memory_bytes: 1128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int>l(n);
  rep(i,n)cin>>l[i];
  sort(l.begin(),l.end());

  int ans = 0;
  rep(i,n-2)rep(j,n-1){
    if(i>=j)continue;
    int a = l[i], b = l[j];
    auto itr = lower_bound(l.begin(),l.end(),a+b);
    ans += n-1-j - (l.end() - itr);
  }
  cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    int sum = 0;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        sum |= a;
    }
    int cnt = 0;
    while((sum&1) == 0){
        cnt++;
        sum >>= 1;
    }
    cout << cnt << endl;
}

int min(int a,int b){
    if(a-b>0) return b;
    return a;
}

int max(int a,int b){
    if(a-b>0) return a;
    return b;
}

int gcd(int a,int b){
    if(a<b) return gcd(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char n;
  scanf("%c",&n);
  if(n=='A'){
    printf("T\n");
  }else if(n=='C'){
    printf("G\n");
  }else if(n=='G'){
    printf("C\n");
  }else{
    printf("A\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    int n;
    int m;
    
    scanf("%d", &n);
    scanf("%d", &m);
    
    int l = 1;
	int r = n;
	
	for (int i = 1; i <= m; i++) {
		int tl;
		int tr;
		scanf("%d", &tl);
		scanf("%d", &tr);
        
		if (l < tl) l = tl;
		if (tr < r) r = tr;
	}
	
	if (r < l) {
		printf("0\n");
	} else {
		printf("%d", r - l + 1);
	}

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
using namespace std;
using ll =long long;

int main (void) {
  int N,D,X;
  cin >> N >> D >>X;
  int ans=0;
  int a,b;
  for (int i=0; i<N; i++) {
    cin >> a;
    int count=0;
    do{
      ans++;
      count++;
      b=1+a*count;
    } while(D>=b);
  }
  cout << ans+X;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}

void solve() { 
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)
		cout << "bust";
	else
		cout << "win";
}



Measured memory_bytes: 256
#test.py
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)


K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
                ans += gcd(i,j,k)

print(ans)
#メモ化再帰で高速化できないか考える
# Kまでの数の組み合わせを考える





Measured memory_bytes: 69768
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9 + 7;
function abmod(){for(var a=arguments,r=a[0],i=1;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}
var fac=[1,1];
function fSet(n){for(var i=2;i<=n;)fac[i]=abmod(fac[i-1],i++);}
function modinv(a){for(var b=mod,u=1,v=0,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function nCrmod(n,r){return abmod(fac[n],modinv(abmod(fac[r],fac[n-r])));}

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var b = n-k+1;
  var ans = [];
  fSet(2*n+1);
  for(var i = 1; i <= k; i++){
    if(b < i)ans.push(0);
    else{
      var t = nCrmod(b,i);
      t = abmod(t, nCrmod(k-1,i-1));
      ans.push(t);
    }
  }
  return ans.join("\n");
}

Measured memory_bytes: 8340
def main
  n, k = gets.split.map(&:to_i)

  trees = Array.new(n)
  n.times do |i|
    h = gets.chomp.to_i
    trees[i] = h
  end

  trees.sort!
  # puts trees

  min_d = 2**32
  0.upto(n-k) do |i|
    d = trees[i+k-1] - trees[i]
    min_d = d if d < min_d
  end

  puts min_d
end

if __FILE__ == $0
  main
end


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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}

using namespace std;

vector<ll>r,g,b;
int main() 
{	
	fast;
	ll n; cin>>n;
	string s; cin>>s;
	r.clear(); g.clear(); b.clear();
	for(ll i = 0; i < s.size(); i++)
	{
		if(s[i] == 'R') r.push_back(i+1);
		else if(s[i] == 'G') g.push_back(i+1);
		else b.push_back(i+1);
	} 
	ll ans = r.size() * g.size() * b.size();
	ll i,j,k;
	for( i = 0 ; i < r.size() ; i++)
    {
        for( j = 0 ; j < g.size() ; j++ )
        {
            for( k = 0 ; k < b.size() ; k++)
            {
                if(2*r[i]==g[j]+b[k] || 2*g[j]==r[i]+b[k] || 2*b[k]==r[i]+g[j])ans--;
            }
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL N;
	VI X(5);
	cin >> N >> X[0] >> X[1] >> X[2] >> X[3] >> X[4];
	LL minpos = 0;
	LL minval = X[0];
	REP(i, 5) {
		if (X[i] < minval) {
			minval = X[i];
			minpos = i;
		}
	}
	LL val = N / minval;
	if (N % minval != 0) {
		val++;
	}
	cout << val + 4 << endl;
	
    return 0;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
list($t, $a) = explode(" ", trim(fgets(STDIN)));
$hArray = explode(" ", trim(fgets(STDIN)));

$dmin = 100000;
$minPos = -1;
foreach($hArray as $i => $h){
    $diff = abs($t - 0.006 * $h - $a);
    if($diff < $dmin){
        $dmin = $diff;
        $minPos = $i;
    }
}
echo $minPos + 1;


Measured memory_bytes: 4984
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll gcd(ll a,ll b)
{
    if (a%b==0)
    {
        return(b);
    }
    else
    {
        return(gcd(b,a%b));
    }
}

int main() {

    ll N,X;
    cin >> N >> X;

    vector<ll> x;
    x.push_back(X);
    for (int i = 0; i < N; ++i) {
        ll t;
        cin >> t;
        x.push_back(t);
    }
    sort(x.begin(),x.end());

    ll y = x[1] - x[0];
    for (int i = 2; i < N+1; ++i) {
        ll y2 = x[i] - x[i - 1];
        ll z = gcd(y, y2);
        y = z;
    }

    cout << y << endl;


    return 0;
}

Measured memory_bytes: 1400
l,r = map(int,input().split())
sub = r-l
l %= 2019
r %= 2019

if(sub >= 2019):
    print(0)
    exit()

mina = float('INF')

for x in range(l,l+sub+1):
    for y in range(x,l+sub+1):
        if(x==y):
            continue
        
        ans = (x * y) % 2019
        if(mina > ans):
            mina = ans
       
print(mina)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-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; }




int main() 
{
  ll N; cin>>N;
  vector<ll> table(10000000,INF);
  table.at(0)=0;
  rep(i,N)
  {
    chmin(table.at(i+1),table.at(i)+1);
    for(int j=1;j<=7;j++)
    {
      chmin(table.at(i+pow(6,j)),table.at(i)+1);
    } 
    for(int j=1;j<=6;j++)
    {
      chmin(table.at(i+pow(9,j)),table.at(i)+1);
    } 
  }
  cout<<table.at(N)<<endl;
  /*
  rep(i,20)
  {
    if(i!=0) cout<<" ";
    cout<<table.at(i);
  }
  cout<<endl;
  */
  return 0;
}

Measured memory_bytes: 81436
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    int[] y = new int[n];
    int[] h = new int[n];
    int nx = 0;
    int ny = 0;
    int nh = 0;
    for(int i = 0; i < n; i++) {
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
      h[i] = sc.nextInt();
      if(h[i] != 0) {
        nx = x[i];
        ny = y[i];
        nh = h[i];
      }
    }
    int ansx = 0;
    int ansy = 0;
    int ansh = 0;
    for(int X = 0; X <= 100; X++) {
      for(int Y = 0; Y <= 100; Y++) {
        int high = nh + Math.abs(X - nx) + Math.abs(Y - ny);
        int p = 0;
        for(int i = 0; i < n; i++) {
          int s = Math.max(high - Math.abs(x[i] - X) - Math.abs(y[i] - Y), 0);
          if(s != h[i]) p = 1;
        }
        if(p == 0) {
          ansx = X;
          ansy = Y;
          ansh = high;
        }
      }
    }
    System.out.print(ansx);
    System.out.print(" ");
    System.out.print(ansy);
    System.out.print(" ");
    System.out.print(ansh);
  }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  rep(i,1,N+1){
    M=sqrt(i)+10;
    num=0;
    rep(j,1,M)rep(k,1,M){
      sum=i-(j*j+k*k+j*k);
      flag=0;
      int l=1;
      while((j+k+l)*l<=sum){
        if((j+k+l)*l==sum)flag=1;
        l++;
      }
      num+=flag;
    }
    Out(num);
  }
}

Measured memory_bytes: 3628
N=int(input())
A=list(map(int,input().split()))
absA=list(map(abs,A))

if 0 in A:
  print(sum(absA))
  exit()

m=list(filter(lambda x:x<0,A))

if len(m)%2==0:
  print(sum(absA))
else:
  print(sum(absA)-2*min(absA))

Measured memory_bytes: 14224
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d= sc.nextInt();
        int x = (b+c-1)/b;
        int y = (d+a-1)/d;
        if(x<=y){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35736
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] B = new long[(int)(N-1)];
        for(int i = 0 ; i < N-1 ; i++){
                B[i] = sc.nextLong();
        }
        solve(N, B);
    }

    static void solve(long N, long[] B){
        long ans = 0;
        ans += B[0];
        for (int i = 1; i < B.length; i++) {
            ans += Math.min(B[i], B[i-1]);
        }
        ans += B[B.length - 1];
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include<iostream>

using namespace std;

int main(){
  int n,c;
  int sum[1000];
  sum[0]=1;
  for(int i=1;i<1000;i++){
    sum[i]=sum[i-1]+i+1;
  }
  while (1){
    cin >> n;
    if (n==0) return 0;
    c=0;
    for (int i=2;i<=1000;i++) {//i????????£?¶?????????´??°
      if (i>=n) break;
      for(int j=1;j<=1000-j+1;j++){
        if (j>=n) break;
        if (j==1){
          if (sum[i-1]==n)c++;
        }
        else if(i+j-1<=n && sum[j+i-2]-sum[j-2]==n){
          c++;
        }
      }
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3044
L,R = map(int,input().split())
if R-L > 673 or (L%2019) > (R%2019):
  print(0)
else:
  l = L%2019
  r = R%2019
  c = 2018
  w = set()
  for i in range(l,r):
    for j in range(i+1,r+1):
      t = (i*j)%2019
      if c > t:
        c = t
  print(c)

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

signed main(void)
{
	int n; 
	cin >> n;
	long long ans, tmp;
	vector<int> a(n);
	vector<P> out;
	bool plus[n];

	rep(i, n) cin >> a[i];
	sort(a.rbegin(), a.rend());	
	plus[0] = true;
	plus[n - 1] = false;
	for(int i = 1; i < n - 1; i++)
	{
		if (a[i] < 0)
			plus[i] = false;
		else
			plus[i] = true;
	}

	ans = a[0];
	tmp = a[n - 1];
	for(int i = n - 2; i >= 1; i--)
	{
		if (plus[i])
		{
			out.push_back(P(tmp, a[i]));
			tmp -= a[i];
		}
	}
	for(int i = 1; i < n - 1; i++)
	{
		if (!plus[i])
		{
			out.push_back(P(ans, a[i]));
			ans -= a[i];
		}
	}
	out.push_back(P(ans, tmp));
	ans -= tmp;
	cout << ans << endl;
	rep(i, out.size()) 
		printf("%d%c%d%c", out[i].first, ' ', out[i].second, '\n');
	return 0;
}


Measured memory_bytes: 3316
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n,r;
    cin>>n>>r;
    if(n>9){
        cout<<r<<endl;
        return 0;
    }
    int ans=r+1000-100*n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main() {
  int n; cin >> n;
  set<int> st;
  for(int i=0;i<n;i++){
    int a; cin >> a;    
    st.insert(a);
  }
  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    double a,b,t;
    cin >> a >> b >> t;
    t = t / 180.0 * M_PI;
    double L = a+b+sqrt((a-b*cos(t))*(a-b*cos(t))+b*b*sin(t)*sin(t));
    printf("%.8f\n%.8f\n%.8f\n",1.0/2.0*a*b*sin(t),L,b*sin(t));
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i,n) for (long long i=0; i<(long long)(n); i++)
using Graph = vector<vector<int>>;
using ll = long long;


int main() {
    int k;
    cin>>k;
    ll sum=0;
    rep(i,k){
        int a=i+1;
        rep(j,k){
            int b=j+1;
            rep(l,k){
                int c=l+1;
                int p=min(a,min(b,c));
                while(p>0){
                    if(a%p==0){
                        if(b%p==0){
                            if(c%p==0){
                                sum+=p;
                                break;
                            }
                        }
                    }
                    p--;
                }
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e4;
const ll inf = 1e9+7;
ll arr[MAX];
int main() {
	fastio;
	ll n,cont=0;
	cin>>n;
	f(x,1,105){
		f(y,1,105){
			f(z,1,105){
				ll aux = x*x+z*z+y*y+x*y+z*y+x*z;
				if(aux<=n) arr[aux]++;
			}
		}
	}
	f(i,1,n+1){
		cout<<arr[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3576
# 0:a, b, c, a-b
# 1:b+c, a+c, a+b, b-a
# 2:2a+b+c, a+2b+c, a+b+2c, a-b
# 3:2a+3b+3c, 3a+2b+3c, 3a+3b+2c, b-a
# 4:6a+5b+5c, 5a+6b+5c, 5a+5b+6c, a-b
A, B, C, K = [int(x) for x in input().strip().split()]
ans = (A-B)*(-1)**(K%2)
if ans > 10 ** 18:
  print('Unfair')
else:
  print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    public static class Program
    {
        public static List<int> list = new List<int>();

        static void Main(string[] arg)
        {

            var input = GetIntList(Console.ReadLine());
            var answer = 0;
            int a = input[0];
            int b = input[1];
            for(int i = 0; i < 2; i++)
            {
                if (a > b)
                {
                    answer += a;
                    a--;
                }
                else
                {
                    answer += b;
                    b--;
                }
            }

            

            Console.WriteLine(answer);




        }
        
        #region libraries
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();

        }
        private static double[] GetDoubleList(string line)
        {
            return line.Split(' ').Select(x => double.Parse(x)).ToArray();

        }
        private static ulong[] GetUlongList(string line)
        {
            return line.Split(' ').Select(x => ulong.Parse(x)).ToArray();
        }
        private static long[] GetLongList(string line)
        {
            return line.Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        private static int SearchNearest(this IEnumerable<int> list, int target)
        {
            var min = list.Min(c => Math.Abs(c - target));
            return list.First(c => Math.Abs(c - target) == min);
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
        #endregion
    }
}


Measured memory_bytes: 13268