akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

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

    ll ans = 0;
    rep(now, 1, N+1)
    {
        ll cnt = N/now;
        ans += (now + cnt * now) * cnt / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
	/*	int n = stdIn.nextInt();
		int a = 10;
		
		for(int i = 1; i <= 9; i++) {
			if(n%i == 0) {
				 a = n/i;
			}
			if(a<10) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
		
		
		
		*/
		
		int n = stdIn.nextInt();
		for(int i = 1; i < 10; i++) {
			for(int j = 1; j < 10; j++) {
				if(n==i*j) {
					System.out.println("Yes");
                  System.exit(0);
				}
			}
		}
		System.out.println("No");
		
		
		
		
	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int s;
    cin >> s;
    cout << s/3600 << ':' << (s%3600)/60 << ':' << s%60 << endl;
}


Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

string s;
int gx, gy;
bool dp[8010][16010];

int main() {
	cin >> s;
	cin >> gx >> gy;

	int count = 0;
	vector<int> dx, dy;
	bool direct_x = true;

	rep(i, s.size()) {
		if (s[i] == 'F') count++;
		if (s[i] == 'T') {
			if (direct_x) dx.push_back(count);
			else dy.push_back(count);
			count = 0;
			direct_x = !direct_x;
		}
	}
	if (direct_x) dx.push_back(count);
	else dy.push_back(count);

	dp[0][8000] = dp[1][dx[0] + 8000] = true;
	for (int i = 1; i < dx.size(); i++) {
		for (int x = -8000; x <= 8000; x++) {
			if (dp[i][x + 8000])
				dp[i + 1][x - dx[i] + 8000] = dp[i + 1][x + dx[i] + 8000] = true;
		}
	}

	bool ans = dp[dx.size()][gx + 8000];
	memset(dp, false, sizeof(dp));

	dp[0][8000] = true;
	for (int i = 0; i < dy.size(); i++) {
		for (int y = -8000; y <= 8000; y++) {
			if (dp[i][y + 8000])
				dp[i + 1][y - dy[i] + 8000] = dp[i + 1][y + dy[i] + 8000] = true;
		}
	}

	ans &= dp[dy.size()][gy + 8000];
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 125696
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n , m ; cin >> n >> m;
    cout << m*(m-1)/2+n*(n-1)/2 << endl;
}

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

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

    int taro = 0;
    int hana = 0;
    rep(i, N){
        string T, H; cin >> T >> H;
        if (T > H) taro += 3;
        else if(H > T) hana += 3;
        else {
            taro++; 
            hana++;
        }
    }

    cout << taro << " " << hana << endl;

}


Measured memory_bytes: 3216
#include<stdio.h>
#include<stdlib.h>

int main(void){
    
    long int A,B,ans;

    scanf("%ld %ld",&A,&B);

    ans = (A + B)/2;

    if(abs(A - ans) == abs(B - ans)){
        printf("%ld",ans);
    }else{
        printf("IMPOSSIBLE");
    }
    return 0;
}

Measured memory_bytes: 128
n,m,k = map(int, input().split())
#ncr
mod = 998244353
class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod 
    def ncr(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod 
cmb = Combination(n)
ans = 0
for i in range(k+1):
  a = m*pow(m-1,n-i-1,mod)%mod
  a *= cmb.ncr(n-1,i)
  ans += a%mod
print(ans%mod)

Measured memory_bytes: 73944
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        vec.push_back(tmp);
    }
    sort(vec.begin(), vec.end());
    cout << *max_element(vec.begin(), vec.end()) -
                *min_element(vec.begin(), vec.end())
         << endl;
    return 0;
}

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

ll nC2(ll n){
    return n*(n-1)/2;
}

int main(){
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];

    rep(i,n)a[i]--;

    vector<int> count(n);
    rep(i,n)count[a[i]]++;
    ll tmp = 0;
    rep(i,n){
        tmp += nC2(count[i]);
    }
    rep(i,n){
        ll ans = tmp;
        ans -= nC2(count[a[i]]);
        ans += nC2(count[a[i]]-1);
        cout << ans << endl;
    }

    return 0;
}

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


