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


using namespace std;
typedef long long LL;
const int maxn = 100005;
int a[maxn], fa[maxn], mi[maxn], id[maxn], vis[maxn];
int n, m;

void Init()
{
    for(int i = 0; i <= n; i++)
    {
        fa[i] = i;
        mi[i] = a[i];
        id[i] = i;
    }
}

int Find(int x)
{
    return fa[x] == x ? x : fa[x] = Find(fa[x]);
}

void Merge(int x, int y)
{
    int fx = Find(x), fy = Find(y);
    fa[fx] = fy;
    if(mi[fy] > mi[fx])
    {
        mi[fy] = mi[fx];
        id[fy] = id[fx];
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    multiset<int> s;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        s.insert(a[i]);
    }
    Init();
    for(int i = 1; i <= m; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        Merge(u + 1, v + 1);
    }
    int num = 0;
    LL ans = 0;
    for(int i = 1; i <= n; i++)
    {
        if(Find(i) == i)
        {
            num++;
            ans += mi[fa[i]];
            s.erase(s.find(mi[fa[i]]));
        }
    }
    if(n < 2 * num - 2)
        printf("Impossible\n");
    else if(num == 1)
        printf("0\n");
    else
    {
        int cnt = 0;
        multiset<int>::iterator it;
        for(it = s.begin(); it != s.end() && cnt < num - 2; it++)
        {
            cnt++;
            ans += *it;
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main(){
  int h,w,k;cin>>h>>w>>k;
  int dpx[w+1][2]={};
  dpx[0][0]=1;
  dpx[1][0]=1;
  rep(i,2,w+1){
    dpx[i][1]=dpx[i-1][0];
    dpx[i][0]=dpx[i-1][0]+dpx[i-1][1];
  }
  const int m=1e9+7;
  ll dpy[h+1][w]={};
  dpy[0][0]=1;
  rep(i,h){
    rep(j,w){
      dpy[i+1][j]+=(dpy[i][j]*dpx[j+1][0])%m*dpx[w-j][0]%m;
      dpy[i+1][j]%=m;
      if(j>0){
        dpy[i+1][j]+=(dpy[i][j-1]*dpx[j][0])%m*dpx[w-j][0]%m;
        dpy[i+1][j]%=m;
      }
      if(j<w-1){
        dpy[i+1][j]+=(dpy[i][j+1]*dpx[j+1][0])%m*dpx[w-1-j][0]%m;
        dpy[i+1][j]%=m;
      }
    }
  }
  cout<<dpy[h][k-1]<<endl;
}

Measured memory_bytes: 256
X = []
N = int(input())
X = list(map(int, input().split()))
tsum = 0
tsumMin = 10000000000000000000000000


for zahyou in range(1, 101):
    for i in range(N):
        tairyoku = (X[i] - zahyou)**2
        tsum += tairyoku
    if(tsum < tsumMin):
        tsumMin = tsum
        tsum = 0
    else:
        tsum = 0
        
print(tsumMin)

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

class Move{
public:
  int y;
  int x;
  int yp;
  int xp;
  Move(int a, int b, int c, int d){
    y = a;
    x = b;
    yp = c;
    xp = d;
  }
};

int main(){
  int H, W;
  cin >> H >> W;
  int a[H+1][W+1];
  int ans = 0;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      cin >> a[i][j];
    }
  }
  int count = 0;
  vector<Move> v;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j < W; j++){
      if(a[i][j] % 2){
        a[i][j]--;
        a[i][j+1]++;
        count++;
        v.push_back(Move(i,j,i,j+1));
      }
    }
  }
  for(int i = 1; i < H; i++){
    if(a[i][W] % 2){
      a[i][W]--;
      a[i+1][W]++;
      count++;
      v.push_back(Move(i,W,i+1,W));
    }
  }
  cout << count << endl;
  for(int i = 0; i < v.size(); i++){
    cout << v[i].y << " " << v[i].x << " " << v[i].yp << " " << v[i].xp << endl;
  }
  return 0;
}


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

int main( void )
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ( ( abs( a - b ) <= d && abs( b - c ) <= d ) || ( abs( a - c ) <= d ) )
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  string a , b , c  ; cin >> a >> b >> c ;
  cout << (char)(a[0]+('A'-'a')) << (char)(b[0]+('A'-'a')) << (char)(c[0]+('A'-'a')) << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n = S()
    ans = ''
    for c in n:
        if c == '1':
            ans += '9'
        elif c == '9':
            ans += '1'
        else:
            ans += c
    print(ans)


