akhauriyash/Code-Regression huggingface dataset:
from sys import stdin

class Vector:
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    def __mul__(self, k):
        return Vector(self.x * k, self.y * k)

    def __gt__(self, other):
        return self.x > other.x and self.y > other.yb

    def __lt__(self, other):
        return self.x < other.x and self.y < other.yb

    def __eq__(self, other):
        return self.x == other.x and self.y == other.y

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    # usually cross operation return Vector but it returns scalor
    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

class Point(Vector):
    def __init__(self, *args, **kargs):
        return super().__init__(*args, **kargs)

class Segment:
    def __init__(self, p1=Point(0, 0), p2=Point(1, 1)):
        self.p1 = p1
        self.p2 = p2

def get_cross_point(s1, s2):
    base = s2.p2 - s2.p1
    hypo1 = s1.p1 - s2.p1
    hypo2 = s1.p2 - s2.p1
    d1 = abs(base.cross(hypo1))
    d2 = abs(base.cross(hypo2))
    t = d1 / (d1 + d2)
    return s1.p1 + (s1.p2 - s1.p1) * t

def read_and_print_results(n):
    for _ in range(n):
        line = stdin.readline().strip().split()
        p0 = Vector(int(line[0]), int(line[1]))
        p1 = Vector(int(line[2]), int(line[3]))
        p2 = Vector(int(line[4]), int(line[5]))
        p3 = Vector(int(line[6]), int(line[7]))
        s1 = Segment(p0, p1)
        s2 = Segment(p2, p3)
        p = get_cross_point(s1, s2)
        print("{0:0.10f} {1:0.10f}".format(p.x, p.y))

n = int(input())
read_and_print_results(n)


Measured memory_bytes: 5712
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
int main(){
    ll h,w;
    cin>>h>>w;
    char input[h][w];
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
           cin>>input[i][j];
        }
    }
    ll output[h][w] = {0};
    memset(output,0,sizeof(output));
    ll i=0;
    for(i=0;i<w;i++){
        if(input[0][i] == '.'){
            output[0][i] = 1;
        }
        else{
            break;
        }
    }
    for(;i<w;i++){
        output[0][i] = 0;
    }
    

    ll j = 0;
    for(j = 0;j<h;j++){
        if(input[j][0] == '.'){
            output[j][0] = 1;
        }
        else{
            break;
        }
    }
    for(;j<h;j++){
        output[j][0] = 0;
    }
    for(ll i=1;i<h;i++){
        for(ll j=1;j<w;j++){
            if(input[i][j] == '#'){
                output[i][j] = 0;
                continue;
            }
            else{
                output[i][j] = (output[i][j-1] + output[i-1][j]) % MOD;
            }
        }
    }
    cout<<output[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 12428
<?php
list($a, $b) = ints();
echo $a % 3 === 0 || $b % 3 === 0 || ($a + $b) % 3 === 0 ? 'Possible' : 'Impossible';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    for (;;) {
        int d, e; cin >> d >> e;
        if (!d) break;

        double bestans = 1e9;
        int besti = -1;

        for (int i = 0; i <= d; i++) {
            double dist = abs(sqrt(i * i + (d - i) * (d - i)) - 1.0 * e);
            if (dist < bestans) {
                bestans = dist;
                besti = i;
            }
        }

        cout << bestans << endl;
    }
}


Measured memory_bytes: 3264
#include <stdio.h>
#include <iostream>
#include <cstdlib>
using namespace std;

struct Node {
    int key;
    Node *left,*right,*parent;
};

Node *gRoot,*NIL;