//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 4e5+5;
const ll mod = 1e9+7;


ll pow2[62];
void cal_pow2() {
    ll i, x = 1, y;
    for0(i, 61) {
        y = x;
        pow2[i] = y;
        x *= 2;
    }
}

int main() {
    cal_pow2();
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    scl1(n);

    while(n > 0) {
        n /= 2;
        c++;
    }
    c--;

    for(i = 0; i <= c; i++) ans += pow2[i];

    printl(ans);

    return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  ll n, k;
  cin >> n >> k;

  int cnt = 0;
  while(n > 0) {
    cnt++;
    n /= k;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
S = input().strip()
C = {"N":0,"S":0,"E":0,"W":0}
for i in range(len(S)):
    C[S[i]] += 1
if C["N"]>0 and C["S"]>0:
    if (C["E"]>0 and C["W"]>0) or (C["E"]==0 and C["W"]==0):
        print("Yes")
    else:
        print("No")
elif C["N"]==0 and C["S"]==0:
    if (C["E"]>0 and C["W"]>0) or (C["E"]==0 and C["W"]==0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 62120
/*
 * Matheus Oliveira
 * 09:28:22 17/05/2020
 * d.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN 100020
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

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

int p[MAXN];
vector<int> graph[MAXN];

int main() {
	int n, m, n1, n2;
	scanf("%d %d", &n, &m);
	
	for(int i = 0; i < m; i++) {
		scanf("%d %d", &n1, &n2);

		graph[n1].eb(n2);
		graph[n2].eb(n1);
	}

	queue<int> q;
	q.push(1);

	while(not q.empty()) {
		int node = q.front();
		q.pop();

		for(int neighbor : graph[node]) {
			if(p[neighbor] != 0) continue;
			p[neighbor] = node;
			q.push(neighbor);
		}
	}

	printf("Yes\n");
	for(int i = 2; i <= n; i++) printf("%d\n", p[i]);

	return 0;
}

Measured memory_bytes: 10596
fun main(args: Array<String>) {
    readLine()
    val order = readLine()!!.split(" ").map { it.toInt() - 1 }
    val value = readLine()!!.split(" ").map(String::toInt)
    val additionalValue = readLine()!!.split(" ").map(String::toInt) + 0

    val result = order.withIndex().fold(0) { r, o: IndexedValue<Int> ->
        r + value[o.value] + if (order.nextIsInOrder(o)) additionalValue[o.value] else 0
    }

    println(result)
}

fun List<Int>.nextIsInOrder(i: IndexedValue<Int>): Boolean {
    val nextIndex = i.index + 1
    return nextIndex < this.size && this[nextIndex] == i.value + 1
}

Measured memory_bytes: 37872
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

 long long modpow(long long n, long long k,long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     int n;cin >> n;
     int maxi = -INT_MAX;int mini = INT_MAX;
     int mx = -INT_MAX;int mn = INT_MAX;
     for(int i = 0;i<n;i++){
        int x,y;cin >> x >> y;
        maxi = max(maxi,x+y);
        mini = min(mini,x+y);
        mx = max(mx,x-y);
        mn = min(mn,x-y);
     }
     cout << max(maxi-mini,mx-mn);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define endl "\n

using namespace std;

int main(){
  int n;
  cin>>n;
  int h[n];
  int cost[n]={0};
  int i;
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  cost[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++){
    cost[i]=min(cost[i-2]+abs(h[i]-h[i-2]),cost[i-1]+abs(h[i]-h[i-1]));
  }
  cout<<cost[n-1];

}
  

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#include<climits>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



struct StarrySkyTree{
	int n;
	std::vector<long long> segv,segAdd;
	void add(int a,int b,int x,int k,int l,int r){
		if(r<=a || b<=l)return;
		if(a<=l && r<=b){
			segAdd[k] += x;
			return;
		}
		int m=(l+r)/2;
		add(a,b,x,2*k+1,l,m);
		add(a,b,x,2*k+2,m,r);
		segv[k]=std::min(segAdd[2*k+1]+segv[2*k+1] ,segAdd[2*k+2]+segv[2*k+2]);
	}
	long long min(int a,int b,int k,int l,int r)const{
		if(r<=a || b<=l)return LLONG_MAX;
		if(a<=l && r<=b){
			return segv[k]+segAdd[k];
		}
		int m=(l+r)/2;
		return segAdd[k]+std::min(min(a,b,2*k+1,l,m),min(a,b,2*k+2,m,r));
	}
public:
	StarrySkyTree(int n=1<<19){
		init(n);
	}
	void init(int n){
		this->n=n;
		segv.assign(2*n-1,0);
		segAdd.assign(2*n-1,0);
	}
	void add(int a,int b,int x){//[a,b)にxを加算
		add(a,b,x,0,0,n);
	}
	long long min(int a,int b)const{//[a,b)の最小値
		return min(a,b,0,0,n);
	}
};



int main(){
	StarrySkyTree sst;
	set<int> s;
	string str;
	int n,q;
	cin>>n>>q>>str;
	rep(i,n){
		if(str[i]=='(')sst.add(i,n,1);
		else{
			sst.add(i,n,-1);
			s.insert(i);
		}
	}
	rep(i,q){
		int p;
		cin>>p;
		p--;
		int lb,ub,ans;
		if(str[p]=='('){
			str[p]=')';
			sst.add(p,n,-2);
			s.insert(p);
			ans=*s.begin();
			str[ans]='(';
			sst.add(ans,n,2);
			s.erase(ans);
			ans++;
		}else{
			str[p]='(';
			sst.add(p,n,2);
			s.erase(p);
			lb=-1;ub=n-1;
			while(ub-lb>1){
				int m=(lb+ub)/2;
				if(sst.min(m,n)>=2)ub=m;
				else lb=m;
			}
			str[ub]=')';
			sst.add(ub,n,-2);
			s.insert(ub);
			ans=ub+1;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 24804
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i,n;
  char s[5];
  char c[30]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  scanf("%c",s);
  for(i=0;i<27;i++){
    
    if(c[i]==s[0]){
      printf("%c\n",c[i+1]);
    }
  }
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;
int A[501010];
int B[501010];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=S.size();
	
	FOR(i,N) {
		if(S[i]=='<') A[i+1]=A[i]+1;
	}
	for(i=N-1;i>=0;i--) {
		if(S[i]=='>') B[i]=B[i+1]+1;
	}
	
	ll ret=0;
	FOR(i,N+1) {
		ret+=max(A[i],B[i]);
	}
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> v(m);
    for (int i = 0; i < m; i++) {
        int k;
        std::cin >> k;
        while (k--) {
            int in;
            std::cin >> in;
            v[i].push_back(in - 1);
        }
    }
    std::vector<int> p(m);
    for (int i = 0; i < m; i++) std::cin >> p[i];
    int ret = 0;
    for (int i = 0; i < (1 << n); i++) {
        int s = 0;
        for (int j = 0; j < m; j++) {
            int t = 0;
            for (int k : v[j]) if (i & (1 << k)) t++;
            if (t % 2 == p[j]) s++;
        }
        if (s == m) ret++;
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, m;
ll ans=1;
int main() {
	cin >> n >> m;
	ll now = n;
	while (m > 0) {
		if (m & 1) {
			ans = (ans%MOD)*(now%MOD) % MOD;
		}
		m >>= 1;
		now = (now%MOD)*(now%MOD) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3080
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        c: [u64; n],
    }
    let m = 1000000007;

    let mut dp = vec![0; n];
    dp[0] = 1;
    let mut map = HashMap::new();
    map.insert(c[0], 0);
    for i in 1..n {
        dp[i] = if let Some(&prev) = map.get(&c[i]) {
            if prev == i - 1 {
                dp[i-1]
            } else {
                dp[i-1] + dp[prev]
            }
        } else {
            dp[i-1]
        };
        dp[i] %= m;
        *map.entry(c[i]).or_insert(0) = i;
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 12304
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int main(){

    int k;
    cin>> k;
    //int i=k,j=k,l=k;
    int sum=0;

    for (int i =1;i<=k;i++){
        for (int j =1; j<=k;j++){
            for (int l = 1; l<=k;l++){

                 sum+=gcd(i, gcd(j, l));
            }
        }
    }
    cout<<sum<<"\n";


}


Measured memory_bytes: 3600
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = new int[n];
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(input[i]);
        }

        double sum = 0;
        for (int i = 0; i < n; i++)
        {
            sum += (double)1 / (double)d[i];
        }
        Console.WriteLine((double)1 / (double)sum);
    }

   
}

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

vector< int > parent;
vector< int > Size;
vector< pair< int,int > > edge;
vector< ll > decayed;

ll fallen_bridge;

int find_parent(int index)
{
    return ((parent[index] == index) ? index : (parent[index] = find_parent(parent[index]))); //applying path compression
}

void Union(int a,int b)
{
    int x,y;
    if((x = find_parent(a)) == (y = find_parent(b)))    return;
    fallen_bridge -= ((ll)Size[x])*((ll)Size[y]);
    if(Size[y]>Size[x])swap(x,y);
    parent[y] = x;
    Size[x] += Size[y];
    return;
}

int main()
{
    //freopen("in.txt","r",stdin);
    ll n,m;
    cin >> n >> m;
    parent.resize(n+1);
    Size.resize(n+1);
    for(int i = 1;i <= n;i++){
        parent[i] = i;
        Size[i] = 1;
    }
    edge.resize(m+1);
    for(int i = 1;i <= m;i++){
        int a,b;
        cin >> a >> b;
        edge[i].first = a;
        edge[i].second = b;
    }
    fallen_bridge = n*(n-1)/2;
    decayed.push_back(fallen_bridge);
    for(int i=m;i > 1;i--){
        int a = edge[i].first, b = edge[i].second;
        Union(a,b);
        decayed.push_back(fallen_bridge);
    }
    for(int i = m-1;i>=0;i--)    cout << decayed[i] << endl;
}


Measured memory_bytes: 3828
#include<stdio.h>

int main() {
    int n,t[1000],m,p[1000],x[1000],i,j,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
		scanf("%d",&t[i]);
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&p[i],&x[i]);
		sum = sum + x[i];
		for(j=0;j<n;j++){
			if(j==p[i]-1)
				continue;
			sum = sum + t[j];
		}
		printf("%d\n",sum);
		sum = 0;
	}
    return 0;
}

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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  
  int a = n % x;
  if(a == 0)
    cout << t * (n /x) << endl;
  else
	cout << t * (n/x + 1) << endl;
}

Measured memory_bytes: 3632
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M, R = map(int, input().split())

RS = list(map(int, input().split()))

G = [[] for _ in range(N + 1)]

for i in range(M):
    A, B, C = map(int, input().split())
    G[A].append((B, C))
    G[B].append((A, C))


def dijkstra(s):
    d = [1 << 28] * (N + 1)
    d[s] = 0
    q = []
    heapq.heappush(q, (0, s))

    while q:
        cur = heapq.heappop(q)

        if d[cur[1]] != cur[0]:
            continue

        for nx in G[cur[1]]:
            if d[nx[0]] > cur[0] + nx[1]:
                d[nx[0]] = cur[0] + nx[1]
                heapq.heappush(q, (cur[0] + nx[1], nx[0]))

    return d


DIRS = [dijkstra(s) for s in RS]
MAT = [[d[r] for r in RS] for d in DIRS]

mem = {}


def solve(idx, st):
    if st == (1 << R) - 1:
        return 0
    if (idx, st) in mem:
        return mem[(idx, st)]

    ret = 1 << 28
    for i in range(R):
        if ((st >> i) & 1) == 0:
            ret = min(ret, solve(i, st | (1 << i)) + MAT[idx][i])

    mem[(idx, st)] = ret
    return ret


print(min([solve(i, 1 << i) for i in range(R)]))


Measured memory_bytes: 7348
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

b = []
b << inp
b << inp
b << inp
n = inp[0]
n.times do ||
  d = inp[0]
  3.times do |i|
    3.times do |j|
      b[i][j] = -1 if b[i][j] == d
    end
  end
end
ans = "No"
3.times do |i|
  f = true
  3.times do |j|
    f=false if b[i][j] >= 0
  end
  ans = "Yes" if f
end
3.times do |i|
  f = true
  3.times do |j|
    f=false if b[j][i] >= 0
  end
  ans = "Yes" if f
end
ans = "Yes" if(b[0][0] == b[1][1] and b[1][1] == b[2][2] and b[0][0] == -1)
ans = "Yes" if(b[0][2] == b[1][1] and b[1][1] == b[2][0] and b[0][2] == -1)
puts ans

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

int main(){
 long long N,c,d,p,ans,k;
cin>>N;
  ans=0;
vector<long long>a(N),b(N);
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=N-1;i>=0;i--){
    a[i]+=ans;
    if(a[i]%b[i]!=0){
      ans+=b[i]-a[i]%b[i];
    }
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){

  int i, j, a, b;

  while(1){
    scanf("%d%d",&a,&b);
    for ( i = 0; i < a; i++ ){
      for ( j = 0; j < b; j++ ){
	printf("#");
      }
      printf("\n");
    }
    if(a==0 || b==0)break;
    printf("\n");
 
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

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

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

using namespace std;
const int N=1e5+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
LL n,a[N],z[N],f[N][3];
char cc[2];

int main()
{
    //////
	n=rd(),z[1]=1,a[1]=rd();
	for(int i=2;i<=n;++i) scanf("%s",cc),z[i]=cc[0]=='-'?-1:1,a[i]=rd();
	memset(f,-0x3f3f3f,sizeof(f));
	f[1][0]=a[1];
	for(int i=2;i<=n;++i)
	{
		f[i][0]=max(f[i][0],f[i-1][0]+z[i]*a[i]);
		f[i][0]=max(f[i][0],f[i-1][1]-z[i]*a[i]);
		f[i][1]=max(f[i][1],f[i-1][1]-z[i]*a[i]);
		f[i][0]=max(f[i][0],f[i-1][2]+z[i]*a[i]);
		f[i][1]=max(f[i][1],f[i-1][2]+z[i]*a[i]);
		f[i][2]=max(f[i][2],f[i-1][2]+z[i]*a[i]);
		if(z[i]<0)
		{
			f[i][1]=max(f[i][1],f[i-1][0]+z[i]*a[i]);
			f[i][2]=max(f[i][2],f[i-1][1]-z[i]*a[i]);
		}
	}
	printf("%lld\n",f[n][0]);
    return 0;
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,L; cin>>N>>L;
    int minimum=9999999;
    int ans=0;
    for(int i=1;i<=N;i++){
        int a=abs(L-1+i);
        if(minimum>a){
            ans=i;
        }
        minimum=min(a,minimum);

    }
    int wa=0;
    for(int i=1;i<=N;i++){
        if(i!=ans){
            wa=wa+i;
        }
    }
    cout<<(N-1)*(L-1)+wa;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  int K; cin>>K;
  string S; cin>>S;
  int N=S.length();
  rep(i,min(N,K)) cout<<S[i];
  if(K<N) cout<<"...";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n,k;
    string s;
    cin>>n>>k;
    cin>>s;
    vector<ll> v;
    //sの端か0ならその外側に0個の1を付け加える
    if(s[0]=='0') v.push_back(0);
    int l=0;
    while(l<n){
        char t=s[l];
        int c=0;
        while(s[l]==t){
            l++;
            c++;
        }
        v.push_back(c);
    }
    if(s[n-1]=='0') v.push_back(0);
    /*
    11101010110011
    311111222
    00010
    03110  両端が0なので0個の1を考える
    累積和の問題に落ちた
     */
    int m=v.size();
    ll sum[m+1]={};
    rep(i,m){
        sum[i+1]=sum[i]+v[i];
    }
    
    //k回操作するまでに全部イケちゃうとき。イケイケ
    if((m-1)/2<k){
        cout<<sum[m]<<endl;return 0;
    }

    ll ans=0;
    for(int i=2*k+1;i<=m;i+=2){
        ans=max(ans,sum[i]-sum[i-2*k-1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N,M;
  while(cin >> N >> M){
    int ans = 0;

    vector<int> s(N+10);
    REP(i,M){
      int L,R; cin >> L >> R;
      ++s[L];
      --s[R+1];
    }
    REPE(i,N) s[i+1] += s[i];
    //dump(s);

    FORE(i,1,N) if(s[i] == M) ++ans;
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 640
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input! {
        N: usize,
    }

    let mut sum = 0;
    for res in 1.. {
        if res * res >= N { break; }
        if N % res == 0 {
            let m = N / res - 1;
            if m <= res { continue; }
            sum += m;
        }
    }
    println!("{}", sum)
}

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

int main(){
  int H,W,K;cin>>H>>W>>K;
  char A[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++) cin>>A[i][j];
  }
  int ans=0;
  for(int s=0;s<(1<<H);s++){//sを2進表示した時の6桁数字を縦の選び方と考える
    for(int t=0;t<(1<<W);t++){//tは横
      int black=0;
      //以下、あるsとtに対してH*Wマスを探索
      //s,tのbitをi,jずらした(2でi,j回割った)ときちょうど1なら、そこは赤く塗られているので除外      
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          if((s & 1<<i)==0 && (t & 1<<j)==0 && A[i][j]=='#') black++;
          //if((s>>i & 1)==0 && (t>>j & 1)==0 && A[i][j]=='#') black++;
          
        }
      }
      if(black==K) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (size_t i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (size_t i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define INF 1e7

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

  for (int i = a; i < 1000; i++) {
    if (i % 10 == i/10 % 10 && i % 10 == i/100) {
      cout<<i<<endl;
      break;
    }
  }

  return 0;
}


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

int n, m;
int s[100005], t[100005];
vector<int> edge[10005], redge[10005];
bool used[10005];
vector<int> ord;
int comp[10005];
int noin[10005], noout[10005];

void dfs1(int a){
  used[a]=true;
  for(int i=0; i<edge[a].size(); i++){
    int b=edge[a][i];
    if(!used[b]) dfs1(b);
  }
  ord.push_back(a);
}

void dfs2(int a, int c){
  //printf("%d ", a);
  used[a]=true;
  comp[a]=c;
  for(int i=0; i<redge[a].size(); i++){
    int b=redge[a][i];
    if(!used[b]) dfs2(b, c);
  }
}

int main(){
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> s[i] >> t[i];
    edge[s[i]].push_back(t[i]);
    redge[t[i]].push_back(s[i]);
  }
  fill(used, used+n, false);
  for(int i=0; i<n; i++)
    if(!used[i]) dfs1(i);
  int cnt=0;
  fill(used, used+n, false);
  for(int i=n-1; i>=0; i--){
    if(!used[ord[i]]){
      dfs2(ord[i], cnt++);
      //printf("\n");
    }
  }
  fill(noin, noin+n, 1);
  fill(noout, noout+n, 1);
  for(int i=0; i<m; i++){
    if(comp[s[i]]!=comp[t[i]]){
      noout[comp[s[i]]]=0;
      noin[comp[t[i]]]=0;
    }
  }
  int ans=0;
  if(cnt>1){
    int noincnt=0, nooutcnt=0;
    for(int i=0; i<cnt; i++) noincnt+=noin[i];
    for(int i=0; i<cnt; i++) nooutcnt+=noout[i]; 
    ans=max(noincnt, nooutcnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6460
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,sum=0;
  cin>>n;
  vector<int> a(n),b(n),c(n-1);
  rep(i,n) {
    cin>>a[i];
    a[i]--;
  }
  rep(i,n) cin>>b[i];
  rep(i,n-1) cin>>c[i];
  rep(i,n){
    sum+=b[a[i]];
    if(i>0 && a[i-1]+1==a[i])
      sum+=c[a[i-1]];
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
using namespace std ;
#define ll long long 
#define all(x) x.begin() , x.end()
int const N = 1e6+1 , MOD = 1e9 + 7; 
int main(){
     // freopen("input.txt" ,"r",stdin);
      int x1 , y1, x2 , y2 , x3,x4,y3,y4;
      scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
      int deltaX = x2 - x1 , deltaY = y2 - y1 ;
      x3 = x2 - deltaY;
      cout<<x3<<" ";
      y3 = y2 + deltaX;
      cout<<y3<<" ";
      x4 = x1 - deltaY ; 
      cout<<x4<<" ";
      y4 = y1 + deltaX;
      cout<<y4<<" ";

}                   

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

int main()
{
		int a, b, c, d;	
		cin >> a >> b >> c >> d;
		
		int train = 1001;
		int bus = 1001;
		if (train > a) {
				train = a;
		}
		if (train > b) {
				train = b;
		}
		if (bus > c) {
				bus = c;
		}
		if (bus > d) {
				bus = d;
		}

		int ans = train + bus;
		cout << ans << endl;

		return 0;
}


Measured memory_bytes: 256
while 1:
	try:
		h=[input() for i in [1]*5]
		l=set(h)
		if 1 in h and 2 in h:w=1
		if 1 in h and 3 in h:w=3
		if 2 in h and 3 in h:w=2
		if len(l)==3 or len(l)==1:
			for i in h:print 3
		else:
			for i in h:print 1 if i==w else 2
	except:
		break

Measured memory_bytes: 4216
N, C = gets.split.map(&:to_i)
xvs = N.times.map { gets.split.map(&:to_i) }

# 右回り(時計回り)
r_maxes = Array.new(N)
current = 0
(0...N).each do |i|
  x, v = xvs[i]
  if i == 0
    current = v - x
    r_maxes[i] = current
  else
    px = xvs[i - 1][0]
    current = current - (x - px) + v
    r_maxes[i] = [
      current,
      r_maxes[i - 1]
    ].max
  end
end

# 左回り(反時計回り)
l_maxes = Array.new(N)
current = 0
(0...N).each do |i|
  pos = N - i - 1
  x, v = xvs[pos]
  if pos == N - 1
    current = v - (C - x)
    l_maxes[i] = current
  else
    px = xvs[pos + 1][0]
    current = current - (px - x) + v
    l_maxes[i] = [
      current,
      l_maxes[i - 1]
    ].max
  end
end

ans = 0
(0..N).each do |r_count|
  l_count = N - r_count
  r_max = r_count > 0 ? r_maxes[r_count - 1] : 0
  l_max = l_count > 0 ? l_maxes[l_count - 1] : 0
  sum = r_max + l_max
  sum -= if r_count == 0 || l_count == 0
    0
  else
    r_distance = xvs[r_count - 1][0]
    l_distance = C - xvs[N - l_count][0]
    [r_distance, l_distance].min
  end
  ans = sum if sum > ans
end
puts ans


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

int main()
{
    string S;
    cin >> S;
    int size = S.size();
    rep(i, size)
    {
        if ((i % 2 == 0) && (S.at(i) != 'R' && S.at(i) != 'U' && S.at(i) != 'D'))
        {
            cout << "No" << endl;
            return 0;
        }
        else if ((i % 2 != 0) && (S.at(i) != 'L' && S.at(i) != 'U' && S.at(i) != 'D'))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
toInt :: (String -> Int)
toInt x = read x ::Int

getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y
    where
      toInt x = read x ::Int

getInt = do
	x <- getLine
	let y = toInt x
	return y

coopon::Int->Int
coopon y = y+(y `div` 100)

solv x y
	|x <= y = 0
	|otherwise = 1 + solv x (coopon y)


main = do
	x <- getInt
	let y = solv x 100 
	print y

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> b(n - 1);
  rep(i, n - 1) cin >> b[i];
  vector<int> c(n);
  c[0] = b[0];
  repz(i, 1, n - 1) { c[i] = min(b[i], b[i - 1]); }
  c[n - 1] = b[n - 2];
  cout << accumulate(ALL(c), 0) << endl;
  return 0;
}


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

int main() {
  int x;
  cin >> x;
  while(true) {
    bool flg = true;
    for(int i = 2; i < sqrt(x); ++i) {
      if(x % i == 0) {
        flg = false;
        break;
      } else continue;
    }
    if(flg) {
      cout << x << endl;
      return 0;
    }
    ++x;
  }
  
    
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if( b == 0 )
    return a;
  else
    return gcd(b,a%b);
}
int lcm(int a,int b){
  long long int x = a*b;
  return x/gcd(a,b);
}
int main(){
  int n;
  cin >> n;
  int arr[n];
  for(int i = 0 ; i < n ; i++)
    cin >> arr[i];
  int num = 1,denm = 0;
  for(int i = 0 ; i < n ; i++)
    num = lcm(num,arr[i]);
  for(int i = 0 ; i < n ; i++)
  denm = denm + num/arr[i];
  
  printf("%0.5f",(float)num/(float)denm);
  
  return 0;
}
  
    

Measured memory_bytes: 256
#!/usr/bin/env python3
#E

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def comb(n, r):
    return fact[n]*pow(fact[n-r], mod-2, mod)*pow(fact[r], mod-2, mod) % mod
n = I()
ab = [LI() for _ in range(n)]

fact = [1]*(n+1)
for i in range(1, n+1):
    fact[i] = i * fact[i-1]
    fact[i] %= mod

x = defaultdict(lambda : 0)
y = defaultdict(lambda : 0)
z = defaultdict(lambda : 0)
tmp = 0
for a, b in ab:
    if a == 0 and b == 0:
        tmp += 1
    elif a == 0:
        x[0] += 1
        z[0] = 1
    elif b == 0:
        y[0] += 1
        z[0] = 1
    else:
        if a * b > 0:
            g = math.gcd(a, b)
            a //= g
            b //= g
            x[(abs(a), abs(b))] += 1
            z[(abs(a), abs(b))] = 1
        else:
            g = math.gcd(a, b)
            a //= g
            b //= g
            y[(abs(b), abs(a))] += 1
            z[(abs(b), abs(a))] = 1

ans = 1
for i in z.keys():
    ans *= (2**x[i] + 2**y[i] - 1)
    ans %= mod
ans -= 1
ans += tmp
ans %= mod
print(ans)






Measured memory_bytes: 198360
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var m = cin.ReadInt;
            var d = cin.ReadInt;

            var ans = 0;

            for (int mi = 1; mi <= m; mi++)
            {
                for (int di = 22; di <= d; di++)
                {
                    if ((di % 10 >= 2) && (di % 10) * (di / 10) == mi)
                    {
                        ans++;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 13268
/**
 * Moore-Bellman-Ford's Algorithm
 *
 * O(|V||E|)
 */

#include <vector>
using namespace std;

using Int = int;
Int INF = 1e9;
struct edge{
  int to;
  Int cost;
};
vector<Int> BellmanFord(const vector<vector<edge>>& G,int s){
  vector<Int> dist(G.size(),INF);
  dist[s] = 0;
  for(int i = 1;i < G.size();i++){
    for(int v = 0;v < G.size();v++){
      for(auto& e : G[v]){
        if(dist[v] == INF) continue;
        if(dist[e.to] > dist[v] + e.cost){
          dist[e.to] = dist[v] + e.cost;
        }
      }
    }
  }
  return dist;
}

vector<bool> NegativeCycle(const vector<vector<edge>>& G,vector<Int> dist){
  vector<bool> neg(G.size(),false);
  for(int i = 1;i < G.size();i++){
    for(int v = 0;v < G.size();v++){
      for(auto& e : G[v]){
        if(dist[v] == INF) continue;
        if(dist[e.to] > dist[v] + e.cost){
          neg[v] = true;
          dist[e.to] = dist[v] + e.cost;
        }
        neg[e.to] = neg[e.to] || neg[v];
      }
    }
  }
  return neg;
}

#include <iostream>

int main(){
  int v,e,r;
  cin >> v >> e >> r;
  vector<vector<edge>> G(v);
  for(int i = 0;i < e;i++){
    int s,t,d;
    cin >> s >> t >> d;
    G[s].push_back({t,d});
  }
  auto dist = BellmanFord(G,r);
  auto neg = NegativeCycle(G,dist);

  for(int i = 0;i < v;i++){
    if(neg[i]){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  for(int i = 0;i < v;i++){
    if(dist[i] == INF)
      cout << "INF" << endl;
    else
      cout << dist[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 3176