main()



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

int N, K;
int l[60];
int main(){
  cin >> N >> K;
  for(int i=0; i<N; ++i){
    cin >> l[i];
  }
  
  sort(l, l+N, greater<int>());
  int sum =0;
  for(int i=0; i<K; ++i){
    sum += l[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int64_t> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  int64_t k=0;
  for(int i=0;i<n;i++){
    k+=a.at(i)/(n+1);
    a.at(i)=a.at(i)%(n+1);
  }
  vector<int> b(n+1,0);
  for(int i=0;i<n;i++)
    b.at(a.at(i))++;
  for(int i=0,p=n;i<n;i++){
    while(b.at(p)==0)
      p--;
    a.at(i)=p+k;
    b.at(p)--;
  }
  int64_t m=a.at(0)*n;
  for(int i=0;i<n;i++)
    m=min(m,i+max(a.at(i)+i-n+1,(int64_t)0)*n);
  cout<<k+m<<endl;
}

Measured memory_bytes: 3560
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            Solve();

        }
        static void Solve()
        {
            var inp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = inp[0];
            var D = inp[1];
            var A = inp[2];
            var Monster = new Tuple<long, long>[N];
            for (int i = 0; i < N; i++)
            {
                var XH = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                Monster[i] = new Tuple<long, long>(XH[0], XH[1]);
            }
            Sort(Monster);
            var que = new Queue<long>();
            long CumlatedDamage = 0;
            que.Enqueue(Monster[0].Item2);
            long MaxRange = Monster[0].Item1 + 2 * D;
            long TopNum = 0;
            long TargetMonsterSum = 1;
            long ans = 0;
            while (TopNum < N)
            {
                MaxRange = Monster[TopNum].Item1 + 2 * D;
                while (TargetMonsterSum < N && Monster[TargetMonsterSum].Item1 <= MaxRange)
                {
                    que.Enqueue(Monster[TargetMonsterSum].Item2 + CumlatedDamage);
                    TargetMonsterSum++;
                }
                var tmp = ((que.Peek() - CumlatedDamage - 1) / A) + 1;
                ans += tmp;
                CumlatedDamage += tmp * A;

                while(que.Count >0 && que.Peek() <= CumlatedDamage)
                {
                    que.Dequeue();
                    TopNum++;
                }
                
            }

            Console.WriteLine(ans);
        }
    }

}