Node *find(Node* u,int value){
    while(u != NIL && value != u->key){
        if(value < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int value){
    Node *y = NIL;
    // 親
    Node *x = gRoot;
    // 自身
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = value;
    z->left = NIL;
    z->right = NIL;
    
    // rootから自身を挿入する場所を探す
    while(x != NIL){
        // rootから検索
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    // 親に子を持たせる
    if(y == NIL){
        gRoot = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}
// 先行順巡回
void preOrder(Node *u){
    if(u == NIL)return;
    printf(" %d",u->key);
    preOrder(u->left);
    preOrder(u->right);
}

// 中間順巡回
void inOrder(Node *u){
    if(u == NIL)return;
    inOrder(u->left);
    printf(" %d",u->key);
    inOrder(u->right);
}

int main(){
    int n,x;
    string com;
    
    cin >> n;
    for(int i = 0;i < n;++i){
        cin >> com;
        if(com[0] == 'f'){
            cin >> x;
            Node *t = find(gRoot,x);
            if(t != NIL) cout << "yes\n";
            else cout << "no\n";
        }
        if(com == "insert"){
            cin >> x;
            insert(x);
        }
        else if(com == "print"){
            inOrder(gRoot);
            cout << "\n";
            preOrder(gRoot);
            cout << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 22008
package main

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

var (
	H, W, K    int
	black, red [][]bool
)

func main() {
	defer writer.Flush()
	readVariables()
	var answer int
	for br := 0; br < 1<<H; br++ {
		for bc := 0; bc < 1<<W; bc++ {
			clearRed()
			for i := 0; i < H; i++ {
				if 1<<i&br > 0 {
					setRowRed(i)
				}
			}
			for j := 0; j < W; j++ {
				if 1<<j&bc > 0 {
					setColRed(j)
				}
			}
			k := count()
			if k == K {
				answer++
			}
		}
	}
	println(answer)
}

func count() int {
	var result int
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if black[i][j] && !red[i][j] {
				result++
			}
		}
	}
	return result
}

func setRowRed(i int) {
	for j := 0; j < W; j++ {
		red[i][j] = true
	}
}
func setColRed(j int) {
	for i := 0; i < H; i++ {
		red[i][j] = true
	}
}

func clearRed() {
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			red[i][j] = false
		}
	}
}

func readVariables() {
	H, W, K = nextInt(), nextInt(), nextInt()
	black = make([][]bool, H)
	red = make([][]bool, H)
	for i := 0; i < H; i++ {
		black[i] = make([]bool, W)
		red[i] = make([]bool, W)
	}
	for i := 0; i < H; i++ {
		row := nextStr()
		for j := 0; j < W; j++ {
			black[i][j] = row[j] == '#'
		}
	}
}

/* Template */

var (
	scanner *bufio.Scanner
	writer  *bufio.Writer
)

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
	writer = bufio.NewWriterSize(os.Stdout, Max)
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


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

int main(void){
    int n;
    cin >> n;
    bool flag = 0;
    for(int j=1;j<=9;j++){
        for(int z=1;z<=9;z++){
            if(n==j*z){
                flag = 1;
                break;
            }
        }
    }
    if(flag==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout <<"No"<<endl;
    }
    
    
    return 0;
    
}


















































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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}


int main() {
   ll i,j;
   ll n,k;
   cin >>n>>k; 
   if(n>k)
   {
     n%=k;
   }


   cout<< min(n,k-n) <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_H 200001
int House[MAX_H];

// always x < y ex) 1 , 19   D:20 (1+20)-19
int GetDistance(int x, int y, int D)
{
	int dist = y - x;

	if (dist < 0)
		dist += D;

	return dist;
}

int main()
{
	#ifdef _WIN32
		freopen("input.txt", "r", stdin);
	#endif

	int K, N;
	scanf("%d %d", &K, &N);

	for (int n = 0; n < N; n++)
		scanf("%d", &House[n]);
	
#ifdef _WIN32
	printf("input : %d %d\n", K, N);
	for (int n = 0; n < N; n++)
		printf("%d ", House[n]);
	printf("\n");
#endif

	int Result = 0;
	for (int i = 0; i < N; i++)
	{
		int temp = GetDistance(House[i], House[(i + 1) % N], K);
		if (Result < temp)
			Result = temp;
	}

	printf("%d", K- Result);

	return 0;
}







Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>
#include <math.h>
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using namespace std;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int n;
    
    string tmp_a,tmp_f,tmp_s;
    int num_f,num_s;
    
    cin >> n;
    
    tmp_a = to_string(n);
    tmp_f = tmp_a.substr(0, 1);
    tmp_s = tmp_a.substr(tmp_a.length()-1, 1);
    
    num_f = stoi(tmp_f);
    num_s = stoi(tmp_s);
    //cout << num_f << num_s << endl;

    vector<vector<ll>> c(10, vector<ll>(10, 0));
    for(int i = 1; i <= n; ++i){
        int y = i % 10;
        if(y == 0)  continue;
        string s = to_string(i);
        //cout << s[0] << endl;
        int x = s[0] - '0';
        ++c[x][y];
        
    }
    ll res = 0;
    for(int i = 1; i < 10; ++i){
        for(int j = 1; j < 10; ++j){
            res += c[i][j] * c[j][i];
            //cout << c[i][j] << " "<< i << " " << j << endl;
        }
    }
    cout << res << endl;
}


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

const int M = 1e9+7;
int N, A, B, C, D;
void madd(int& a, int b) {
    a += b;
    if (a >= M) a -= M;
}
int mult(int a, int b) {
    return (1LL*a*b) % M;
}
int modexp(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b&1) res = mult(res,a);
        a = mult(a,a);
        b >>= 1;
    }
    return res;
}

