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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};

typedef pair<int, int> P;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h)
    {
        cin >> s[i];
    }
    int ans = 0;
    rep(si, h)
    {
        rep(sj, w)
        {
            if (s[si][sj] == '#')continue;
            
            vector<vector<int> > dist(h, vector<int>(w, INF));
            queue<P> q;
            auto update = [&](int i, int j, int x){
                if (dist[i][j] != INF) return;
                dist[i][j] = x;
                q.push(P(i,j));
            };
            update(si,sj,0);
            while(!q.empty())
            {
                int i = q.front().first;
                int j = q.front().second;
                q.pop();
                rep(dir,4)
                {
                    int ni = i+di[dir];
                    int nj = j+dj[dir];
                    if (ni<0 || ni>=h || nj < 0 || nj>=w)continue;
                    if (s[ni][nj] == '#') continue;
                    update(ni,nj,dist[i][j]+1);
                }
            }
            rep(i,h)
            {
                rep(j,w)
                {
                    if (dist[i][j]==INF)
                    {
                        continue;
                    }
                    ans = max(ans, dist[i][j]);
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; i++) cin >> A[i];
	if (M == 1) {
		if (A[0] == 1) cout << 1 << endl << 1 << endl << 1 << endl;
		else cout << A[0] << endl << 2 << endl << A[0] - 1 << ' ' << 1 << endl;
		return 0;
	}
	int Odd = 0;
	for (int i = 0; i < M; i++) {
		if (A[i] % 2 == 1) {
			Odd++;
		}
	}
	if (Odd >= 3) {
		cout << "Impossible" << endl;
		return 0;
	}
	if (Odd == 2) {
		for (int i = 0; i < M; i++) {
			if (A[i] % 2 == 1) {
				swap(A[0], A[i]);
				break;
			}
		}
		for (int i = M - 1; i >= 0; i--) {
			if (A[i] % 2 == 1) {
				swap(A[M - 1], A[i]);
				break;
			}
		}
	}
	if (Odd == 1) {
		for (int i = 0; i < M; i++) {
			if (A[i] % 2 == 1) {
				swap(A[0], A[i]);
				break;
			}
		}
	}
	vector<int> ANS;
	ANS.push_back(A[0] + 1);
	for (int i = 1; i < M - 1; i++) ANS.push_back(A[i]);
	if (A[M - 1] != 1) ANS.push_back(A[M - 1] - 1);
	for (int i = 0; i < M; i++) cout << A[i] << (i == M - 1 ? '\n' : ' ');
	cout << ANS.size() << '\n';
	for (int i = 0; i < ANS.size(); i++) cout << ANS[i] << (i == ANS.size() - 1 ? '\n' : ' ');
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
    int a[10],b[10],d[10],e[10],c,i,cnt=0;
    for(i=1;i<=6;i++){
        scanf("%d",&b[i]);
        a[i] = b[i];}
    for(i=1;i<=6;i++){
        scanf("%d",&e[i]);
        d[i] = e[i];}
    for(i=1;i<=5;i++){
        if(a[i]>a[i+1]){
            c = a[i+1];
            a[i+1] = a[i];
            a[i] = c;}
        if(d[i]>d[i+1]){
            c = d[i+1];
            d[i+1] = d[i];
            d[i] = c;}}
    for(i=1;i<=6;i++){
        if(a[i] == d[i])
            cnt++;}
    if((cnt==6) && (a[1]==a[2]) && (a[2]==a[3]) && (a[3]==a[4]) && (a[4]==a[5])){
        printf("Yes\n");
        return 0;}
    for(i=0;i<4;i++){
        if(b[1] == e[1])
            break;
        c = b[1];
        b[1] = b[2];
        b[2] = b[6];
        b[6] = b[5];
        b[5] = c;}
    for(i=0;i<4;i++){
        if(b[1] == e[1])
            break;
        c = b[1];
        b[1] = b[3];
        b[3] = b[6];
        b[6] = b[4];
        b[4] = c;}
    for(i=0;i<4;i++){
        if(b[2] == e[2])
            break;
        c = b[2];
        b[2] = b[3];
        b[3] = b[5];
        b[5] = b[4];
        b[4] = c;}
    for(i=2;i<=6;i++){
        if(b[i] != e[i]){
            printf("No\n");
            return 0;}}
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1820
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int angle = 0;
		sc.useDelimiter("[\n ,]");
		double px = 0.0;
		double py = 0.0;
		
		while(true){
			int len = sc.nextInt();
			int theta = sc.nextInt();
			if (len == 0 && theta == 0){
				break;
			}
			px += len*Math.sin(angle*Math.PI/180);
			py += len*Math.cos(angle*Math.PI/180);
			angle += theta;
		}
		
		System.out.printf("%d\n%d\n", (int)px, (int)py);
		sc.close();
	}
}

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

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K, H, W;
ll MOD = 1000000007;
int ans = 1;
//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<int ,int> firstElof, pair<int,int> secondElof)
{
	return firstElof.second > secondElof.second;
}
int Keta(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
//////////////

int main()
{
	cin >> N;
	vector<pair<ll,ll>>XY(N);
	vector<pair<ll, ll>>XY2(N);
	vector<int> flag(N);
	for (i = 0; i < N; i++) {
		cin >> XY[i].first >> XY[i].second;
		XY2[i].first = XY[i].second;
		XY2[i].second = XY[i].first;
		flag[i] = 0;
	}
	sort(XY.begin(), XY.end());
	sort(XY2.begin(), XY2.end());
	vector<vector<ll>> gapX(N, vector<ll>(N, 0));
	vector<vector<ll>> gapY(N, vector<ll>(N, 0));
	for (i = 0; i < N-1; i++) {
		for (j = i + 1; j < N; j++) {
			gapX[i][j] = XY[j].first - XY[i].first;
			gapY[i][j] = XY[j].second - XY[i].second;
		}
	}
	for (i = 0; i < N - 1; i++) {
		for (j = i+1; j < N; j++) {
			int count = 1;
			ll X = gapX[i][j];
			ll Y = gapY[i][j];
			flag[i] = 1; flag[j] = 1;
			int now = j;
			int next = j + 1;
			while (now < N - 1) {
				while (next < N) {
					if (gapX[now][next] == X && gapY[now][next] == Y && flag[next]==0) {
						now = next;
						next = now + 1;
						flag[now] = 1;
						count++;
					}
					else {
						next++;
					}
				}
				bool b = false;
				for (k = 0; k < N; k++) {
					if (flag[k] == 0) {
						now = k;
						next = k + 1;
						flag[k] = 1;
						b = true;
						break;
					}
				}
				if (b == false) {
					break;
				}
			}
			ans = max(ans, count);
			for (k = 0; k < N; k++) {
				flag[k] = 0;
			}
		}
	}
	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N; j++) {
			gapX[i][j] = XY2[j].second - XY2[i].second;
			gapY[i][j] = XY2[j].first - XY2[i].first;
		}
	}
	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N; j++) {
			int count = 1;
			ll X = gapX[i][j];
			ll Y = gapY[i][j];
			flag[i] = 1; flag[j] = 1;
			int now = j;
			int next = j + 1;
			while (now < N - 1) {
				while (next < N) {
					if (gapX[now][next] == X && gapY[now][next] == Y && flag[next] == 0) {
						now = next;
						next = now + 1;
						flag[now] = 1;
						count++;
					}
					else {
						next++;
					}
				}
				bool b = false;
				for (k = 0; k < N; k++) {
					if (flag[k] == 0) {
						now = k;
						next = k + 1;
						flag[k] = 1;
						b = true;
						break;
					}
				}
				if (b == false) {
					break;
				}
			}
			ans = max(ans, count);
			for (k = 0; k < N; k++) {
				flag[k] = 0;
			}
		}
	}
	if (N == 1) {
		cout << 1;
	}
	else {
		cout << N - ans;
	}
}

