akhauriyash/Code-Regression huggingface dataset:
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

ll dp[4010][4010];

int main() {
    string S;
    cin >> S;
    int N = S.length();

    int r[N * 2 + 1], b[N * 2 + 1];
    r[0] = b[0] = 0;
    for (int i = 1; i <= N; ++i) {
        r[i] = r[i - 1] + ('2' - S[i - 1]);
        b[i] = b[i - 1] + (S[i - 1] - '0');
    }
    for (int i = N + 1; i <= N * 2; ++i) {
        r[i] = r[i - 1];
        b[i] = b[i - 1];
    }

    dp[0][0] = 1;
    for (int x = 0; x <= r[N]; ++x) {
        for (int y = 0; y <= b[N]; ++y) {
            if (r[x + y + 1] > x) {
                dp[x + 1][y] += dp[x][y];
                dp[x + 1][y] %= MOD;
            }
            if (b[x + y + 1] > y) {
                dp[x][y + 1] += dp[x][y];
                dp[x][y + 1] %= MOD;
            }
        }
    }

    cout << dp[r[N]][b[N]] << endl;
    return 0;
}


Measured memory_bytes: 123520
#include<stdio.h>
#define INF 1000000
#define N 101
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n;
int M[N][N];
void DKR(void);
int main(){
  int k,u,c,v,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INF;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }
  DKR();
  return 0;
}