int dp[1005][1005];
int ch[1005][1005];
int part[1005][1005];
int ifac[1005];

int main() {
    scanf("%d %d %d %d %d",&N,&A,&B,&C,&D);
    ifac[0] = 1;
    for (int i = 1; i <= N; i++) {
        ifac[i] = mult(ifac[i-1],modexp(i,M-2));
    }
    for (int i = 0; i <= N; i++) {
        ch[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            madd(ch[i][j],ch[i-1][j]);
            madd(ch[i][j],ch[i-1][j-1]);
        }
    }
    for (int j = 1; j <= N; j++) part[0][j] = 1;
    for (int n = 1; n <= N; n++) {
        for (int j = 1; j <= n; j++) {
            if (n % j == 0) {
                part[n][j] = mult(ch[n][j],part[n-j][j]);
                /*
                int x = mult(part[n][j],ifac[n/j]);
                //if (n == 3 && j == 1) {
                    printf("%d\n",x);
                    part[n][j] = x;
                    printf("[%d][%d]: %d\n",n,j,part[n][j]);
                    //printf("%d\n",x);
                //}
                */
            }
        }
    }
    for (int i = 0; i <= N+1; i++) dp[0][i] = 1;
    for (int i = B; i >= A; i--) {
        for (int n = 1; n <= N; n++) {
            dp[n][i] = dp[n][i+1];
            for (int j = C*i; n-j >= 0 && j <= D*i; j += i) {
                int ways = mult(ch[n][j],part[j][i]);
                ways = mult(ways,ifac[j/i]);
                //printf("%d\n",ways);
                madd(dp[n][i],mult(ways,dp[n-j][i+1]));
            }
        }
    }
    printf("%d\n",dp[N][A]);
}



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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b < c || d < a){
        cout << 0 << endl;
    }else if(a < c){
        cout << min(b-c, d-c) << endl;
    }else{
        cout << min(d-a, b-a) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  	var heights = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
    var max = 0;
  	var count = 0;
  	
  	heights.forEach((val) => {
      var h = parseInt(val);
      if (h >= max) {
        count++;
        max = h;
      }
    });
	//出力
	console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    if (s == "SAT") cout << 1;
    if (s == "FRI") cout << 2;
    if (s == "THU") cout << 3;
    if (s == "WED") cout << 4;
    if (s == "TUE") cout << 5;
    if (s == "MON") cout << 6;
    if (s == "SUN") cout << 7;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
	long long int N, sum = 0;
	scanf ("%lld", &N);
	
	for (int i=1; i<=N; i++){
		if (i % 3 != 0 && i % 5 != 0){
			sum+=i;
		}
	}
	
	printf ("%lld\n", sum);
	
return 0;
}


Measured memory_bytes: 1676
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
char s[10];
signed main(){
	cin>>s;
	puts(*s==s[1]&&*s==s[2]?"No":"Yes");
	exit(0);
}