Measured memory_bytes: 256
x = int(input())
import math
f = 1
for A in range(-10**5,10**5):
    A5 = A ** 5
    if x - A5 > 0:
        f = -1
        B = round(math.pow(x - A5,1/5),0)
    else:
        B = round(math.pow(-(x - A5),1/5),0)
    if  A5 == x + int(B*f) ** 5:
        print(A,int(B)*f)
        quit()


Measured memory_bytes: 9640
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)
        self.added = [0]*(n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        self.added[x] += w
        self.added[y] += w
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            #self.weight[rx] = w - self.weight[x] + self.weight[y]
            self.weight[rx] = w - self.diff(x, y)
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            #self.weight[ry] = -w - self.weight[y] + self.weight[x]
            self.weight[ry] = -w + self.diff(x, y)
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]+self.added[x]-self.added[y]

    def added_diff(self, x, y):
        return self.diff(x, y)


def dealIn(l):
    a, b, c = l
    Un.union(b, a, c)


def compare(l):
    a, b = l
    if Un.same(a, b):
        diff = Un.added_diff(b, a)
        return diff
    else:
        return "WARNING"


N, Q = map(int, input().split())
Un = WeightedUnionFind(N+1)
ans = []
for _ in range(Q):
    s, *l = input().split()
    if s == "IN":
        dealIn(list(map(int, l)))
    else:
        ret = compare(list(map(int, l)))
        ans.append(ret)