Measured memory_bytes: 59588
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tst ll T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
ll a[100001]={0};
int main()
{
    // clock_t start, end;
    // start = clock();
    vite;
    ll n, t = 0;
    cin >> n;
    for (ll i = 0; i < n;i++)
    {
        ll x;
        cin >> x;
        t += x;
        a[x]++;
    }
    ll q;
    cin >> q;
    for (ll i = 0; i < q;i++)
    {
        ll x, y;
        cin >> x >> y;
        a[y] += a[x];
        t += y * a[x] - x * a[x];
        a[x] = 0;
        cout << t << "\n";

    }
        // end = clock();
        // double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
        // cout<<fixed << time_taken << setprecision(5);
        return 0;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define R__64 18446744073709551616//2^64
#define R__InFinity 100000000;
#define R__PI acos(-1.0)
template <class R> string R__MonthName(R name){string mon[15];mon[1]="January";mon[2]="February";mon[3]="March";mon[4]="April";mon[5]="May";mon[6]="June";mon[7]="July";mon[8]="August";mon[9]="September";mon[10]="October";mon[11]="November";mon[12]="December";return mon[name];}
template <class R> R R__MonthDay(R num){R month[13];month[1]=31;month[2]=28;month[3]=31;month[4]=30;month[5]=31;month[6]=30;month[7]=31;month[8]=31;month[9]=30;month[10]=31;month[11]=30;month[12]=31;return month[num];}
template <class R> R R__GCD(R a,R b){if(b==0) return a;else return R__GCD(b,a%b);}
template <class R> R R__LCM(R a,R b){return (a*b)/R__GCD(a,b);}
template <class R> R R__POW( R a, R b){if(b==0) return 1; R x=a;for(R i=2;i<=b;i++) a=a*x;return a;}
template <class R> R R__BigMod(R a,R b,R c){if(a==0) return 0;if(b==0) return 1;if(b%2==0){R x=R__BigMod(a,b/2,c)%c;return (x*x)%c;}else return  ((a%c)*R__BigMod(a,b-1,c)%c)%c;}
template <class R> R R__Factorial(R a){R b=1;for(R i=1;i<=a;i++)b=b*i;return b;}
template <class R> R R__BinarySearch(R a[],R l,R h,R n){while(l<=h){R m=(l+h)/2;if(n<a[m])h=m-1;else if(n>a[m])l=m+1;else return m;} return -1;}

long long a[100],i;

int main()
{
    //time_t t1=clock();
    //freopen("input.txt","r",stdin);//freopen("output.txt","w",stdout);
    while(cin>>a[0])
    {
        for(i=1;i<=9;i++)
            cin>>a[i];
        sort(&a[0],&a[10]);
        cout<<a[9]<<"\n"<<a[8]<<"\n"<<a[7]<<"\n";
    }
    //time_t t2=clock();
    //cout<<(t2-t1);
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	const Int MOD = 1e9 + 7;
	Int N, K;
	cin >> N >> K;
	vector<Int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	Int k1 = (K * (K - 1) / 2) % MOD;
	Int k2 = (K * (K + 1) / 2) % MOD;
	Int ans = 0;
	for (int i = 0; i < N; ++i) {
		Int cnt1 = 0, cnt2 = 0;
		for (int j = 0; j < N; ++j) {
			if (a[i] <= a[j]) { continue; }
			if (j < i) { ++cnt1; }
			else { ++cnt2; }
		}
		(ans += cnt1 * k1) %= MOD;
		(ans += cnt2 * k2) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;



int main(){
  int N;
  cin >> N;
  int a[N];
  REP(i, 0, N){
    cin >> a[i];
  }

  // calculate yama1
  ll all_sum = 0;
  REP(i, 0, N){
    all_sum = all_sum + a[i];
  }
  ll sum = 0;
  REP(i, 0, N/2){
    sum = sum + a[i*2+1];
  }
  int yama1 = (all_sum / 2) - sum;
  cout << yama1*2 << " ";

  int prev_yama = yama1;
  REP(i, 1, N){
    prev_yama = a[i-1] - prev_yama;
    cout << prev_yama*2 << " ";
  }
  cout << endl;

  return 0;
}


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

#define int long long
#define double long double

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;
using ld=double;

constexpr int MOD = 1e9+7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> c(h);
    int ans=0;
    rep(i,h)cin>>c[i];
    rep(i,(1<<h)){
        rep(j,(1<<w)){
            int cnt=0;
            rep(l,h){
                rep(m,w){
                    if(c[l][m]=='#'&&(i>>l)%2==0&&(j>>m)%2==0)cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3652
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ansNums = factorization(N)
ans = 0

for a in ansNums:
    if a[0] == 1:
        break
    cnt = 1
    while a[1] >= cnt:
        a[1] -= cnt
        ans += 1
        cnt += 1

print(ans)



Measured memory_bytes: 9476
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let k: u32 = input();
    if k % 2 == 0 {
        println!("{}", k / 2 * k / 2);
    } else {
        println!("{}", k / 2 * (k / 2 + 1));
    }
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

Measured memory_bytes: 4352
/*
   Creator - Glitched
   Yeet!!
*/

#include "bits/stdc++.h"
#include "stdlib.h"
using namespace std;
#define testcases ll t;cin>>t;while(t--)
#define queries ll q;cin>>q;while(q--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)

#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{   
    // fastio;
    double ans = -mod;
    ll n,k;
    cin>>n>>k;
    std::vector<double> v(n),s(n);
    std::vector<double> ev(n), pf(n);

    loop(i,0,n){
        cin>>v[i];
        double x = v[i];
        s[i] = x*(x+1);
        s[i]/=2;
        ev[i] = (1/x)*s[i];

        if(i==0)
            pf[i] = ev[i];
        else
            pf[i] = ev[i]+pf[i-1];           

    }

    loop(i,k-1,n){
        if(i==k-1){
            ans = max(ans, pf[i]);
        }
        else{
            ans = max(ans, pf[i] - pf[i-k]);
        }
    }
    cout<<fixed<<setprecision(10)<<ans;


    
}

Measured memory_bytes: 6528
N, M = map(int, input().split())
input_li = []
p_dict = {}
ans_dict = {}
for _ in range(M):
    p, y = map(int, input().split())
    input_li.append([p, y])
    if p not in p_dict:
        s = [y]
        p_dict[p] = s
    else:
        p_dict[p].append(y)
for p in p_dict:
    li = sorted(p_dict[p])
    ans_dict[p] = {}
    for i in range(len(li)):
        p_id = '0' * (6 - len(str(p))) + str(p)
        c_id = '0' * (6 - len(str(i + 1))) + str(i + 1)
        ans_dict[p][li[i]] = p_id + c_id
for p, y in input_li:
    print(ans_dict[p][y])


Measured memory_bytes: 146180
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i = 1;;i++){
            int x = sc.nextInt();
            if (x != 0) {
                System.out.println("Case "+i+": "+x);
            }else{
                break;
            }
        }
    }
}


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

using namespace std;

struct tree {
	vector<vector<int>> out;
	vector<int> vis;
	int n;
} t;

int fill_path(int v, int dest, int prev) {
	if (v == dest) {
		t.vis[v] = 1;
		return 1;
	}

	for (int x : t.out[v]) {
		if (x != prev) {
			int n = fill_path(x, dest, v);

			if (n > 0) {
				t.vis[v] = n + 1;
				return n + 1;
			}
		}
	}

	return 0;
}

int fill_all(int v, int prev) {
	int sum = 1;
	for (int x : t.out[v]) {
		if (x != prev && !t.vis[x]) {
			sum += fill_all(x, v);
		}
	}
	return sum;
}

int main() {

	cin >> t.n;

	t.out.resize(t.n);
	t.vis.resize(t.n);
	for (int i = 0; i < t.n - 1; i++) {
		int x;
		int y;

		cin >> x >> y;

		t.out[x - 1].push_back(y - 1);
		t.out[y - 1].push_back(x - 1);
	}

	int common = fill_path(0, t.n - 1, -1) - 2;
	int fennec = fill_all(0, -1) - 1;
	int snuke = fill_all(t.n - 1, -1) - 1;

	int turn = 0;
	int fennec_pos = 0;
	int snuke_pos = t.n - 1;
	while (turn < common) {
		if (turn % 2 == 0) {
			for (int x : t.out[fennec_pos]) {
				if (t.vis[x] == t.vis[fennec_pos] - 1) {
					fennec_pos = x;
					break;
				}
			}
			fennec += fill_all(fennec_pos, -1) - 1;
		}
		else {
			for (int x : t.out[snuke_pos]) {
				if (t.vis[x] == t.vis[snuke_pos] + 1) {
					snuke_pos = x;
					break;
				}
			}
			snuke += fill_all(snuke_pos, -1) - 1;
		}

		turn++;
	}

	while (fennec >= 0 && snuke >= 0) {
		if (turn % 2 == 0) {
			fennec--;
		}
		else {
			snuke--;
		}
		turn++;
	}

	if (fennec < 0) {
		cout << "Snuke\n";
	}
	else {
		cout << "Fennec\n";
	}

	return 0;
}

Measured memory_bytes: 12288
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)
const double PI = 3.14159265358979323846;

double a, b, x;

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

    double ans;

    if (a * a * b >= x * 2) {
        double c = x / a / b * 2;
        ans = atan(b / c) / PI * 180;
    } else {
        double y = a * a * b - x;
        double c = y / a / a * 2;
        ans = atan(c / a) / PI * 180;
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}


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


using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;



const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const int NMAX = 1e7 + 5;
const int MOD = 1e9 + 7;
#define endl "\n"



ll tab[NMAX];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for (int i = 1; i <=n; ++i)
    {
        int x = i;
        while(x<=n){
            tab[x]++;
            x+=i;
        }
    }
    ll ans=0;
    for (ll i =1; i <=n; ++i)
    {
        ans += i*tab[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 81772
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    k--;
    for(int i=0;i<n;i++){
        if(i==k) cout<<(char)(s.at(i)+32);
        else cout<<s.at(i);
    }
    cout<<"\n";
}

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

using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

string StrCpy(string str, long long int start, long long int end){string temp = "";for(long long int i=start; i<=end; i++){temp += str[i];}return temp;}

#define ull unsigned long long int
#define ll long long int 
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a*b)/gcd(a, b))



int solve(){

    
    string s,t;

    int cnt=0;
    int ans = 999999;

    cin >> s;
    cin >> t;

    //cout << " SS " << s << " " << t << endl;

    for(int i=0; i<=s.length() - t.length(); i++){

        cnt = 0;

        for(int j=0; j<t.length(); j++){    

            if(t[j] != s[i+j])
                cnt++;

        }

      //  cout << ans << " " << cnt << endl;

        ans = min(ans,cnt);

    }


    cout << ans << endl;



    return 0;
}

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

    time__("programm time"){
        solve();
	}
    return 0;

}