Measured memory_bytes: 256
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    X, Y = input_number_list()
    print(['No', 'Yes'][2 * X <= Y <= 4 * X and Y % 2 == 0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, M;
ll x[1010], y[1010], z[1010], sum[1010];

signed main(){
    cin >> N >> M;
    REP(i, N){
        cin >> x[i] >> y[i] >> z[i];
    }
    ll ans = 0;
    ll sgn[3];
    REP(i, 1 << 3){
        REP(j, 3){
            if(i & (1 << j)) sgn[j] = -1;
            else sgn[j] = 1;
        }
        REP(j, N){
            sum[j] = sgn[0] * x[j] + sgn[1] * y[j] + sgn[2] * z[j];
        }
        sort(sum, sum + N, greater<ll>());
        ans = max(ans, accumulate(sum, sum + M, 0LL));
    }
    PRINT(ans);
    return 0;
}

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

struct unionfind {
    vector<int> par;
    vector<int> rank;
    vector<int> number;
    unionfind(int N) : par(N), rank(N), number(N) {
        for(int i = 0; i < N; i++) {
          par[i] = i;
          rank[i] = 1;
          number[i] = 1;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
          par[rx] = ry;
          number[ry] += number[rx];
        } else {
          par[ry] = rx;
          number[rx] += number[ry];
          if (rank[rx] == rank[ry])
            rank[rx]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
      return rank[root(x)];
    }

    int size2(int x) {
      return number[root(x)];
    }
};

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

  int N, M, K, A, B, C, D;
  cin >> N >> M >> K;
  vector<vector<int> > f(N);
  vector<vector<int> > b(N);
  vector<int> c(N);
  unionfind tree(N);
  rep(i, M) {
    cin >> A >> B;
    A--;
    B--;
    f[A].pb(B);
    f[B].pb(A);
    tree.unite(A, B);
  }
  rep(i, K) {
    cin >> C >> D;
    C--;
    D--;
    b[C].pb(D);
    b[D].pb(C);
  }
  // rep(i, N) {
  //   cout << tree.size2(i) << ' ';
  // }
  // cout << endl;
  rep(i, N) {
    int temp = tree.size2(i);
    temp -= 1 + f[i].size();
    rep(j, b[i].size()) {
      if (tree.root(b[i][j]) == tree.root(i))
        temp -= 1;
    }
    cout << temp << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 13432
//http://arc071.contest.atcoder.jp/tasks/arc071_b

#include <stdio.h>
#define ArrLen 100000
#define Modulo 1000000007

long long findLineMod(int n) {
//    int arr[ArrLen];
    long long result = 0;
    long long left, right;
    scanf("%lld", &left);
    for(long long i = 1; i < n; i++) {
        scanf("%lld", &right);
        long long diff = (right - left) % Modulo;
        long long times = (i * (n - i)) % Modulo;
        result += (diff * times) % Modulo;
        result %= Modulo;
        left = right;
    }
//    for(int i = 1; i < n; i++) {
//        for(int j = 0; j < i; j++) {
//            result += arr[i] - arr[j];
//            result %= Modulo;
//        }
//    }
    
    return result;
}

int main() {
    int m, n;
    scanf("%d%d", &m, &n);
    long long xSum = findLineMod(m);
    long long ySum = findLineMod(n);
    
    long long product = xSum * ySum;
    product %= Modulo;
    
    printf("%lld\n", product);
    
    return 0;
}

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

int main(){
  stack<int> S1;
  stack<pair<int,int> > S2;
  char ch;
  int sum = 0;
  int i,j,a;
  for( i = 0; cin >> ch ; i++){
    if(ch == '\\'){
      S1.push(i);
    }
    else if( ch == '/' && S1.size() > 0){
      j = S1.top();
      S1.pop();
      sum += i - j;
      a = i - j;
      while(S2.size() > 0 && S2.top().first > j){
        a += S2.top().second;
        S2.pop();
      }
      S2.push( make_pair(j,a) );
    }
  }

  vector<int> ans;
  int t = 0;
  while(S2.size() > 0){
    ans.push_back( S2.top().second );
    S2.pop();
  }
  reverse( ans.begin(), ans.end() );
  cout << sum << endl;
  cout << ans.size();
  for( i = 0; i < ans.size(); i++){
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
int main(void){
	int n;
	scanf("%d\n",&n);
	int A[n];
	int k;
	for(k=0;k<n;k++){
		scanf("%d ",&A[k]);
	}
	long long int sum;
	int max = A[0];
	int min = A[0];
	int h;
	for(h=0;h<n;h++){
		if(max<A[h]){
			max = A[h];
		}
		if(min>A[h]){
			min = A[h];
		}
		sum = sum + A[h];
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


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

signed main() {
    ll n, x;
    cin >> n >> x;
    
    ll r = 0;
    vll a(n);
    rep(i, n) {
        cin >> a[i];
    }
    
    r = abs(x-a[0]);
    
    rep(i, n){
        r = gcd(r, abs(x-a[i]));
    }
    
    mes(r);
    
}

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


int main() {
	int A, B;
	int a, b;
	cin >> A >> B;
	for (int i = 1; i < 1010; i++) {
		a = i * 0.08;
		b = i * 0.1;
		if (a== A && b == B) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1;
	
}

Measured memory_bytes: 256
s = input()
k = int(input())

for i,c in enumerate(s):
	if c!='1':
		break # if j<i: s[j]=='1' else: s[j]!='1'
else:
	i = float('inf')

if k-1<i:
	print('1')
else:
	print(c)

	


Measured memory_bytes: 2940
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
    int n;
    cin >> n;
    v a(n, 0);
    rep(i, n)  cin >> a[i];
    rep(i, n)
    {
        if(a[i] % 2 != 0) continue;
        bool flag = false;
        if(a[i] % 3 == 0){
            flag = true;
        }
        if(a[i] % 5 == 0){
            flag = true;
        }
        if(!flag){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
void main()
{
    long n = rdElem;

    writeln((n + 1) / 2);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main()
{

	int n;
	scanf("%d", &n);
	int a = n % 10;
	int b = n / 10;
	if (a == 9 || b == 9)
		printf("Yes\n");
		else printf("No\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int a[11]={};
	rep(i,0,3){
		int b;
		cin >> b;
		a[b]++;
	}

	if( a[5] == 2 && a[7] )
		YES;
	else
		NO;

	ret 0;
}

Measured memory_bytes: 256
base = input().split()
n = int(base[0])
a = int(base[1])
b = int(base[2])
block = a+b
blockcnt = n//block
partx =a*blockcnt
ans = 0
if a>=(n%block):
    ans = partx+(n%block)
else:
    ans = partx+a
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
		int length = Integer.parseInt(sc.nextLine());
		String a = sc.nextLine();
		String b = sc.nextLine();
		String c = sc.nextLine();

		int cnt = 0;
		for (int i = 0; i < length; i++) {
			String a1 = a.substring(i, i+1);
			String b1 = b.substring(i, i+1);
			String c1 = c.substring(i, i+1);

			if (!a1.equals(b1) && !b1.equals(c1) && !c1.equals(a1)) {
				cnt += 2;
			} else if (!a1.equals(b1) || !b1.equals(c1)) {
				cnt += 1;
			}
		}
		System.out.println(cnt);
	}

}

Measured memory_bytes: 23252
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


class UnionFind {
private:
	vector<ll> data;
public:
	UnionFind(ll size) : data(size, -1) { }
	bool unite(ll x, ll y) { //x が入っている集合と y が入っている集合を併合する. (O(α(n)))
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	ll find(ll x) { // x のグループ番号を得る. (O(α(n)))
		return root(x);
	}
	ll root(ll x) { // x のみが入る集合 {x} を作る.
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	ll size(ll x) { // x が入っている集合の大きさを調べる. (O(1))
		return -data[root(x)];
	}
};


int main() {
	ll N, M;
	cin >> N >> M;
	vll A(M), B(M);
	rep(i, M) {
		cin >> A[i] >> B[i];
		--A[i], --B[i];
	}

	UnionFind uf(N);
	vll conv(M);	// 便利さ

	ll val = 0;
	ford(i, 0, M - 1) {
		if (uf.find(A[i + 1]) == uf.find(B[i + 1])) conv[i] = conv[i + 1];
		else {
			conv[i] = conv[i + 1] + uf.size(A[i + 1]) * uf.size(B[i + 1]);
			uf.unite(A[i + 1], B[i + 1]);
		}
	}

	rep(i, M) cout << N * (N - 1) / 2 - conv[i] << endl;
}

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

vector<vector<int>> perms;

void add_perms(vector<int> perm, vector<bool> can_use) {
  if (none_of(can_use.begin(), can_use.end(), [](bool b){ return b; })) {
    perms.push_back(perm);
  } else {
    for (auto it = can_use.begin(); it != can_use.end(); it++) {
      if (*it) {
        int dist = distance(can_use.begin(), it);
        vector<int> new_perm(perm);
        new_perm.push_back(dist);
        vector<bool> new_can_use(can_use);
        new_can_use[dist] = false;
        add_perms(new_perm, new_can_use);
      }
    }
  }
}

int main() {
  int N, M; cin >> N >> M;
  bool E[N][N];
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      E[i][j] = false;
  for (int i = 0; i < M; i++) {
    int x, y; cin >> x >> y; x--; y--;
    E[x][y] = E[y][x] = true;
  }
  vector<bool> can_use_init = vector<bool>(N, true);
  can_use_init[0] = false;
  add_perms(vector<int>(1, 0), can_use_init);
  int c = 0;
  for (auto it = perms.begin(); it != perms.end(); it++) {
    vector<int> perm = *it;
    bool valid_path = true;
    for (int i = 0; i < N-1; i++) {
      if (!E[perm[i]][perm[i+1]]) valid_path = false;
    }
    c += valid_path;
  }
  cout << c << endl;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,q;
Graph G;
int ans[200020];
bool seen[200020];

void dfs(int v,int p){
    seen[v]=true;
    ans[v]+=ans[p];
    for(int x :G[v]){
        if(seen[x])continue;
        dfs(x,v);
    }
}
int main(){
    cin >> n >> q;
    G.resize(n);
    rep(i,200020){
        ans[i]=0;
        seen[i]=false;
    }
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int p,y;
        cin >> p >> y;
        p--;
        ans[p]+=y;
    }
    ans[-1]=0;
    dfs(0,-1);
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 20608
#include<stdio.h>
int main(){
	int x,y,a[100][100],s[100]={0},u[100]={0},num=0;
	scanf("%d %d",&y,&x);
	for(int i=0;i<y;i++){
		for(int j=0;j<x;j++){
			scanf("%d",&a[j][i]);
			s[i]=s[i]+a[j][i];
		}
	}
	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			u[i]=u[i]+a[i][j];
		}
		num = num+u[i];
	}
	for(int i=0;i<y;i++){
		for(int j=0;j<x;j++){
			printf("%d ",a[j][i]);
		}
		printf("%d\n",s[i]);
	}
	for(int i=0;i<x;i++){
		printf("%d ",u[i]);
	}
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 2732
#include<stdio.h>
 
int main(void)
{
  int i,N,x=0,y=0;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    x+=800;
    if((i%15)==0){
      y+=200;
    }
  }
  printf("%d",x-y);
  return 0;
}

Measured memory_bytes: 128
#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 ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  int A, B;
  cin >> A >> B;
  if(A>12)
    cout << B << endl;
  else if(A>5)
    cout << B/2<<endl;
  else
    cout <<0<<endl;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
d_ans = dict(Counter(d))
t_ans = dict(Counter(t))
flag = True
for i in t_ans:
    if i not in d_ans:
        flag = False
        
    else:
        if t_ans[i] > d_ans[i]:
            flag = False
print('YES' if flag==True else 'NO')

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

int main(void) {
  int N, M;
  string S, T;
  cin >> N >> M >> S >> T;
  long long gcd = __gcd(N, M);
  long long ans = N / gcd * M;
  for (int i = 0; i < gcd; i++) {
    if (S[i * N / gcd] != T[i * M / gcd]) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

#define si(a) scanf("%d",&a)
#define f first
#define s second
#define mp(a,b) make_pair(a,b)
#define MAX 100005

bool vis[MAX];
int dist[MAX];
vector<pair<int,int> > graph[MAX];
vector<int > sorted_ara;

void go(int now)
{
    if(vis[now])
        return ;
    vis[now]=1;
    for(int i=0;i<graph[now].size();i++)
        go(graph[now][i].f);
    sorted_ara.push_back(now);
}

bool f(int now)
{
    //cout<<now<<' '<<dist[now]<<endl;
    bool flag=true;
    for(int i=0;i<graph[now].size();i++){
        int to=graph[now][i].f,w=graph[now][i].s;
        if(dist[to]==-1){
            dist[to]=dist[now]+w;
            flag &=f(to);
        }
        else{
            if(dist[to] !=dist[now]+w)return false;
        }
    }
    //cout<<now<<endl;
    return flag;

}

int main()
{
    //freopen("input.txt","r",stdin);
    int n,m,i;
    si(n);si(m);
    for(i=0;i<m;i++){
        int u,v,w;
        si(u);si(v);si(w);
        graph[u].push_back(mp(v,w));
    }
    for(i=1;i<=n;i++)
        go(i);
    reverse(sorted_ara.begin(),sorted_ara.end());

    memset(dist,-1,sizeof(dist));

    bool flag=true;
    for(i=0;i<n;i++){
        int to=sorted_ara[i];
        if(dist[to] ==-1){
            dist[to]=0;
            flag&=f(to);
        }
    }
    if(flag)printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 11384
#include <bits/stdc++.h>
#define MAX 100005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);
#define fi(a,b,c) for(int i=a;i<b;i=i+c)
#define fj(a,b,c) for(int j=a;j<b;j+=c)
using namespace std;
 
ll gcd(ll n1,ll n2) {
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent) {
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll max(ll a,ll b,ll c) {
	return max(a,max(b,c));
}
int max(int a,int b,int c) {
	return max(a,max(b,c));
}

int main()
{
	string s;
	cin>>s;
	if(s.back()=='s'){
		s+="es";
	}else{
		s+="s";
	}
	cout<<s;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll int
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=1e5+3;
const ll mod=1e9+7;
vi a(MAX),b(MAX),c(MAX);
ll n;/*
ll fun(ll i,ll turn)
{
    if(i==n)
        return 0;
    if(turn==1)
    {
        return a[i]+max(fun(i+1,2),fun(i+1,3));
    }
    if(turn==2)
    {
        return b[i]+max(fun(i+1,1),fun(i+1,3));
    }
    if(turn==3)
    {
        return c[i]+max(fun(i+1,2),fun(i+1,1));
    }
}*/
ll fun()
{
    vi x(MAX),y(MAX),z(MAX);
    x[0]=a[0];
    y[0]=b[0];
    z[0]=c[0];
    rep(i,1,n)
    {
        x[i]=a[i]+max(y[i-1],z[i-1]);
        y[i]=b[i]+max(x[i-1],z[i-1]);
        z[i]=c[i]+max(x[i-1],y[i-1]);
    }
    return max(x[n-1],max(y[n-1],z[n-1]));
}
int main()
{
   FASTIO
   int t=1;
  // cin>>t;
   while(t--)
  {
       // ll n,k;
        cin>>n;
        ll x,y,z;
        rep(i,0,n)
        {
            cin>>x>>y>>z;
            a[i]=x;b[i]=y;c[i]=z;
        }
        ll ans=fun();
        cout<<ans;

   }
 return 0;
}


Measured memory_bytes: 2560
#include <cstdio>

int main() {
  int N;
  while (true) {
    scanf("%d", &N);
    if (N == 0) break;
    int cnt = 0;
    for (int i=0;i<N;i++) {
      for (int j=i+2;j<=N;j++) {
        if (j*(j+1)/2 - i*(i+1)/2 == N) cnt++;
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 2604
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  long long int N,M1,M2,K;
  int c=2;
  scanf("%lld",&N);

  for(K=2;K*K<=N;K++)
  {
    M1 = N;
    M2 = N;
    if(K*K  == N-1)
    {
      c++;
    }
    else if((N-1)%K == 0)
    {
      c += 2;
    }
    else if(K*K  == N)
    {
      c++;
    }
    else if(N%K ==  0)
    {
      while(M1%K == 0)
      {
        M1 /= K;
      }
      while(M2%(N/K) == 0)
      {
        M2 /= (N/K);
      }
      if(M1%K == 1)
      {
        c++;
      }
      if(M2%(N/K) == 1)
      {
        c++;
      }
    }
  }

  if(N == 2)
  {
    c = 1;
  }

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

  return 0;
}


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

int a[211];

int main(void) {


    int n = 0; scanf("%d", &n);
    for (int i = 0; i < 2*n; ++i) {
        scanf("%d", &a[i]);
    }
    sort(a, a + 2*n);
    int ans = 0;
    for (int i = 0; i < 2*n; i += 2) {
        ans += a[i];
    } 
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 764
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

string s;
int memo[501][501];

bool is_cat(int l, int r) {
	if(memo[l][r] != -1)
		return memo[l][r];

	if(l == r)
		return memo[l][r] = true;

	if(s[l] != 'm' || s[r - 1] != 'w')
		return memo[l][r] = false;

	int pos = l;
	while((pos = s.find('e', pos + 1)) != s.npos && pos < r - 1) {
		if(is_cat(l + 1, pos) && is_cat(pos + 1, r - 1))
			return memo[l][r] = true;
	}

	return memo[l][r] = false;
}

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

	memset(memo, -1, sizeof(memo));

	cin >> s;
	cout << (is_cat(0, s.size()) ? "Cat" : "Rabbit") << endl;

	return EXIT_SUCCESS;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  ll n;
  cin>>n;
  if(n%2==0)
    cout<<n<<nl;
  else
    cout<<2*n<<nl;
}

int main()
{
    su;
    ///tt
    f();
    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
using namespace std;

long long a=0,b=0,c=0;

int main(){
	scanf("%lld %lld %lld",&a,&b,&c);
	long long cha1=0,cha2=0,cha3=0;
	
	long long temp=a*b*(c/2)-a*b*(c-c/2);
	if(temp>0){cha1=temp;	}
	else{cha1=-temp;}
	
	temp=a*c*(b/2)-a*c*(b-b/2);
	if(temp>0){cha2=temp;	}
	else{cha2=-temp;}
	
	temp=b*c*(a/2)-b*c*(a-a/2);
	if(temp>0){cha3=temp;	}
	else{cha3=-temp;}
	
	long long min=0;
	if(cha1<cha2){min=cha1;}
	else{min=cha2;	}
	if(min>cha3){min=cha3;	}
	printf("%lld\n",min);
	return 0;
} 

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

int memo[13];
int ans[10000000]={0};
int n;

int main(){
  int i,j=6;
  memo[0]=1;
  for(i=1;i<=6;i++){
    memo[i]=j;
    j*=6;
  }
  j=9;
  for(i=1;i<=5;i++){
    memo[6+i]=j;
    j*=9;
  }
  cin >> n;
  for(i=1;i<=n;i++){
    ans[i]=99999;
    for(j=0;j<12;j++){
      if(memo[j]>i)continue;
      if(ans[i]>ans[i-memo[j]]+1)ans[i]=ans[i-memo[j]]+1;
    }
  }
  cout << ans[n] <<endl;
  return 0;
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table
p = prime_decomposition(N)
# print(p)
c = Counter(p)
# print(c)
ans = 0
for p, e in c.items():
    i = 0
    cnt = 1
    while cnt <= e:
        e -= cnt
        cnt += 1
        ans += 1
print(ans)

Measured memory_bytes: 10120
// AGC 19 A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    ll q,h,s,d; cin >> q >> h >> s >> d;
    int n; cin >> n;
    q*=4; h*=2;
    ll mi = min(q,min(h,s));
    ll two = min(mi*2, d);
    ll ans = (n/2)*two + (n%2)*mi;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Println(answer(n))
}

func answer(n int) int64 {
	var res int64 = 0
	for i:=1; i<=n; i++ {
		if i%3!=0 && i%5!=0 {
			res += int64(i)
		}
	}
	return res
}


Measured memory_bytes: 1820
#include<stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b&&a<c){
		if(b<c){
			printf("%d %d %d\n",a,b,c);
		}else{
			printf("%d %d %d\n",a,c,b);
		}
	}else if(b<a&&b<c){
		if(a<c){
			printf("%d %d %d\n",b,a,c);
		}else{
			printf("%d %d %d\n",b,c,a);
		}
	}else{
		if(a<b){
			printf("%d %d %d\n",c,a,b);
		}else{
			printf("%d %d %d\n",c,b,a);
		}
	}
}

Measured memory_bytes: 1024
import math


def loop(a, x, m):
    count = 0
    while 1:
        count += 1
        x = (a * x) % m
        if x == 1: break
    return count


while 1:
    a1, m1, a2, m2, a3, m3 = map(int, input().split())
    if a1 == 0: break
    x = y = z = 1
    x = loop(a1, x, m1)
    y = loop(a2, y, m2)
    z = loop(a3, z, m3)
    xy = int(x * y / math.gcd(x, y))
    xyz = int(xy * z / math.gcd(xy, z))
    print(xyz)


Measured memory_bytes: 5664
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    if(N%10==3)
    {
        cout << "bon" << endl;
    }
    else if(N%10==1 || N%10==0 || N%10==6 || N%10==8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3592