void DKR(void){
  int d[N],color[N],min,u,i,v;
  for(i=0;i<n;i++){
    d[i]=INF;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;

  while(1){
    min=INF;
    u=NIL;
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < min){
        min=d[i];
        u=i;
      }
    }

    if(u==NIL)break;
    color[u]=BLACK;

    for(v=0;v<n;v++){
      if(color[v] != BLACK && M[u][v] != INF){
        if(d[u]+M[u][v] < d[v]){
          d[v]= d[u] + M[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(d[i] == INF? -1 : d[i]));
  }
}



Measured memory_bytes: 2060
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
  int N;
  int n;
  cin >> N;
  if(N % 2 == 1){
    n = N / 2 + 1;
    cout << setprecision(10) << (float)n/N;
  }else if(N % 2 == 0){
    cout << setprecision(10) << (float)1/2;
  }
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

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

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let N: i32 = read(&mut s).unwrap();

    if N % 2 == 0 {
        println!("{}", N);
    } else {
        println!("{}", N * 2);
    }
}


Measured memory_bytes: 4352
def main():
    N, T = map(int, input().split())
    A = list(map(int, input().split()))

    mi = 10**10
    diff = 0
    r = 0
    for a in A:
        if a < mi:
            mi = a
        elif a - mi == diff:
            r += 1
        elif a - mi > diff:
            r = 1
            diff = a - mi
    return r

print(main())


Measured memory_bytes: 14252
function AlterAltar()
    data = readlines()
    reg = r"^R+W*$"
    occursin(reg, data[2]) && return println(0)
    C = [d=='R' ? true : false for d in data[2]]
    R = sum(C)
    ans = sum([!c for c in C[1:R]])
    return println(ans)
end
AlterAltar()

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

long long inf=1e15;

int main(){
    int n;
    long long lW;
        cin >> n >> lW;
    vector<int> v(n+1, 0);
    vector<long long> w(n+1, inf);
        for(int i=1; i<n+1; i++) cin >> v[i] >> w[i];

    vector<vector<long long>> dp(n+1, vector<long long>(10001, inf));
        for(int i=0; i<n+1; i++) dp[i][0]=0;
    for(int i=1; i<n+1; i++){
        for(int j=1; j<10001; j++){
            if(j-v[i]>=0){
                dp[i][j]=min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }

    for(int i=10000; i>=0; i--){
        if(dp[n][i]<=lW){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 10788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < l.length; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();

		int cnt = 1;
		int d = 0;
		for (int i = 0; i < l.length; i++) {
			d += l[i];
			if (d <= x) {
				cnt++;
			} else {
				break;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long 
int main() {
	ll int n,k;
	cin>>n>>k;
    ll	int x=n%k;
ll 	int y=k-x;
if(y<0){
    y=y*(-1);
}
 ll 	int z=min(x,y);
	cout<<z;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n;
  cin >> n;
  int a[200001] = {};

  LOOP(i,n-1){
    int b;
    cin >> b;
    a[b]++;
  }
  LOOP1(i,n){
    cout << a[i] << endl;
  }
}


Measured memory_bytes: 5196
import sys
from math import ceil

N, Y = [int(x) for x in raw_input().split(" ")]

y = Y / 1000

minC = max(int(ceil((5*N - y)/4.)), 0)
maxC = min(int((10*N-y)/9.), N)

if maxC < minC:
    print "-1 -1 -1"
    sys.exit()

for c in range(minC, maxC+1):
    if ((10*N-y-9*c)%5 == 0) and ((-5*N+y+4*c)%5 == 0):
        print "%d %d %d"%((-5*N+y+4*c)/5, (10*N-y-9*c)/5, c)
        sys.exit()
print "-1 -1 -1"

Measured memory_bytes: 2692
S=raw_input()
S=S[::-1]
l=len(S)

dp=[ 0 for j in range(13) ]
dp[0]=1

mod=10**9+7

dp2=[ 0 for _ in range(13) ]

keta=1

for i in range(1,l+1):
	dp2=[0]*13
	for j in range(13):
		if dp[j]!=0:
			if S[i-1]=="?":
				for k in range(10):
					next=(k*keta+j)%13 
					dp2[next]+=dp[j]
					dp2[next]%=mod
			else:
				k=int(S[i-1])
				next=(k*keta+j)%13
				dp2[next]+=dp[j]
				dp2[next]%=mod

	dp=dp2
	keta=(keta*10)%13

print dp[5]


Measured memory_bytes: 33384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt();
        int w = in.nextInt();
        int m = in.nextInt();
        Map<Integer, Integer> hmap = new HashMap<>();
        Map<Integer, Integer> wmap = new HashMap<>();
        Set<Integer>[] board = new Set[h+1];
        for(int i=1; i<h+1; i++) {
            board[i] = new HashSet<>();
        }
        for(int i=0; i<m; i++) {
            int hi = in.nextInt();
            if(hmap.containsKey(hi)) {
                hmap.put(hi, hmap.get(hi)+1);
            }
            else {
                hmap.put(hi, 1);
            }
            int wi = in.nextInt();
            if(wmap.containsKey(wi)) {
                wmap.put(wi, wmap.get(wi)+1);
            }
            else {
                wmap.put(wi, 1);
            }
            board[hi].add(wi);
        }
        int hmax = 0;
        Iterator<Integer> it = hmap.values().iterator();
        while(it.hasNext()) {
            hmax = Math.max(hmax, it.next());
        }
        int wmax = 0;
        it = wmap.values().iterator();
        while(it.hasNext()) {
            wmax = Math.max(wmax, it.next());
        }
        
        Set<Integer> hCandidates = new HashSet<>();
        it = hmap.keySet().iterator();
        while(it.hasNext()) {
            int key = it.next();
            if(hmap.get(key) == hmax) {
                hCandidates.add(key);
            }
        }
        Set<Integer> wCandidates = new HashSet<>();
        it = wmap.keySet().iterator();
        while(it.hasNext()) {
            int key = it.next();
            if(wmap.get(key) == wmax) {
                wCandidates.add(key);
            }
        }
        
        boolean exists = true;
        it = hCandidates.iterator();
        while(it.hasNext()) {
            int hi = it.next();
            Iterator<Integer> it2 = wCandidates.iterator();
            while(it2.hasNext()) {
                int wi = it2.next();
                if(!board[hi].contains(wi)) {
                    exists = false;
                    break;
                }
            }
            if(!exists) {
                break;
            }
        }
        System.out.println(hmax + wmax - (exists ? 1 : 0));
    }
}


Measured memory_bytes: 207684
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
#include <cstring>
using namespace std;

#define rep(i,N) for(int i = 0;i < N;++i)
using LL = long long;

typedef pair<LL, LL> P;

char n[20];

int main() {
	cin >> n;
	int sum = 0, x = atoi(n);
	rep(i, strlen(n)) {
		sum += n[i] - '0';
	}
	if (x % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k;
  string s;
  cin>>k;
  cin>>s;
  int n=s.length();
  if(n<=k)
    cout<<s;
  else if(n>k)
  {
    for(int i=0;i<k;i++)
      cout<<s[i];
    cout<<"...";
  }
}

Measured memory_bytes: 3596
//abc174_d.cpp
//Sat Sep 12 10:35:13 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;

	ll rnum = 0;
	rep(i,n){
		if (s[i]=='R'){
			rnum++;
		}
	}
	ll ans = 0;
	rep(i,rnum){
		if (s[i]=='W'){
			ans++;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc098() {
	string s;
	ll K;
	cin >> s >> K;

	vector<string> sum;
	std::map<string, bool> m;
	string tmp;
	rep(i, s.size()) {
		rep(j, 5) {
			tmp = s.substr(i, j + 1);
			if (m.find(tmp) == m.end()) {
				m.emplace(tmp, true);
				sum.push_back(tmp);
			}
		}
	}

	sort(ALL(sum));

	cout << sum[K - 1] << "\n";
}

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

	solve_abc098();

	return 0;
}


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

long f[1111111] = { 1 }, e[1111111] = { 1 }, l[1111111];
int main() {
	int q, p = 1e6 + 3;
	cin >> q;
	for (int i = 0; i < p; i++) {
		f[i + 1] = f[i] * (i + 1) % p;
		e[i + 1] = e[i] * 2 % p;
	}
	for (int i = 0; i < p; i++)
		l[e[i]] = i;

	for (int i = 0; i < q; i++) {
		int x, d, n;
		scanf("%d%d%d", &x, &d, &n);
		if (!x) {
			cout << 0 << '\n';
			continue;
		}
		if (!d) {
			cout << e[l[x] * n % (p - 1)] << '\n';
			continue;
		}
		long y = e[(l[x] - l[d] + p - 1) % (p - 1)], z = y + n - 1;
		if (z >= p) {
			cout << 0 << '\n';
			continue;
		}
		cout << e[(l[f[z]] - l[f[y - 1]] + p - 1 + l[d] * n) % (p - 1)] << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define N 55
#define S 5005
#define ll long long
#define set(a,v) memset(a,v,sizeof(a))
int n,m,s,lim=5e3,c[N],d[N];bool vs[N];ll dp[N][S];
struct Edge {int v,a,b;};vector<Edge> e[N];queue<int> q;
void addE(int u,int v,int a,int b)
{
	e[u].push_back((Edge) {v,a,b});
	e[v].push_back((Edge) {u,a,b});
}
void SPFA()
{
	set(dp,0x3f);dp[1][s]=0;vs[1]=1;q.push(1);
	while(!q.empty())
	{
		int u=q.front();q.pop();vs[u]=0;
		for(int i=c[u];i<=lim;++i)
			dp[u][i]=min(dp[u][i],dp[u][i-c[u]]+d[u]);
		for(int i=0,v,a,b,fl;i<e[u].size();++i)
		{
			v=e[u][i].v;a=e[u][i].a;b=e[u][i].b;fl=0;
			for(int j=a;j<=lim;++j) if(dp[u][j]+b<dp[v][j-a])
				dp[v][j-a]=dp[u][j]+b,fl=1;
			if(fl && !vs[v]) vs[v]=1,q.push(v);
		}
	}
}
int main()
{
	scanf("%d %d %d",&n,&m,&s);s=min(s,lim);
	for(int i=1,u,v,a,b;i<=m;++i)
		scanf("%d %d %d %d",&u,&v,&a,&b),addE(u,v,a,b);
	for(int i=1;i<=n;++i) scanf("%d %d",&c[i],&d[i]);SPFA();
	for(int i=2;i<=n;++i)
	{
		ll res=1e18;
		for(int j=0;j<=lim;++j) res=min(res,dp[i][j]);
		printf("%lld\n",res);
	}return 0;
}

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


int main()
{
    int n, p;
    while(cin >> n >> p && n && p) {
        int step = 0, wan = p;
        int have[n];
        fill(have, have + n, 0);
        while(true) {
            if(have[step % n] == p) 
                break;
            
            if(wan > 0) {
                have[step % n]++;
                wan--;
            } else {
                wan = have[step % n];
                have[step % n] = 0;
            }
            step++;
        }
        cout << (step % n) << endl;
    }
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << "\n";

    return 0;
}


Measured memory_bytes: 3632
function main(input) {
	const args = input.split(' ');
	const 	N = parseInt(args[0],10);
		A = parseInt(args[1],10);
		B = parseInt(args[2],10);

	const nums = Array.from(new Array(N),(v,i) => ++i).filter((i) => {
	   var n = i.toString().split('').reduce((p,c) => p + parseInt(c),0);
	   return (n >= A && n <= B);	
	});

	console.log(nums.reduce((p,c) => p + c,0));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 int n;
 cin >> n;
 vector<long long int> a(n);
 for(auto& i: a) cin >> i;
 long long int ans = 0;
 long long int cur = a[0];
 for(int i = 1; i < n; i++) {
  if(a[i] < cur) ans += cur - a[i];
  cur = max(cur, a[i]);
 }
 
 cout << ans << '\n';
}


Measured memory_bytes: 4756
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

char in[1002];
int sum[1002][1002][3];
int M,N,K;
int main() {
	cin >> M >> N >> K;
	for(int i=1;i<=M;i++){
		cin >> (in+1);
		for(int j=1;j<=N;j++){
			switch(in[j]){
				case 'J': sum[i][j][0]++; break;
				case 'O': sum[i][j][1]++; break;
				case 'I': sum[i][j][2]++; break;
			}
			for(int k=0;k<3;k++){
				sum[i][j][k]+=sum[i][j-1][k];
			}
		}
	}
	for(int j=1;j<=N;j++){
		for(int i=1;i<=M;i++){
			for(int k=0;k<3;k++){
				sum[i][j][k]+=sum[i-1][j][k];
			}
		}
	}
	for(int i=0;i<K;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a--;b--;
		auto sp="";
		for(int k=0;k<3;k++){
			int r=sum[c][d][k]-sum[a][d][k]-sum[c][b][k]+sum[a][b][k];
			cout << sp << r;
			sp=" ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 12792
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>

using namespace std;

int main(){

    int a,b;
    string ans;
    cin >> a >> b;
    if(b==a){
        ans = "Yes";
    }
    else{ans = "No";}
    cout << ans <<  endl;
}
    

Measured memory_bytes: 256
x = list(map(int, input().split()))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
y = Base_10_to_n(x[0], x[1])
print(len(str(y)))

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

using namespace std;

using ll = long long;

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

    // (R + x) / 2 = G <=> x = 2G - R
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << "01"[i < b ^ j < a];
        }
        cout << '\n';
    }

    //int x = 0, y = 0;
    //int c = w - 2 * a;
    //int d = h - 2 * b;
    //int u = a * w, v = b * h;
    //int f = 0;
    //while (1) {
    //    if (c == 0 && d == 0) {
    //        if (u == v) f = 1;
    //        break;
    //    }
    //}

    //if (f == 0) {
    //    cout << "No" << endl;
    //} else {

    //}

    //(W-X)*A+X*(W-A)=WA-XA+XW-XA=W*(X+A)-2XA=AW+X(W-2A)
    //AW+X(W-2A)=BH+Y(H-2B)

    return 0;
}

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

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

int main()
{
    int n;
    cin >> n;
    int ans = 1;
    while (ans <= n)
    {
        ans *= 2;
    }
    cout << ans / 2 << endl;
    return 0;
}


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

using namespace std;
// 寿司を食べたい！！
typedef long long int64;

struct SegmentTree
{
  vector< int64 > seg, lazy;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, 0);
    lazy.assign(2 * sz - 1, -1);
  }

  void push(int k)
  {
    if(lazy[k] >= 0) {
      if(k < sz - 1) {
        lazy[2 * k + 1] = lazy[k] >> 1LL;
        lazy[2 * k + 2] = lazy[k] >> 1LL;
      }
      seg[k] = lazy[k];
      lazy[k] = -1;
    }
  }

  int64 query(int a, int b, int k, int l, int r)
  {
    push(k);
    if(a >= r || b <= l) {
      return (0);
    } else if(a <= l && r <= b) {
      return (seg[k]);
    } else {
      return (query(a, b, 2 * k + 1, l, (l + r) >> 1) +
              query(a, b, 2 * k + 2, (l + r) >> 1, r));
    }
  }

  int64 query(int a, int b)
  {
    return (query(a, b, 0, 0, sz));
  }

  void update(int a, int b, int64 x, int k, int l, int r)
  {
    push(k);
    if(a >= r || b <= l) {
      return;
    } else if(a <= l && r <= b) {
      lazy[k] = x * (r - l);
      push(k);
    } else {
      update(a, b, x, 2 * k + 1, l, (l + r) >> 1);
      update(a, b, x, 2 * k + 2, (l + r) >> 1, r);
      seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
    }
  }

  void update(int a, int b, int64 x)
  {
    update(a, b, x, 0, 0, sz);
  }

};

signed main()
{
  int N, Q;

  cin >> N >> Q;
  SegmentTree tree(N);
  while(Q--) {
    int64 A, B;
    cin >> A >> B;
    int low = 0, high = A;
    while(high - low > 1) {
      int mid = (low + high) >> 1;
      if(tree.query(mid, mid + 1) * (A - mid) - tree.query(mid, A) > B) low = mid;
      else high = mid;
    }
    if(tree.query(low, low + 1) * (A - low) - tree.query(low, A) > B) ++low;
    int64 v = tree.query(low, A) + B;
    int64 width = A - low;
    tree.update(low, A, v / width + 1);
    tree.update(low + v % width, A, v / width);
  }
  for(int i = 0; i < N; i++) {
    cout << tree.query(i, i + 1) << endl;
  }
}


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

constexpr int MAX_N = 20;
int p[MAX_N];

int main() {
  int N;
  cin >> N;
  for (int i{}; i < N; ++i) {
    cin >> p[i];
  }

  int ans{};
  for (int i{1}; i < N-1; ++i) {
    int lo = min(p[i-1], p[i+1]);
    int hi = max(p[i-1], p[i+1]);
    if (lo < p[i] && p[i] < hi) {
      ++ans;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
K = int(input())

if K%2 == 0 or K%5 == 0:
    print(-1)

elif K%7 == 0:
    x = -1
    b = 9*K/7
    c = 10%b

    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

    print(x)

else:
    x = -1
    b = 9*K
    c = 10%b
    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b
        #print(c)
    print(x)

Measured memory_bytes: 64624
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if (k<=a) cout << k << endl;
    else if (k<=a+b) cout << a << endl;
    else cout << a*2+b-k << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	set<string>good;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		good.insert(s);
	}
	cout<<good.size();
	return 0;
}

Measured memory_bytes: 19252
#include <bits/stdc++.h>
using namespace std;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
const int maxn = 50 + 5;

int N , cnt[maxn][26];
string s[maxn];

int main( int argc , char * argv[] ){
	cin >> N;
	for(int i = 1 ; i <= N ; ++ i){
		cin >> s[i];
		for(auto it : s[i])
			++ cnt[i][it - 'a'];
	}
	string ans;
	for(int i = 0 ; i < 26 ; ++ i){
		int mi = cnt[1][i];
		for(int j = 2 ; j <= N ; ++ j)
			mi = min( mi , cnt[j][i] );
		while( mi -- )
			ans.push_back( (char)(i + 'a' ));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cstdio>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;
constexpr int like = 753;

string s;
int ret = 1 << 29;
int main(void) {
	cin >> s;
	for (int i = 0; i < s.size() - 2; i++) {
		int x = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		if (ret > abs(like - x))
			ret = abs(like - x);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    bool ans = false;
    for (int i = A ; i <= A*B ; i += A) {
        if (i%B == C) ans = true;
    }
    
    cout<<(ans ? "YES" : "NO")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	ll n, m, ans = 0;
	cin >> n >> m;
	ans += (n - m) * 100;
	cout << 1900 * m*std::pow(2, m)+std::pow(2,m)*ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int mod=1e9+7;
int main()
{
    long long n,sum,i;
    while(cin>>n)
    {
        sum=1;
        for(i=1;i<=n;i++)
        {
            sum*=i;
            sum%=mod;
        }
        cout<<sum<<endl;
    }
    return 0;
}


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

int main(){
    int n;cin>>n;
    vector<int> v(n);
    for(auto &i : v) cin>>i;
    sort(v.begin(),v.end());
    long long ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=(lower_bound(v.begin(),v.end(),v[i]+v[j])-v.begin())-j-1;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const double eps=1e-16;
const int N=100005;
int n,T[N];
double val[N];
using namespace std;

struct node
{
	double a,b,c,k;
	int key;
}L[N];
bool cmp(node a,node b){return a.k>b.k;}
/*struct node
{
	int t,next;
}adj[N<<1];
void add(int s,int t)
{
	adj[++now]=(node){t,head[s]};
	head[s]=now;
}*/
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
//void upd(int& x,int y){if (x==-1) x=y;else x=max(x,y);}
bool cmpval(double a,double b){return a<b;}
int find(double k)
{
	int lb=0,rb=n+1,mid;
	while (lb<rb-1)
	{
		mid=lb+rb>>1;
		if (val[mid]>=k) rb=mid;
		else lb=mid;
	}
	return rb;
}
int query(int x){int tmp=0;while (x) tmp+=T[x],x-=x&(-x);return tmp;}
void ins(int x){while (x<=n) T[x]++,x+=x&(-x);}
ll calc(double k)
{
	memset(T,0,sizeof(T));
	int i;ll rtn=0;
	for (i=1;i<=n;i++) val[i]=(L[i].c-k*L[i].a)/L[i].b;
	sort(val+1,val+1+n,cmpval);
	for (i=1;i<=n;i++) L[i].key=find((L[i].c-k*L[i].a)/L[i].b);//,printf ("%d\n",L[i].key);puts("");
	for (i=1;i<=n;i++)
	rtn+=query(L[i].key),ins(L[i].key);
	/*for (i=1;i<=n;i++)
	{
		double tmp=L[i].c/L[i].a;
		if (tmp<=k) rtn++;
	}
	if (k>=0.0) rtn+=n+1;*/
	//printf ("%.3lf %d\n",k,rtn);
	return rtn;
}
double work()
{
	double lb=-1000000000.0,rb=1000000000.0,mid;
	int i;
	ll th=(1ll*n)*(1ll*n-1)/2;
	th=(th+1)/2;
	for (i=1;i<=80;i++)
	{
		mid=(lb+rb)/2;
		if (calc(mid)>=th) rb=mid;
		else lb=mid;
	}
	return lb;
}
int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d",&n);
	int i;
	for (i=1;i<=n;i++)
	{
		scanf ("%lf %lf %lf",&L[i].a,&L[i].b,&L[i].c);
		if (L[i].b<0) L[i].a*=-1,L[i].b*=-1,L[i].c*=-1;
		L[i].k=L[i].a/L[i].b;
	}
	sort(L+1,L+1+n,cmp);
	double ansx=work();
	for (i=1;i<=n;i++) swap(L[i].a,L[i].b),L[i].k=1.0/L[i].k;
	for (i=1;i<=n;i++)
	if (L[i].b<0) L[i].a*=-1,L[i].b*=-1,L[i].c*=-1;
	sort(L+1,L+1+n,cmp);
	double ansy=work();
	printf ("%.12lf %.12lf",ansx,ansy);
	return 0;
}


Measured memory_bytes: 5500
N = int(input())
C = [int(input()) for _ in range(N)]
C = [x for (x,y) in zip(C[:-1], C[1:]) if x!=y] + [C[-1]]

SUM = 1
DP_dict = {}

for c in C:
  if c in DP_dict.keys():
    SUM += DP_dict[c]
  DP_dict[c] = SUM

print(SUM % (10**9+7))

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, z, w;
    cin >> n >> z >> w;

    vector<int64_t> a(n + 1, w);
    for (auto i : irange(0L, n)) {
        cin >> a[i + 1];
    }

    vector<vector<int64_t>> score(2, vector<int64_t>(n + 1));
    for (auto i : irange(1L, n + 1)) {
        score[0][i] = score[1][i] = abs(a[n] - a[n - i]);
        for (auto j : irange(1L, i)) {
            score[0][i] = max(score[0][i], score[1][j]);
            score[1][i] = min(score[1][i], score[0][j]);
        }
    }

    cout << score[0][n] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 



int main(void){
    ll L;
    cin>>L;
    double edge = (double)L/3;
    printf("%.15lf",edge*edge*edge);
    cout<<endl;
    return 0;
}



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

int main() {
  int A,B;cin>>A>>B;
  int preuse=1;
  int ans=0;
  while(true){
    if(B==1) break;
    ans++;
    preuse += A-1;
    if(preuse>=B) break;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3684
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		new Main().run();
		}
	public void run() {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		move(sx,tx,'R');
		move(sy,ty,'U');
		move(sx,tx,'L');
		move(sy,ty+1,'D');
		move(sx,tx+1,'R');
		move(sy,ty+1,'U');
		move(0,1,'L');
		move(0,1,'U');
		move(sx,tx+1,'L');
		move(sy,ty+1,'D');
		move(0,1,'R');
		System.out.println();
		sc.close();
	}
	public void move(int s, int t, char C) {
		for (int i = 0; i < t - s; i++) {
			System.out.print(C);
		}
	}
}


Measured memory_bytes: 27524
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		bool l = false;
		if (i % 3 == 0) {
			cout << " " << i;
			l = true;
		}
		if (!l) {
			string s = to_string(i);
			for (int i = 0; i < s.length(); i++) {
				if (s[i] == '3') {
					cout << " " + s;
					break;
				}
			}
		}
	}
	cout << endl;
}

Measured memory_bytes: 3248
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007

using namespace std;

char L[100008];
long long f[100008], g[100008];

int main()
{
    cin >> L;
    int len = strlen(L);
    int i;
    f[0] = 1;   //till now already less than L
    g[0] = 2;   //till now still equal to L
    for(i = 1; i < len; i++)
    {
        if(L[i] == '1')
        {
            f[i] = (f[i - 1] * 3 + g[i - 1]) % MOD;
            g[i] = g[i - 1] * 2 % MOD;
        }
        else
        {
            f[i] = f[i - 1] * 3 % MOD;
            g[i] = g[i - 1];
        }
    }
    
    cout << (f[len-1] + g[len-1]) % MOD;
    
    return 0;
}


Measured memory_bytes: 1920
import math
A, B = map(int, input().split())
ans = 0

for i in range(1, 1001):
    tmpa = math.floor(i * 0.08) 
    tmpb = math.floor(i * 0.1)
    if tmpa == A and tmpb == B:
        ans = i
        break

if ans == 0:
    ans = "-1"

print(ans)

Measured memory_bytes: 38384
while line = gets
	m, f, r = line.split( " " ).map { | val | val.to_i }
	break if -1 == m && -1 == f && -1 == r
	
	mf = ( m + f )
	if -1 == m || -1 == f
		puts( "F" )
	elsif 80 <= mf
		puts( "A" )
	elsif 65 <= mf && mf < 80
		puts( "B" )
	elsif 50 <= mf && mf < 65
		puts( "C" )
	elsif 30 <= mf && mf < 50
		if 50 <= r
			puts( "C" )
		else
			puts( "D" )
		end
	else
		puts( "F" )	
	end
end

Measured memory_bytes: 6104
import sys
S = list(input())
# S = "Atcoder"
# S = list(S)

if S[0] != "A":
    print("WA")
    sys.exit()
elif S[1].isupper():
    print("WA")
    sys.exit()
elif S[-1].isupper():
    print("WA")
    sys.exit()
elif "C" in S[2:-1]:
    S.remove("C")
    del S[0]
    S = str(S)
    if S.islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 string s;
  cin >> s ;
  if(s=="ABC")cout << "ARC" << endl;
  else if(s=="ARC") cout << "ABC" << endl;
      
}

Measured memory_bytes: 3624
#include <iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m;
	int ans = -1;
	int cnt = 0;
	cin >> n >> m;
	vector<int> a(m);

	for (int i = 0;i < m; i++) {
		cin >> a[i];
		cnt += a[i];
	}
	if (cnt > n) {
		cout << -1;
	}
	else {
		cout << n - cnt;
	}

	return 0;
}

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

int keta(int x)
{
	int sum;

	sum = 1;
	while(x / 10)
	{
		x /= 10;
		sum++;
	}
	return sum;
}

signed main(void)
{
	int a, b, cnt, tmp;
	bool ok;

	cin >> a >> b;
	cnt = 0;
	for(int i = a; i <= b; i++)
	{
		vector<int> v;
		tmp = i;
		while (tmp / 10)
		{
			v.push_back(tmp % 10);
			tmp /= 10;
		}
		v.push_back(tmp);
		ok = true;
		for(int j = 0; j < 2; j++)
			if (v.at(j) != v.at(4 - j))
				ok = false;
		if (ok)
		{
			//cout << i << endl;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,k;
    long long int a[200010] = {0};

    scanf("%d %d", &n, &k);
    for(auto i=1; i<=n; ++i){
        scanf("%lld", &a[i]);
    }

    for(auto i=1; i<=n-k; ++i){
        if(a[i] < a[i+k]){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
}

Measured memory_bytes: 3220
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    a=input()
    b=input()
    c=input()
    ans=0
    for i in range(n):
        if a[i]!=b[i]:
            if b[i]!=c[i] and a[i]!=c[i]:
                ans+=2
            elif (b[i]!=c[i] and a[i]==c[i]) or b[i]==c[i]:
                ans+=1
        else:
            if b[i]!=c[i]:
                ans+=1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

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

	int N = X / 100;
	int R = X % 100;
	for (int b = 0; b < 100; ++b) {
		for (int c = 0; 2 * c < 100; ++c) {
			for (int d = 0; 3 * d < 100; ++d) {
				for (int e = 0; 4 * e < 100; ++e) {
					for (int f = 0; 5 * f < 100; ++f) {
						if (b + c + d + e + f <= N && b + 2 * c + 3 * d + 4 * e + 5 * f == R) {
							cout << 1 << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	cout << 0 << endl;
}


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

using namespace std;

int main() {
    int n; 
    string s;
    cin >> n >> s;
    for (size_t i = 0, sz = s.size(); i < sz; ++i) {
        int a = (s[i] - 'A' + n) % 26;

        s[i] = a + 'A';
    }

    cout << s << "\n";
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	string s,t;
    cin >> s >> t;
    int a,b; cin >> a>> b;
    string u;cin>>u;
    if(u==s){
        a--;
    } else {
        b--;
    }
    cout << a<<" "<<b;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"
#define PI 3.141592653589793

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
    int N; cin>>N;
    double x[N],y[N];
    REP(i,N){ cin>>x[i]; }
    REP(i,N){ cin>>y[i]; }
    
    double a[N];
    REP(i,N){
      a[i] = abs(x[i]-y[i]);  
    }
    
    for(double p=1;p<=3;++p){
      double d = 0;
      REP(i,N){ d += pow(a[i],p);}
      d = pow(d,1/p);
      printf("%.5f\n",d);
    }
    printf("%.5f\n", *max_element(a,a+N) );
    
}


Measured memory_bytes: 3408
import fractions


def two_abbreviation(n, m, s, t):
    common = int(fractions.gcd(n, m) + 10 ** -6)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    ret = int(n * m / common + 10 ** -6) if s_common == t_common else -1
    return ret


N, M = [int(a) for a in input().split()]
S = str(input())
T = str(input())

print(str(two_abbreviation(N, M, S, T)))

Measured memory_bytes: 8248
package main

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

var si = bufio.NewScanner(os.Stdin)

func readInt() int {
	si.Scan()
	r, _ := strconv.Atoi(si.Text())
	return r
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func calc(Q int, q [50][4]int, n, m int, a []int) int {
	ret := 0
	if n == 0 {
		for i := 0; i < Q; i++ {
			if a[q[i][1]]-a[q[i][0]] == q[i][2] {
				ret += q[i][3]
			}
		}
		return ret
	}
	for i := a[len(a)-1]; i <= m; i++ {
		ret = max(ret, calc(Q, q, n-1, m, append(a, i)))
	}
	return ret
}

func main() {
	si.Split(bufio.ScanWords)
	si.Buffer(make([]byte, 0), 10000000)
	N, M, Q := readInt(), readInt(), readInt()

	var q [50][4]int

	for i := 0; i < Q; i++ {
		q[i] = [4]int{readInt(), readInt(), readInt(), readInt()}
	}
	fmt.Println(calc(Q, q, N, M, []int{1}))

}


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

#define loop(s, e, i) for (int i=s; i<e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;


int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;

  double res1 = W*H/2;
  int res2 = (W == x+x) && (H == y+y);
  cout << fixed << setprecision(9) << res1 << ' ' << res2 << endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int main(){
    int H[3],s=0,t=0,e=0,d=0;
    while(1){
        cin>>H[0]>>H[1]>>H[2];
        sort(H,H+3);
        if(H[2]>=H[0]+H[1]) break;
        s++;
        if(H[0]*H[0]+H[1]*H[1]-H[2]*H[2]==0) t++;
        else if(H[0]*H[0]+H[1]*H[1]-H[2]*H[2]>0) e++;
        else if(H[0]*H[0]+H[1]*H[1]-H[2]*H[2]<0) d++;
    }
    cout<<s<<" "<<t<<" "<<e<<" "<<d<<endl;
    return 0;
}



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

struct Card{
  char pic; int val;
};

void bubbleSort(Card A[], int n){
  for(int i = 0; i < n - 1; i++){
    for(int j = n - 1; j > i; j--){
      if(A[j].val < A[j-1].val){
        swap(A[j], A[j-1]);
      }
    }
  }
}

void selectionSort(Card B[], int n){
  for(int i = 0; i < n; i++){
    int min = i;
    for(int j = i; j < n; j++){
      if(B[j].val < B[min].val) min = j;
    }
    swap(B[i], B[min]);
  }
}

int main(void){
  int n;
  Card A[36], B[36];

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> A[i].pic >> A[i].val;
    B[i].pic = A[i].pic; B[i].val = A[i].val;
  }

  bubbleSort(A, n);
  selectionSort(B, n);

  for(int i = 0; i < n; i++){
    cout << A[i].pic << A[i].val;
    if(i < n - 1) cout << " ";
  }
  cout << "\nStable" << endl;

  bool flag = true;
  for(int i = 0; i < n; i++){
    cout << B[i].pic << B[i].val;
    if(i < n - 1) cout << " ";
    if(B[i].pic != A[i].pic) flag = false;
  }
  if(flag){
    cout << "\nStable" << endl;
  }else{
    cout << "\nNot stable" << endl;
  }

  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

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

void solve()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << min(B / A, C) << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 384
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
 
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
  
using namespace std;
  
double EPS = 1e-10;
const double PI = acos(-1);
  
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}
  
  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }
  
  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
  
  point operator * (double d){
    return point(x*d,y*d);
  }
  
  point operator / (double d){
    return point(x/d,y/d);
  }
  
};
  
#define Line pair<point,point>
 
double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}
 
double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}
  
double norm(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}
  
int ccw(point a, point b, point c) {
  b = b-a; c = c-a;
  if (cross(b, c) > 0)   return +1;
  if (cross(b, c) < 0)   return -1;
  if (dot(b, c) < 0)     return +2;
  if (norm(b) < norm(c)) return -2; 
  return 0;
}
 
point intersection_l(point a1, point a2, point b1, point b2) {
  return a1 + (a2 - a1) * (cross(b2 - b1,b1 - a1) / cross(b2 - b1,a2 - a1));
}
 
point symmetry(point p1, point p2, point Q){
  double xa,ya,xb,yb,t1,t2;
  point R;
  
  xa=Q.x-p1.x,ya=Q.y-p1.y;
  xb=p2.x-p1.x,yb=p2.y-p1.y;
  
  t1=xa*xb+ya*yb,t2=xb*xb+yb*yb;
  
  R.x=2*(p1.x+xb*t1/t2)-Q.x;
  R.y=2*(p1.y+yb*t1/t2)-Q.y;
  return R;
}
 
 Line parallel_line(point a,point b,double h){
    double t = atan((a.y-b.y)/(a.x-b.x));
  
    point a_(a.x + h*cos(t+PI/2), a.y + h*sin(t+PI/2));
    point b_(b.x + h*cos(t+PI/2), b.y + h*sin(t+PI/2));
  
    if(ccw(a,b,a_)==-1)a_=symmetry(a,b,a_),b_=symmetry(a,b,b_);
  
    return make_pair(a_,b_);
}
 
vector<point> convex_cut(vector<point>pol,point a,point b){
  vector<point>q;
  for (int i=0; i<pol.size();i++) {
    point A=curr(pol,i),B=next(pol, i);
    if (ccw(a,b,A)!=-1)q.push_back(A);
    if (ccw(a,b,A)*ccw(a,b,B)<0)
      q.push_back(intersection_l(A,B,a,b));
  }
  return q;
}
 
bool C(vector<point>pol,double d){
  vector<Line>L;
  for(int i=0;i<pol.size();i++){
    L.push_back(Line(curr(pol,i),next(pol,i)));
  }
   
  for(int i=0;i<L.size();i++){
    Line tmp=parallel_line(L[i].first,L[i].second,d);
    pol=convex_cut(pol,tmp.first,tmp.second);
  }
  return pol.size()>0;
}
 
double Binary_search(vector<point>pol){
  double l=0,r=10000,tc=50;
  while(tc--){
    double d=(l+r)/2;
    if(C(pol,d))l=d;
    else r=d;
  }
  return l;
}
 
int main(void){
 
  int n;
  while(cin >> n,n){
    vector<point>pol(n);
    for(int i=0;i<n;i++)cin >> pol[i].x >> pol[i].y;
    printf("%.6f",Binary_search(pol));
    cout << endl;
  }
 
  return 0;
}

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

using namespace std;

const int MOD = 1000000007;

long long modPow(long long a, long long p){
	if(p == 0) return 1;
	long long res = modPow(a, p/2);
	res = (res * res) % MOD;
	if(p%2 == 1) res = (res * a) % MOD;
	return res;
}

pair<long long, long long> solve(const vector<int>& h){
	if(h.size() == 1){
		pair<long long, long long> res;
		res.first = modPow(2, h[0]);
		res.second = 0;
		return res;
	}
	int minH = h[0];
	for(const auto& t : h) minH = min(minH, t);
	long long alt = 2;
	long long any = 0;
	for(int i=0;i<h.size();i++){
		if(h[i] == minH){
			if(i > 0) any = (2 * any + alt) % MOD;
		} else {
			int end = i;
			while(end < h.size() && h[end] != minH) ++end;
			vector<int> nh(end - i);
			for(int j=i;j<end;j++) nh[j-i] = h[j] - minH;
			if(end - i == 1){
				auto next = solve(nh);
				if(i > 0) any = ((2 * any + alt) * next.first) % MOD;
				alt = (alt * next.first) % MOD;
			} else {
				auto next = solve(nh);
				long long addAny = 0;
				addAny += (2 * next.first) % MOD;
				addAny += next.second % MOD;
				any = (any * addAny) % MOD;
				if(i > 0){
					any = (any + alt * next.first) % MOD;
					any = (any + alt * next.second) % MOD;
				} else {
					any = (any + next.second) % MOD;
				}
				alt = (alt * next.first) % MOD;
			}
			i = end - 1;
		}
	}
	alt = (alt * modPow(2, minH-1)) % MOD;
	return make_pair(alt, any);
}

int main(){
	int N;
	while(cin >> N){
		vector<int> h(N);
		for(auto& t : h) cin >> t;
		auto res = solve(h);
		cout << (res.first + res.second) % MOD << endl;
	}
}

Measured memory_bytes: 256