Measured memory_bytes: 3816
import java.util.*;

public class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	char at=sc.next().charAt(0),top=sc.next().charAt(0);
	if(at=='H'){
		if(top=='H')System.out.println("H");
		else System.out.println("D");
	}
	else{
		if(top=='H')System.out.println("D");
		else System.out.println("H");
	}
	sc.close();
  }
}


Measured memory_bytes: 35428
N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
A_sum = sum(A)
B_sum = 0
n, m = N, 0
ans= 0
while m != M:
  if A_sum + B_sum <= K:
    ans = max(ans, n+m)
    m += 1
    B_sum += B[m]
  elif A_sum + B_sum > K and n >= 0:
    A_sum -= A[n]
    n -= 1
  else:
    break
if A_sum + B_sum <= K:
  ans = max(ans, n+m)    
print(ans)

Measured memory_bytes: 39940
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

bool solve(void){
    int n;
    cin >> n;

    string s;
    cin >> s;

    if(n & 1){
        return false;
    }

    string t = s.substr(0, n / 2);
    string u = s.substr(n / 2, n / 2);

    return t == u;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

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

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);
const double pi = 3.14159265358979323846264;
//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    ll sum = 1;
    bool zero = false;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        sum *= a[i];
        if (a[i] == 0)
        {
            zero = true;
        }
    }
    if (zero)
    {
        cout << "0" << endl;
    }
    else
    {
        ll judge = sum;
        bool amari = false;
        for (ll i = 0; i < n; i++)
        {
            if (!judge % a[i])
            {
                amari = true;
            }
            judge /= a[i];
        }
        if (judge == 1 && amari == false)
        {
            if (sum <= 1000000000000000000)
            {
                cout << sum << endl;
            }
            else
            {
                cout << "-1" << endl;
            }
        }
        else
        {
            cout << "-1" << endl;
        }
    }
}