if ans:
    print("\n".join(map(str, ans)))



Measured memory_bytes: 16040
#include<iostream>

using namespace std;

long long a, b, x;

int main() {
    cin >> a >> b >> x;
    long long ans = ((b / x) + 1) - ((a - 1) < 0 ? 0 : (a - 1) / x + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, M; cin >> N >> M;
  int left = 0, right = INF;
  rep(i, M){
    int L, R; cin >> L >> R;
    left = max(left, L);
    right = min(right, R);
  }
  if (right - left + 1 >= 0) cout << right - left + 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
a , b , c ,x , y = map(int , input().split())
c2 = c *2
na , nb ,nc = 0 , 0 ,0 
if a > c2 :
    a = c2
if b > c2 :
    b = c2

if a <= c2 and b <= c2 :
    if a + b >= c2 :
        nc = min(x,y)
        if x > y :
            na = x - y
        else :
            nb = y -x
    else :
        na = x
        nb = y
print(na*a+nb*b+nc*c2)


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

using namespace std;

struct alphabet
{
	char alpha;
	bool exist;
};

int main()
{
	string s;
	cin >> s;
	
	alphabet x[26];
	for(int i = 0; i < 26; i++)
	{
		x[i].alpha = 'a' + i;
		x[i].exist = true;
	}
	
	for(int i = 0; i < s.size(); i++)
	{
		for(int j = 0; j < 26; j++)
		{
			if(s[i] == x[j].alpha)
			{
				x[j].exist = false;
			}
		}
	}
	
	for(int i = 0; i < 26; i++)
	{
		if(x[i].exist == true)
		{
			cout << x[i].alpha << endl;
			return 0;
		}
	}
	
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
ans = 0

if n%2 == 0:
    for i in range(1,n+1):
        for j in range(i,n+1):
            if j ==n+1-i or j ==i:
                continue
            ans += 1

else:
    for i in range(1,n+1):
        for j in range(i,n+1):
            if j == n-i or j ==i:
                continue
            ans += 1

print(ans)

if n%2 == 0:
    for i in range(1,n+1):
        for j in range(i,n+1):
            if j ==n+1-i or j ==i:
                continue
            print(i,j)

else:
    for i in range(1,n+1):
        for j in range(i,n+1):
            if j == n-i or j ==i:
                continue
            print(i,j)





Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define tr(x) ((x) * (x) * (x))
using namespace std;

long long n, k;

int main() {
	scanf("%lld%lld", &n, &k);
	printf("%lld\n", tr(n / k) + (k & 1 ? 0 : tr(n / (k >> 1) - n / k)));
	return 0;
}



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

bool LinearSearch(int t, vector<int> S)
{
	int n = S.size();
	for(int j = 0; j < n; j++){
		if(t == S[j]){
			return true;
		}	
	}
	return false;
}

int main()
{
	int Count = 0;
	int n;
	cin >> n;
	vector<int> S;
	for(int i = 0; i < n; i++){
		int s;
		cin >> s;
		S.push_back(s);
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		if(LinearSearch(t, S)){
			Count ++;
		}
	}
	cout << Count << endl;
	return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
  string S, T;
  cin >> S >> T;
  bool answer = false;
  for(int i = 0; i < S.size(); i++){
    if(S == T){
      answer = true;
    }
    S = S.back() + S.substr(0, S.size() - 1);
  }
  if(answer){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int fac(int n){
    int res = 1;
    rep(i,n){
        res *= i+1;
    }
    return res;
}

int main(){
    int N; cin >> N;
    vector<Pi> xy(N);
    rep(i,N){
        cin >> xy[i].first >> xy[i].second;
    }
    sort(xy.begin(),xy.end());
    double sum = 0;
    do{
        rep(i,N-1){
            sum += sqrt((xy[i+1].first-xy[i].first)*(xy[i+1].first-xy[i].first) + (xy[i+1].second-xy[i].second)*(xy[i+1].second-xy[i].second));
        }
    }while(next_permutation(xy.begin(),xy.end()));

    sum /= fac(N);
    cout << fixed <<setprecision(7) << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[201],b=1000,c;
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i+1]>a[i])
		{
			int tmp=b/a[i];
			b-=tmp*a[i];
			c+=tmp;
		}
		else
		{
			b+=a[i]*c;
			c=0;
		}
	}
	printf("%lld",b);
	return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    string s="";
    for (int i = 0; i < 3; i++) {
        string str;
        cin >> str;
        s += str[i];
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Polygonal Line Search
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			int[][] arc0 = null;
			int[][] rev0 = null;

			for (int i = 0; i <= n; i++) {

				int m = parseInt(br.readLine());

				int[][] arc = new int[m][2];

				for (int j = 0; j < m; j++) {
					line = br.readLine();
					arc[j][0] = parseInt(line.substring(0, line.indexOf(' ')));
					arc[j][1] = parseInt(line.substring(line.indexOf(' ') + 1));
				}

				arc = normalize(arc);

				if (i == 0) {
					arc0 = arc;
					rev0 = normalize(reverse(arc0));
				} else {
					if (arc.length != arc0.length) {
						continue;
					} else {
						for (int j = 0; j < 4; j++) {
							if (congruent(arc0, arc) || congruent(rev0, arc)) {
								System.out.println(i);
								break;
							} else {
								arc = rotate(arc);
							}
						}
					}
				}
			}

			System.out.println("+++++");
		}

	}//end main

	static int[][] reverse(int[][] a) {

		int[][] ret = new int[a.length][a[0].length];

		for (int i = 0, j = a.length - 1; i < a.length; i++, j--) {
			ret[i][0] = a[j][0];
			ret[i][1] = a[j][1];
		}

		return ret;
	}

	static int[][] normalize(int[][] a) {

		int[][] ret = new int[a.length][a[0].length];

		int dx, dy;
		dx = -a[0][0];
		dy = -a[0][1];

		for (int i = 0; i < a.length; i++) {
			ret[i][0] = a[i][0] + dx;
			ret[i][1] = a[i][1] + dy;
		}

		return ret;
	}

	static int[][] rotate(int[][] a) {

		int[][] ret = new int[a.length][a[0].length];

		for (int i = 0; i < a.length; i++) {
			ret[i][0] = -a[i][1];
			ret[i][1] = a[i][0];
		}

		return ret;
	}

	static boolean congruent(int[][] a1, int[][] a2) {

		boolean ret = true;

		for (int i = 0; i < a1.length; i++) {
			ret &= (a1[i][0] == a2[i][0] && a1[i][1] == a2[i][1]);
			if (!ret) break;
		}

		return ret;
	}
}

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

int main() {
  int l, r, d;
  cin >> l >> r;
  d = (r - l + 1) / 2019;
  l %= 2019;
  r %= 2019;
  if(d > 0) cout << 0 << endl;
  else if(l > r) cout << 0 << endl;
  else{
    int m = 2019;
    rep(i, r-l) rep(j, r-l-i) m = min(m, (l+i)*(l+i+j+1) % 2019);
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
$lines = explode(", ", trim(fgets(STDIN)));

foreach($lines as $lineKey => $line){
    $newline = "";
    foreach(str_split($line) as $char){
        if(ctype_upper($char) === true){
            $char = strtolower($char);
        }else{
            $char = strtoupper($char);
        }
        $newline .= $char;
    }
    $lines[$lineKey] = $newline;
}


echo implode(", ",$lines);
echo PHP_EOL;


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

using namespace std;

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

    long long n;
    cin >> n;
    string s = "";
    while(n > 0) {
        --n;
        s += ('a' + (n%26));
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s;
    return 0;
}


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

/*
long long int kk(long long int a,long long int b){
	long long int x=1;
	long long int y=1;
	for(int i=0;i<b;i++)x*=(a-i);
	for(int i=0;i<b;i++)y*=(b-i);
	//cout<<x<<" "<<y<<" "<<"aaaaaaa"<<endl;
	return x/y;
}
*/

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	vector<long long int> v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	sort(v.begin(),v.end(),greater<long long int>());
	double ans=0;
	for(int i=0;i<a;i++)ans+=v[i];
	//cout<<ans<<endl;
	ans/=a;
	cout<<fixed<<setprecision(20)<<ans<<endl;
	
	long long int ku=0;
	
	long long int ko=1;
	for(int i=1;i<a;i++){
		if(v[a-1-i]==v[a-1]){
			ko++;
		}else{
			break;
		}
	}
	
	long long int bc=a-ko;
	//cout<<bc<<endl;
	
	for(int i=a;i<n;i++){
		if(v[i]==v[a-1]){
			ko++;
		}else{
			break;
		}
	}
	
	//cout<<ko<<endl;
	
	vector<vector<long long int> > kumi(51,vector<long long int>(51) );
	for(int i=0;i<=n;++i){
		for(int j=0;j<=i;++j){
			if(j==0){
				kumi[i][j]=1LL;
			}else{
				kumi[i][j]=(kumi[i-1][j-1]+kumi[i-1][j]);
			}
		}
	}
	
	for(int i=a;i<=b;i++){
		ku+=kumi[ko][i-bc];
		//cout<<ko<<" "<<i-bc<<" "<<kumi[ko][i-bc]<<endl;
		if(bc!=0)break;
	}
	
	cout<<ku<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(int(x) for x in input().split())
count = 0
for i in range(N):
  min_a = i
  for j in range(i,N):
    if a[j] < a[min_a]:
      min_a = j
  if min_a != i:
    count += 1
  tmp = a[i]
  a[i] = a[min_a]
  a[min_a] = tmp

for k in range(N):
  if k == N-1:
    print(a[k],end ="")
  else:
    print(a[k],end =" ")
    
print()
print(count)


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

#define ll long long
const int mod = 1e9+7;
const ll INF = 1e18L+5;
int a[407];
ll dp[401][401];
ll sum[401];
int main(){
  int n;
  cin>>n;
  memset(sum,0,sizeof(sum));
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  memset(dp,0,sizeof(dp));
  //vector<vector<pair<int,int>>> dp(401, vector<pair<int,int>>(401))
  for(int i=n-1;i>=0;i--){
    for(int j=i;j<n;j++){
      if(i==j){
        dp[i][j]=0;
        continue;
      }
      else{
        dp[i][j]=INF;
        ll s = 0;
        for(int k=i;k<=j;k++){
          s+=a[k];
        }
        for(int k=i;k<j;k++){
          dp[i][j] = min(dp[i][j],(dp[i][k]+dp[k+1][j]+s));
        }
      }
    }
  }
  cout<<(dp[0][n-1])<<endl;
}


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

using namespace std;

int type(int n) {
  if (n >= 3200) {
    return 9;
  }
  for (int i = 1; i < 9; i++) {
    if (n < 400 * i) {
      return i;
    }
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);

  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }

  int ans = 0;
  int free = 0;
  set<int> S;

  for (int i = 0; i < n; i++) {
    int color = type(vec[i]);
    if (color == 9) {
      free++;
    } else {
      S.insert(color);
    }
  }

  if (S.size() == 0) {
    cout << 1 << " ";
    cout << free << endl;
  } else {
    cout << S.size() << " ";
    cout << S.size() + free << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	N := nextInt()
	m := map[string]int{}
	for i := 0; i < N; i++ {
		s := next()
		m[s] = 10
	}
	fmt.Println(len(m))
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 18312
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  string s;
  int n;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i+2<n;i++){
    if(s.substr(i,3)=="ABC"){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int i, j;
    cin >> i >> j;
    set <int> myset;
    int a;
    for (int k = 0; k < j; k++) {
        cin >> a;
        myset.insert(a);
    }
    int small = i;
    while (myset.find(small) != myset.end() || small == i) {
        small--;
    }
    int big = i;
    while (myset.find(big) != myset.end() || small == i) {
        big++;
    }
    if (i - small < big - i) {
        cout << small;
    }
    else if (i - small > big - i) {
        cout << big;
    }
    else {
        cout << small;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
const int MX=2e5+5;
vector<pair<int,pair<int,int>>> a[MX];
int check[MX];
int b[MX*2];
long long c[MX],d[MX],e[MX],dd[MX];
int visit[MX];
int p[MX][32];
long long dist[MX];
int inn[MX],outn[MX],dth[MX];
int k;
int cnt;
int n,m;
long long ans[MX];

int get_lca(int u,int v){
    int i;
    if(dth[v]<dth[u])swap(u,v);
    for(i=30 ; i>=0 ; i--)if(dth[v]-dth[u]>=(1<<i))v=p[v][i];
    if(u==v)return v;
    for(i=30 ; i>=0 ; i--)if(p[v][i]!=p[u][i])v=p[v][i],u=p[u][i];
    return p[v][0];
}
struct A{
    int x,y,u,v,l,r,idx,lca;
    void process(){
        if(inn[u]>inn[v])swap(u,v);
        lca=get_lca(u,v);
        if(lca==u){
            l=inn[u]+1;
            r=inn[v];
        }
        else{
            l=outn[u];
            r=inn[v];
        }
    }
    bool operator<(const A&t){
        if(l/k==t.l/k)return r<t.r;
        return l/k<t.l/k;
    }
}q[MX];
void dfs(int v){
    inn[v]=++cnt;
    b[inn[v]]=v;
    visit[v]=1;
    for(auto &i: a[v]){
        int u=i.f;
        if(visit[u]==0){
            dth[u]=dth[v]+1;
            dist[u]=dist[v]+i.s.s;
            p[u][0]=v;
            c[u]=i.s.f;
            d[u]=i.s.s;
            dfs(u);
        }
    }
    outn[v]=++cnt;
    b[outn[v]]=v;
}
int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int i,j;
    cin>>n>>m;

    k=sqrt(2*n);
    for(i=1 ; i<n ; i++){
        int u,v,cc,ddd;
        cin>>u>>v>>cc>>ddd;
        a[u].push_back({v,{cc,ddd}});
        a[v].push_back({u,{cc,ddd}});
    }

    dfs(1);
    for(i=1 ; i<=30 ; i++)for(j=1 ; j<=n ; j++)p[j][i]=p[p[j][i-1]][i-1];
    for(i=1 ; i<=m ; i++){
        int x,y,u,v;
        cin>>x>>y>>u>>v;
        q[i]={x,y,u,v,0,0,i,0};
        q[i].process();
    }

    sort(q+1,q+m+1);
    for(i=1 ; i<=m ; i++){
        ans[q[i].idx]=dist[q[i].u]+dist[q[i].v]-2*dist[q[i].lca];
        for(j=q[i-1].r+1 ; j<=q[i].r ; j++){
            int t=b[j];
            check[t]++;
            if(check[t]==1)e[c[t]]++,dd[c[t]]+=d[t];
            if(check[t]==2)e[c[t]]--,dd[c[t]]-=d[t];
        }
        for(j=q[i].l ; j<q[i-1].l ; j++){
            int t=b[j];
            check[t]++;
            if(check[t]==1)e[c[t]]++,dd[c[t]]+=d[t];
            if(check[t]==2) e[c[t]]--,dd[c[t]]-=d[t];
        }
        for(j=q[i].r+1 ; j<=q[i-1].r ; j++){
            int t=b[j];
            check[t]--;
            if(check[t]==1)e[c[t]]++,dd[c[t]]+=d[t];
            if(check[t]==0) e[c[t]]--,dd[c[t]]-=d[t];
        }
        for(j=q[i-1].l ; j<q[i].l ; j++){
            int t=b[j];
            check[t]--;
            if(check[t]==1)e[c[t]]++,dd[c[t]]+=d[t];
            if(check[t]==0) e[c[t]]--,dd[c[t]]-=d[t];
        }
        ans[q[i].idx]-=dd[q[i].x];
        ans[q[i].idx]+=e[q[i].x]*q[i].y;
    }
    for(i=1 ; i<=m ; i++)cout<<ans[i]<<"\n";
    return 0;
}


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll dp[3252][3252];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll a[3252];
	cin>>n;
	REP(i, n){
		cin>>a[i];
	}
	if(n&1){
		REP(i, n){
			dp[i][i]=a[i];
		}
		FOR(d, 1, n){
			if(d&1){
				REP(l, n-d){
					int r=l+d;
					dp[l][r]=min(dp[l+1][r]-a[l], dp[l][r-1]-a[r]);
				}
			}
			else{
				REP(l, n-d){
					int r=l+d;
					dp[l][r]=max(dp[l+1][r]+a[l], dp[l][r-1]+a[r]);
				}
			}
		}
	}
	else{
		REP(i, n){
			dp[i][i]=-a[i];
		}
		FOR(d, 1, n){
			if(d&1){
				REP(l, n-d){
					int r=l+d;
					dp[l][r]=max(dp[l+1][r]+a[l], dp[l][r-1]+a[r]);
				}
			}
			else{
				REP(l, n-d){
					int r=l+d;
					dp[l][r]=min(dp[l+1][r]-a[l], dp[l][r-1]-a[r]);
				}
			}
		}
	}
	cout<<dp[0][n-1]<<'\n';
	return 0;
}


Measured memory_bytes: 78080
#include<stdio.h>
long long int dp[101][21];
int main(void)
{
	int n;
	int s[101];
	int i,j,k;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&s[i]);
		
	}
	for(i=1;i<=n;i++){
		for(j=0;j<=20;j++){
			dp[i][j]=0;
		}
	}
	
	dp[1][s[1]]=1;
	for(i=1;i<n-1;i++){
		for(j=0;j<=20;j++){
			if(dp[i][j]!=0){
				if(s[i+1]+j<=20){
					dp[i+1][s[i+1]+j]+=dp[i][j];
				}
				if(j-s[i+1]>=0){
					dp[i+1][j-s[i+1]]+=dp[i][j];				
				}
			}
		}
	}
	printf("%lld\n",dp[n-1][s[n]]);
	return 0;
}

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

class Vertex {
 public:
  int index, connection_num;
  vector<int> connections;

  Vertex() :
    index(0),
    connection_num(0) {
  };

  bool operator < (const Vertex &v) const {
    return connection_num < v.connection_num;
  }
};

int main() {
  int N;
  cin >> N;
  int A[N], B[N], C[N];
  Vertex v[N];
  for (int i = 0; i < N-1; i++) {
    v[i].index = i;
    int a, b;
    cin >> a >> b;
    v[a-1].connections.push_back(b-1);
    v[b-1].connections.push_back(a-1);
    v[a-1].connection_num++;
    v[b-1].connection_num++;
  }
  v[N-1].index = N-1;
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  int sum = 0, cur_index = 0;
  int ans[N];
  sort(C, C+N);
  while (cur_index < N-1) {
    sort(v+cur_index, v+N);
      Vertex cur_vtx = v[cur_index];
      sum += C[cur_index] * cur_vtx.connection_num;
      ans[cur_vtx.index] = C[cur_index];
      for (int i = 0; i < cur_vtx.connections.size(); i++) {
        for (int j = cur_index+1; j < N; j++) {
          if (v[j].index == cur_vtx.connections[i]) {
            v[j].connection_num--;
            break;
          }
        }
      }
      cur_index++;
  }
  ans[v[cur_index].index] = C[cur_index];
  cout << sum << endl;
  for (int i = 0; i < N; i++) {
    cout << ans[i];
    if (i != N-1) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Vector;
import java.util.Scanner;
import java.util.Stack;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ALimitedInsertion solver = new ALimitedInsertion();
        solver.solve(1, in, out);
        out.close();
    }

    static class ALimitedInsertion {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 逆順でやればいい
            // ここでやばなのは後ろから順番にやること
            int n = in.nextInt();
            ArrayList<Integer> al = new ArrayList<>();
            Stack<Integer> st = new Stack<>();
            for (int i = 0; i < n; i++) {
                al.add(in.nextInt());
            }

            while (!al.isEmpty()) {
                boolean f = true;
                for (int i = al.size() - 1; i >= 0; i--) {
                    if (al.get(i) == i + 1) {
                        f = false;
                        st.add(al.get(i));
                        al.remove(i);
                        break;
                    }
                }
                if (f) {
                    out.println(-1);
                    return;
                }
            }

            while (!st.isEmpty()) {
                out.println(st.pop());
            }

        }

    }
}



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

int dp[3][100002];
#define M(a, b) max(dp[a][i], dp[b][i])

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    dp[0][i + 1] = M(1, 2) + a;
    dp[1][i + 1] = M(0, 2) + b;
    dp[2][i + 1] = M(0, 1) + c;
  }

  printf("%d\n", max(dp[0][N], max(dp[1][N], dp[2][N])));
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if((10*g+b)%4 == 0) puts("YES");
	else puts("NO");
 	return 0;
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
dp = [0]*(n+1)
ball = [1]*(n+1)
dp[0] = 1
for i in range(m):
  x,y = (int(i) for i in input().split())
  if dp[x-1] == 1:
    dp[y-1] = 1
  ball[x-1] -= 1
  ball[y-1] += 1
  if ball[x-1] == 0:
    dp[x-1] = 0
print(sum(dp))

Measured memory_bytes: 4596
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, a, b = MI()

    ao = n // (a + b)
    r = n % (a + b)
    print(a * ao + min(r, a))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
signed main(){
  long long n , m , a;
  cin>>n>>m;
  if(n == 1 && m == 1){
    a=1;
  } else if(n == 1 || m == 1){
    a=max(n,m)-2;
  } else {
    a = (n-2)*(m-2);
  }
  cout<<a<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,a,b;
	int i;
	cin>>n;
	for(i=1;i<=sqrt(n);i++){
		if(n%i==0){
			a=i;
			b=n/a;
		}
	}
	long long count=0;
	if(a>=b){
		while(a!=0){
			count++;
			a/=10;
		}
	}else{
		while(b!=0){
			count++;
			b/=10;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

template<int mod> class modint {
public:
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = (long long) x * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
#define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
  op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) bool operator o(modint that) const { return x o that.x; }
  op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};

using mint = modint<100000>;

mint dp[110][110][3][2];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0) break;
    rep(i, 110) rep(j, 110) rep(k, 3) rep(l, 2) dp[i][j][k][l] = 0;
    dp[0][0][0][0] = 1;
    rep(i, w) rep(j, h) rep(k, 3) rep(l, 2) reps(m, 2) {
      if (l == 1 && k != m) continue;
      if (k > 0 && k != m) {
        switch (m) {
          case 1: dp[i + 1][j][1][1] += dp[i][j][k][l]; break;
          case 2: dp[i][j + 1][2][1] += dp[i][j][k][l]; break;
        }
      } else {
        switch (m) {
          case 1: dp[i + 1][j][1][0] += dp[i][j][k][l]; break;
          case 2: dp[i][j + 1][2][0] += dp[i][j][k][l]; break;
        }
      }
    }
    mint ans = 0;
    rep(k, 3) rep(l, 2) ans += dp[w - 1][h - 1][k][l];
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3388
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;


int main(void) {

	int n, a;
	int max = -1000000, min = 1000000;
	long int sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a > max)
			max = a;
		if (a < min)
			min = a;
		sum += a;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X;
    cin>>N>>X;
    ll res = N;
    ll a = max(N-X,X), b = min(N-X,X);

    while(b){
        ll q = a/b;
        ll r = a%b;

        res += (b*2) * q;
        if(r==0) res -= b;
        a=b,b=r;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pdbs;
using namespace std;

// typedef tree<int, null_type, less<int>, rb_tree_tag,  
//             tree_order_statistics_node_update>  
//     ordered_set;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define ms(dp, x) memset(dp, x, sf(dp))

int main()
{
	fastio();
	ll n, m;
	cin>>n>>m;
	ll sum = 0, sum1 = 0, sum2 = 0;
	rep(i, m-1)
		sum1 += i;
	rep2r(i, n-m+2, n+1)
		sum2 += i;
	// sum += 
	rep2(i, m-1, n+1){
		sum1 += i;
		sum2 += n-i;
		// cout<<sum1<<" "<<sum2<<endl;
		sum = (sum + sum2 - sum1 +1)%mod;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>S;
    vector<bool> in(N), ans(N);
    rep(i,N) in[i] = S[i] == 'o';
    rep(s, 4){
        ans[0] = s%2;
        ans[1] = s/2;
        reps(i,2,N){
            ans[i] = ans[i-2] ^ ans[i-1] ^ in[i-1];
        }
        if(ans[0] ^ ans[1] ^ ans[N-1] == in[0]
        && ans[N-2] ^ ans[N-1] ^ ans[0] == in[N-1]){
            rep(i,N) cout<<(ans[i] ? 'S' : 'W');
            cout<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n;
	cin >> n;

	int a[n], b[n];

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = n-1; i >= 0; i--)
		cin >> b[i];

	bool swapped = true;

	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			swapped = false;

			for (int j = 0; j < n; j++) {
				if (b[i] == b[j])
					continue;

				if (a[j] == b[i])
					continue;

				if (a[i] == b[j])
					continue;

				swap(b[i], b[j]);
				swapped = true;
				break;
			}

			if (!swapped)
				break;
		}
	}

	if (swapped) {
		cout << "Yes" << endl;
		for (int i = 0; i < n; i++)
			cout << b[i] << " ";

	} else
		cout << "No";

	return 0;
}

Measured memory_bytes: 5204
#include <stdio.h>

int main(void) {

  long a,b_1,b_2;
  scanf("%ld %ld.%ld", &a, &b_1, &b_2);
  long ans = a*b_2;
  ans /= 100;
  ans += a*b_1;
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 1652