Measured memory_bytes: 4312
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

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

    lint res = 1000;

    REP(i, S.length()-2) {
      lint n = ctoi(S[i])*100+ctoi(S[i+1])*10+ctoi(S[i+2]);

      res = min(res, abs(753-n));
      
    }

    PRINT(res);

    return 0;
}


Measured memory_bytes: 256
def main():
    d, g = map(int, input().split())
    pc = [list(map(int, input().split())) for _ in range(d)]

    n = len(pc)
    ans = float("inf")

    for i in range(2**n):
        point, cnt = 0, 0
        for j in range(n):
            if (i>>j) & 1:
                point += (j+1)*100*pc[j][0] + pc[j][1]
                cnt += pc[j][0]
        if point >= g:
            ans = min(ans, cnt)
        # print(cnt, point)
        else:
            for j in range(n-1, -1, -1):
                if (i >> j) & 1:
                    continue
                else:
                    for k in range(pc[j][0]):
                        if point >= g:
                            ans = min(ans, cnt)
                            break
                        point += (j+1)*100
                        cnt += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=5e3+9;
	int n,mod,ans[N],a[N];
	int main(){
		n=read<int>(),mod=read<int>();
		for(int i=(n+1)/2+1;i<=n;i++) a[1]++,a[i+1]--;
		for(int i=1;i<=(n+1)/2+(!(n&1));i++) a[1]--,a[i+1]++;
		a[1]++;
		for(int i=1;i<=n;i++) a[i]+=a[i-1];

		ans[0]=1;
		for(int i=2;i<=n;i++)
			for(int j=a[i];j<n;j++)
				ans[j]=(ans[j]+ans[j-a[i]])%mod;

		int ret=0;
		for(int i=0;i<n;i++)
			ret=(ret+1LL*(n-i)*ans[i])%mod;
		printf("%d\n",ret);
		return 0;
	}

}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 384
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
if k>max(a):
    ans = 0
elif k in a:
    ans = 1
elif n==1:
    if a[0]==k:
        ans = 1
    else:
        ans = 0
else:
    g = gcd(a[0], a[1])
    for num in a[2:]:
        g = gcd(g, num)
    if k%g==0:
        ans = 1
    else:
        ans = 0
ans = "POSSIBLE" if ans else "IMPOSSIBLE"
print(ans)

Measured memory_bytes: 86304
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        private int gcd(int m, int n) {
            return m % n == 0 ? n : gcd(n, m % n);
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long gcdSum = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    int gcd1 = gcd(i, j);
                    for (int k = 1; k <= n; k++) {
                        int gcd = gcd(gcd1, k);
                        gcdSum += gcd;
                    }
                }
            }

            out.println(gcdSum);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 34360
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)1e3 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = (int)1e9 + 7;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}
pair<string, int> ps[105];
int main() {
//    freopen("../in.txt", "r", stdin);
    int n;
    int id[105];
    read(n);
    char str[12];
    for (int i = 0; i < n; ++i) {
        scanf("%s%d", str, &ps[i].second);
        ps[i].first=str;
        id[i] = i;
    }
    sort(id, id+n, [](int a, int b) {
        return ps[a].first==ps[b].first?ps[a].second>ps[b].second:ps[a].first<ps[b].first;
    });
    for (int i = 0; i < n; ++i) {
        printf("%d\n", id[i]+1);
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))

minX = min(x)
maxX = max(x)

s = [0] * (maxX + 1)
for i in range(minX, maxX+1):
    for _x in x:
        s[i] += (_x - i)**2

print(min(s[minX:]))

Measured memory_bytes: 3064
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>

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

int main() {
    int n, d,ans = 0;
    ll x[200000], y[200000];
    double l;
    cin >> n >> d;
    rep(i, n) {
        cin >> x[i] >> y[i];
        x[i] = pow(x[i], 2);
        y[i] = pow(y[i], 2);
        l = sqrt(x[i] + y[i]);
        if (l <= d)ans++;
    }
    cout << ans << endl;


   
return 0;
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  ll N, M;
  cin >> N >> M;
  cout << min((N * 2 + M) / 4, M / 2) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int mass = 0;
	int hour = 0;
	int min = 0;
	int s = 0;
	
	scanf("%d", &mass);
	
	hour = mass / 3600;
	mass = mass % 3600;
	min = mass / 60;
	s = mass % 60;
	
	printf("%d:%d:%d\n", hour, min, s);
	
	return 0;
}


Measured memory_bytes: 2136
import sys
input = sys.stdin.readline

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

dp = [[0]*(K+1) for i in range(N+1)]

dp[0][0] = 1

cum = [0]*(K+2)

for i in range(1,N+1) :
    cum[0] = 1
    for j in range(1,K+2) :
        cum[j] = (cum[j-1] + dp[i-1][j-1]) % (10**9+7)
    for j in range(K+1) :
        dp[i][j] = (cum[j+1] - cum[max(0, j-A[i-1])] + (10**9+7)) % (10**9+7)

ans = dp[N][K]

print(ans)
#print(dp)


Measured memory_bytes: 118384
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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


 ll a,b,c,k,f=0;
 cin>>a>>b>>c>>k;
 while(k--)
 {
     //cout<<a<<" "<<b<<" "<<c<<" "<<k<<endl;
     if(c>b&&b>a)
     {
         f=1;
         break;
     }
     if(b<=a)
     {
         b*=2;
         continue;
     }
     if(c<=b)
     {
         c*=2;
         continue;
     }
 }
  if(c>b&&b>a)
     {
         f=1;
     }
 if(f)
 {
     cout<<"Yes"<<endl;
 }
 else
 {
     cout<<"No"<<endl;
 }
return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>

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

using namespace std;
using P = pair<int,int>;

int main()
{
    int N;
    cin>>N;
    P r[100010];
    rep(i,N){
        int x,l;
        cin>>x>>l;
        r[i] = make_pair(x+l,x-l);
    }

    sort(r,r+N);

    int ans=1,min=0;
    for(int i=1;i<N;i++){
        if(r[min].first<=r[i].second){
            min = i;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int N,M,a[MAXN/2],b[MAXN/2],f[MAXN];
long long ans[MAXN],cnt[MAXN];

int find(int x){
	return (f[x]==x) ? x : f[x]=find(f[x]);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M;
	for(int i = 1; i <= N; i++){
		f[i] = i;
		cnt[i] = 1;
	}
	for(int i = 1; i <= M; i++){
		cin >> a[i] >> b[i];
	}
	long long ANS = 1ll*(N-1)*N/2;
	for(int i = M; i > 0; i--){
		int x=find(a[i]),y=find(b[i]);
		ans[i] = ANS;
		if(x==y) continue;
		ANS -= cnt[x]*cnt[y];
		f[x] = y;
		cnt[y] += cnt[x];
	}
	for(int i = 1; i <= M; i++)
		cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        int len = 0;
        while (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
        {
            len++;
            i++;
        }

        ans = max(ans, len);
    }
    cout << ans << endl;
}


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

//qsort用降順
int cmp(const void *a,const void *b){
    if(*(int*)a>*(int*)b){return 1;}
    else if(*(int*)a<*(int*)b){return -1;}
    else {return 0;}
}


int main(void){
    int a[10000];
for(int i=0;i<10000;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<10000;i++){
printf("Case %d: %d\n",i+1,a[i]);
}
return 0;
}



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

int ans[100];

int fib(int n){
    if(n == 0 || n == 1) return 1;
    else return ans[n - 1] + ans[n - 2];
}

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


Measured memory_bytes: 3108
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
	new Main().doIt();
    }
    void doIt() { B(); }
    void B() {
	int K =	sc.nextInt(), X	= sc.nextInt();
	ArrayList<Integer> ans = new ArrayList<Integer>();
	for(int	i = X-(K-1); i <= X+(K-1); i++) ans.add(i);
        //      System.out.println(ans);                                                         
	for(Integer i: ans) System.out.print(" " + i);
	System.out.println();
    }
    void A() {
        int A = sc.nextInt(), B = sc.nextInt();
	int ans = A+B;
	ans = Math.max(ans, Math.max(A-B, A*B));
	System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
 
int gcd(int a, int b) {
  if (b == 0)
    return a;
 
  return gcd(b, a % b);
}
 
int main() {
  int N;
  cin >> N;
 
  ll sum = 0;
  for (int a = 1; a <= N; a ++) {
    for (int b = 1; b <= N; b ++) {
      for (int c = 1; c <= N; c ++) {
        sum += gcd(gcd(a, b), c);
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c = map(int, input().split())
for i in range(10**5):
    ans = a*i
    if ans % b == c:
        print('YES')
        exit()
print('NO')


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

typedef long long ll;

const int MOD = 1e9+7;
const int N = 100001;

int main () {
	ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	ll a = t1*(a1-b1), b = t2*(a2-b2);
	if (a > 0)
		a *= -1LL, b *= -1LL;
	if (a+b < 0) {
		cout << 0 << endl;
	} else if (a+b == 0) {
		cout << "infinity" << endl;
	} else {
		ll s = -a/(a+b), t = abs(a)%(abs(a+b));
		cout << 2LL*s+(t != 0) << endl; 
	}

	return 0;
}

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

int main(){
  long long int N,M,x,y,ans=0,cou=0;
  cin>>N>>M;
  vector<pair<int,int> >v;
  for(int i=0;i<N;i++){
    cin>>x>>y;
    v.push_back(make_pair(x,y));
  }
  sort(v.begin(),v.end());
  for(int i=0;cou<M&&i<N;i++){
    for(int j=v[i].second;j>0;j--){
    if(cou<M){
      ans+=v[i].first;
      cou++;
      }
      else {break;}
    }
  }
  cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 1400
N = int(input())
A = list(map(int, input().split()))
Flag = True

for i in A:
  if i % 2 == 0:
    if i % 3 == 0 or i % 5 == 0:
      continue
    else:
      Flag = False

if Flag:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#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> a(n);
    rep(i,n) cin >> a[i];
    const int mod = 1'000'000'007;
    int ans = 0;
    int x = 0;
    rep(i,n) {
        ans = (ans+(ll)a[i]*x)%mod;
        x = (x+a[i])%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3960
S = input()
mae = int(S[:2])
ushiro = int(S[-2:])


if mae > 12 or mae == 0:
    # YYMM
    if ushiro > 12 or ushiro == 0:
        print("NA")
    else:
        print("YYMM")
else:
    # MMYY
    if ushiro < 13 and ushiro > 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")


Measured memory_bytes: 2940