akhauriyash/Code-Regression huggingface dataset:
import sys
import math

#+++++

ppi=3.141592653589793238462643383279502884197169399375105820974944592307816406286208998

def deg_to_rad(a_deg):
	return math.pi * a_deg / 180.0
	
def max_v(a,b,deg):
	tt = a * math.tan(ppi * deg / 180.0)
	if tt <= b:
		return (a*b)-(a*tt/2)
	else:
		return b*b*math.tan(ppi*(90.0-deg)/180.0)/2
		
def is_ok(a,b,x,deg):
	pa((a * max_v(a,b,deg),deg))
	return x < a * max_v(a,b,deg)
		
def main():
	a, b ,x = map(int, input().split())
	if a*a*b == x:
		return 0
	ok = 0.0
	ng =90.0
	while abs(ok-ng) > 0.0000001:
		mid = (ok+ng)/2.0
		if is_ok(a,b,x,mid):
			ok = mid
		else:
			ng = mid
	return ok
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using ll = long long;
using ld = long double;
using Pa = std::pair<ll, ll>;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n,ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow(((x * x)%mod), n / 2,mod));
	else
		return ((x%mod) * pow(x, n - 1,mod));
}
vector<ll>primess(ll n) {
	vector<ll>a;
	while (n % 2 == 0)n /= 2, a.push_back(2);
	ll sosuu = 3;
	while (n != 1) {
		if (n % sosuu == 0)n /= sosuu, a.push_back(sosuu);
		else if (sosuu > sqrt(n) + 2) {
			a.push_back(n);
			break;
		}
		else sosuu += 2;
	}
	return a;
}
bool prime(int n) {
	int i = 2;
	if (n == 2)return true;
	else if(n <= 1)return false;
	if (n % i == 0)return false;
	i = 3;
	while (i <= sqrt(n)) {
		if (n % i == 0)return false;
		i += 2;
	}
	return true;
}
int main() {
	ll x, k, d; cin >> x >> k >> d;
	x = abs(x);
	if (k < x/d)cout << x - (k * d) << endl;
	else {
		ll num = x / d;
		if ((num % 2) == (k % 2))cout << x % d << endl;
		else cout << d - (x % d) << endl;
	}
}

Measured memory_bytes: 3720
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
# mod = 10**9+7
mod = 998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"
INF = 1<<32-1
# INF = 10**18

def main():
    n,k = map(int,ipt().split())
    dp = [0]*(n+1)
    dp[1] = 1
    rng = [tuple(map(int,ipt().split())) for i in range(k)]
    for i in range(2,n+1):
        for l,r in rng:
            dp[i] += dp[max(0,i-l)]-dp[max(0,i-r-1)]
        dp[i] += dp[i-1]
        dp[i] %= mod

    print((dp[n]-dp[n-1])%mod)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 77220
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import java.io.*;

public class Main {
    public static void main(String argv[]) {
        Scanner cin = new Scanner(System.in);
        final int MX = 170*80;
        int h = cin.nextInt();
        int w = cin.nextInt();
        int[][] a = new int[h][w];
        int[][] b = new int[h][w];
        Boolean[][][] c = new Boolean[h][w][MX];
        Consumer<BiConsumer<Integer,Integer>> loop = f ->
            IntStream.range(0, h).forEach(i ->
                IntStream.range(0, w).forEach(j -> f.accept(i,j)) );
        loop.accept((i,j)-> Arrays.fill(c[i][j], false));
        loop.accept((i,j)-> a[i][j] = cin.nextInt());
        loop.accept((i,j)-> b[i][j] = cin.nextInt());
        loop.accept((i,j)-> {
            int d = Math.abs(a[i][j]-b[i][j]);
            IntStream.range(0, MX).forEach(k->{
                if (i>0 && c[i-1][j][k] 
                        || j>0 && c[i][j-1][k] 
                        || i==0 && j==0 && k==0) {
                    c[i][j][k+d] = c[i][j][Math.abs(k-d)] = true;
                    // System.err.println("a("+k+"): " + i +" "+ j + " " + (k+d));
                    // System.err.println("s("+k+"): " + i +" "+ j + " " + Math.abs(k-d));
                }
            });
        });
        long answer = Arrays.asList(c[h-1][w-1]).indexOf(true);
        System.out.println(answer);
    }
}


Measured memory_bytes: 538212
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <iomanip>
using namespace std;
long Nchoose2(long n){
    return n*(n-1)/2;
}
int main(){
    int n,x,y;
    cin >> n >> x >> y;
    int ans = 0;
    vector<int> a(n);
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            int tmp = min(j-i, 1 + abs(j-y) + abs(i-x));
            a[tmp]++;
        }
    }
    for(int i = 1; i <= n-1; i++){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<unordered_map>
using namespace std;
typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<int, lld> pil;
typedef pair<pii, int> piii;
int n;
char xx[1000009];
pii b[1000009];
pii c[1000009];
int main()
{
	int i, j, k, l;
	int t = 1, tv = 0;
	while(t--)
	{
		scanf("%d", &n);
		int sum = 0;
		for (i = 0; i < n; i++) {
			scanf("%s", xx);
			int xl = 0;
			int st = 0;
			int mm = 0;
			for (j = 0; xx[j]; j++) {
				if (xx[j] == '(')st++;
				else st--;
				mm = max(mm, -st);
			}
			xl = j;
			sum += st;
			if (st >= 0) {
				b[mm].first++;
				b[mm].second += st;
			}
			else {
				mm = st = 0;
				for (j = xl - 1; j >= 0; j--) {
					if (xx[j] == ')')st++;
					else st--;
					mm = max(mm, -st);
				}
				c[mm].first++;
				c[mm].second += st;
			}
		}
		bool valid = true;
		if (sum != 0) {
			valid = false;
		}
		else {
			int cnt = 0;
			int cur = 0;

			i = j = 0;
			while (i <= j) {
				if (b[i].first > 0) {
					cnt += b[i].first;
					j += b[i].second;
				}
				i++;
			}
			cur = j;

			i = j = 0;
			while (i <= j) {
				if (c[i].first > 0) {
					cnt += c[i].first;
					j += c[i].second;
				}
				i++;
			}
			if (cnt < n || cur != j) { valid = false; }
		}
		printf("%s\n",valid?"Yes":"No");
	}
}

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

constexpr long mod = 1000000007;

long inv(long x) {
    long r = 1;
    long y = mod-2;
    while(y) {
        if(y&1) r *= x, r %= mod;
        x *= x, x %= mod;
        y >>= 1;
    }
    return r;
}

long comb(long x, long y) {
    long r = 1, s = 1;
    for(long i=0; i<y; i++)
        r *= x-i, r %= mod;
    for(long i=0; i<y; i++)
        s *= i+1, s %= mod;
    return r * inv(s) % mod;
}

long fact(long x) {
    long r = 1;
    for(long i=1; i<=x; i++)
        r *= i, r %= mod;
    return r;
}

int main(void) {
    long n, m ,k;
    cin >> n >> m >> k;

    long sum = 0;
    
    for(long x=0; x<m; x++) {
        long a;
        a = x*(x+1)/2, a %= mod;
        a = a * n, a %= mod;
        sum += a * n, sum %= mod;

        a = (m-1-x)*(m-1-x+1)/2 % mod;
        a = a * n, a %= mod;
        sum += a * n, sum %= mod;
    }

    for(long y=0; y<n; y++) {
        long a;
        a = y*(y+1)/2 % mod;
        a = a * m, a %= mod;
        sum += a * m, sum %= mod;

        a = (n-1-y)*(n-1-y+1)/2 % mod;
        a = a * m, a %= mod;
        sum += a * m, sum %= mod;
    }

    long r = 1;
    r *= sum, r %= mod;
    r *= comb(n*m-2, k-2), r %= mod;
    r *= inv(2), r %= mod;
    cout << r << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
int prime[1000001];
void sieve()
{
	prime[1]=1;
	prime[0]=1;
	int j;
	for(j=2;j<=1000000;j++)
	{
		prime[j]=j;
	}
	for(j=2;j<=1000;j++)
	{
		if(prime[j]==j)
		{
			for(int k=2;j*k<=1000000;k++)
			{
				prime[j*k]=j;
			}
		}
	}
}
int function(multiset<int> &st,int n)
{
	map<int,int> mp;
	for(int x:st)
	{
		mp[x]++;
	}
	mp[0]=n-st.size();
	while(1)
	{
		auto it1=mp.end();
		it1--;
		auto it2=mp.begin();
		int val1=it1->first;
		int val2=it2->first;
		if(val1-val2<=2)
		{
			break;
		}
		int newval1=val1-2;
		int newval2=val2+1;
		it1->second--;
		if(it1->second==0)
		   mp.erase(it1);
		it2->second--;
		if(it2->second==0)
		   mp.erase(it2);
		mp[newval1]++;
		mp[newval2]++;
	}
	auto it=mp.begin();
	return it->first;
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
	 int n,m;
	 cin>>n>>m;
	 multiset<int> st;
	 int j;
	 map<int,multiset<int>> mp;
	 for(j=0;j<n;j++)
	 {
		 int a,b;
		 cin>>a>>b;
		 if(a<=m)
		 {
			 mp[a].insert(b);
		 }
	 }
	 int answer=0;
	 for(j=1;j<=m;j++)
	 {
		 for(int x:mp[j])
		 {
			 st.insert(x);
		 }
		 if(st.size()!=0)
		 {
			 auto it=st.end();
			 it--;
			 answer+=(*it);
			 st.erase(it);
		 }
	 }
	 cout<<answer<<endl;
}


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

int main() {
	long long N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<long long> > A(N, vector<long long>(M));
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		for (int j = 0; j < M; j++) A[i][j] = S[j] - '0';
	}
	vector<vector<long long> > COUNTA(N + 1, vector<long long>(M + 1, 0)), COUNTB(N, vector<long long>(M, 0)), COUNTC(N, vector<long long>(M, 0));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			COUNTA[i + 1][j + 1] = COUNTA[i + 1][j] + COUNTA[i][j + 1] - COUNTA[i][j] + A[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M - 1; j++) {
			if (A[i][j] == 1 && A[i][j + 1] == 1) COUNTB[i][j + 1] = COUNTB[i][j] + 1;
			else COUNTB[i][j + 1] = COUNTB[i][j];
		}
	}
	for (int j = 0; j < M; j++) {
		for (int i = 0; i < N - 1; i++) COUNTB[i + 1][j] += COUNTB[i][j];
	}
	for (int j = 0; j < M; j++) {
		for (int i = 0; i < N - 1; i++) {
			if (A[i][j] == 1 && A[i + 1][j] == 1) COUNTC[i + 1][j] = COUNTC[i][j] + 1;
			else COUNTC[i + 1][j] = COUNTC[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M - 1; j++) COUNTC[i][j + 1] += COUNTC[i][j];
	}
	for (int i = 0; i < Q; i++) {
		long long X1, Y1, X2, Y2;
		cin >> X1 >> Y1 >> X2 >> Y2;
		X1--, Y1--, X2--, Y2--;
		long long ANS = COUNTA[X2 + 1][Y2 + 1] - COUNTA[X2 + 1][Y1] - COUNTA[X1][Y2 + 1] + COUNTA[X1][Y1];
		ANS -= COUNTB[X2][Y2] - COUNTB[X2][Y1];
		if (X1 != 0) ANS += COUNTB[X1 - 1][Y2] - COUNTB[X1 - 1][Y1];
		ANS -= COUNTC[X2][Y2] - COUNTC[X1][Y2];
		if (Y1 != 0) ANS += COUNTC[X2][Y1 - 1] - COUNTC[X1][Y1 - 1];
		cout << ANS << endl;
	}
}

Measured memory_bytes: 128768
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {

	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a + b > c + d)cout << "Left\n";
	else if (a + b == c + d)cout << "Balanced\n";
	else cout << "Right\n";

	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc170/tasks/abc170_d
//Under Construction
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int mp[1111111]={0};
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;++i){
		int val;
		cin>>val;
		++mp[val];
		a.push_back(val);
	}
	int ans = 0;
	for(int i=0;i<n;++i){
		int val = a[i];
		int no = 0;
		if(mp[val]>1) continue;
		if(val==1){++ans;continue;}
		for(int j=1;j<=sqrt(val);++j){
			if(j==1){
				if(mp[j]){
					++no;
					break;
				}
				continue;
			}
			if(val%j==0){
				if(mp[j] || mp[val/j]){
					++no;
					break;
				}
			}
		}
		if(!no) {++ans;}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 8112
#include <iostream>
#include <cstdio>

long long gcd(long long m, long long n);
long long lcm(long long m, long long n, long long g);

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    long long a, b;
    long long g, l;
    while (std::cin >> a >> b) {
        g = gcd(a, b);
        l = lcm(a, b, g);
        std::cout << g << " " << l << std::endl;
    }
}

long long gcd(long long m, long long n)
{
    long long t;
    if (m < n) {
        t = m;
        m = n;
        n = t;
    }
    if (n == 0) return m;
    return gcd(n, m % n);
}

long long lcm(long long m, long long n, long long g)
{
    return m * n / g;
}




Measured memory_bytes: 3104
#include<cstdio>
#include<cstring>
#define N 100010
using namespace std;

int n, k;
int dp[N][2];
int a[N];

bool dfs(int k, int t) {
	if (dp[k][t] >= 0) return dp[k][t];
	int ans = 0;
	for (int i = 1; i <= n; i++) if (k >= a[i]) ans |= !dfs(k - a[i], !t);
	return dp[k][t] = ans;
}

signed main() {
	memset(dp, -1, sizeof(dp));
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	if (dfs(k, 0) == true) puts("First");
	else puts("Second");
}


Measured memory_bytes: 5632
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int s = sc.nextInt();

    sc.close();

    boolean valid = true;

    Set<Integer> hashSet = new HashSet<Integer>();

    hashSet.add(s);

    int count = 2;

    while (valid) {

      if (s % 2 == 0) {
        s = s / 2;
      } else {
        s = 3 * s + 1;
      }

      if (hashSet.contains(s)) {
        valid = false;
      } else {
        hashSet.add(s);
        count++;
      }

    }

    System.out.println(count);

  }

}

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

int main() {
  int n;
  cin >> n;
  multiset<double> v;
  for (int i = 0; i < n; ++i) {
    double vv;
    cin >> vv;
    v.insert(vv);
  }
  for (int i = 0; i < n - 1; ++i) {
    double a = *v.begin();
    v.erase(v.begin());
    double b = *v.begin();
    v.erase(v.begin());
    v.insert((a + b) / 2);
  }
  printf("%f\n", *v.begin());
  return 0;
}


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

int main()
{
  int k, a, b;
  cin >> k >> a >> b;

  string ans;
  if (a <= k * (b/k) && k * (b/k) <= b){
    ans = "OK";
  }else{
    ans = "NG";
  }

  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	static int[][] bingo = new int[3][3];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());

		int total=0;
		for(int i=0;i<n;i++) {
			int ball = Integer.parseInt(sc.next());
			if(ball<k-ball) {	//Aの方が短い
				total+=ball*2;
			}else {
				total+=(k-ball)*2;
			}
		}
		System.out.println(total);
	}


}


Measured memory_bytes: 23892
n = int(input())
s = input()
w = [0 for _ in range(n)]
e = [0 for _ in range(n)]
for i in range(1,n-1):
    if s[i-1] == 'W':
        w[i] = w[i-1] + 1
    else:
        w[i] = w[i-1]
    
    if s[n-i] == 'E':
        e[n-1-i] = e[n-i] + 1
    else:
        e[n-1-i] = e[n-i]

w[n-1] = w[n-2]
e[0] = e[1]
min = n
for i in range(n):
    if min > w[i]+e[i]:
        min = w[i]+e[i]

print(min)

Measured memory_bytes: 17872
def resolve():
    S = input()
    T = input()
    mincnt = float("inf")
    for ptr in range(len(S)-len(T)+1):
        cnt = 0
        for i in range(len(T)):
            sptr = ptr + i
            if S[sptr] != T[i]:
                cnt += 1
        mincnt = min(cnt, mincnt)
    print(mincnt)



    
if '__main__' == __name__:
    resolve()

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

using namespace std;

#define umap std::unordered_map
#define uset std::unordered_set
#define _all(container) std::begin(container), std::end(container)
#define _in(container, value) (std::find(_all(container), value) != std::end(container))
#define _in_if(container, predicate) (std::find_if(_all(container), predicate) != std::end(container))
#define _count(container, value) (std::count(_all(container), value))
#define _count_if(container, predicate) (std::count(_all(container), predicate))
#define _odd(value) (value & 1)
#define _even(value) !(value & 1)
#define _for(i, n) for (int i = 0; i < n; ++i)
#define _FOR(i, k, n) for (int i = k; i <= n; ++i)
#define _FORR(i, k, n) for (int i = n; i >= k; --i)

template <typename DATA_TYPE> using V = std::vector<DATA_TYPE>;
template <typename DATA_TYPE> using VV = std::vector<std::vector<DATA_TYPE>>;
template <typename DATA_TYPE> using C = const DATA_TYPE;
using vint = V<int>;
using pint = std::pair<int, int>;
using vpint = V<pint>;
using vdouble = V<double>;
using cint = C<int>;
using cdouble = C<double>;
using Integer = long long;
using ll = long long;

template <class DATA_TYPE> DATA_TYPE countP(DATA_TYPE n)
{
    DATA_TYPE count = 0;
    if (_even(n))
        count++;

    while (_even(n))
        n >>= 1;

    for (DATA_TYPE p = 3; p * p <= n; p += 2) {
        if (n % p)
            continue;

        count++;

        while (n % p == 0)
            n /= p;
    }

    if (n != 1) {
        count++;
    }

    return count;
}

int main(int argc, char**)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    Integer A, B;
    cin >> A >> B;

    cout << countP(__gcd(A, B)) + 1 << "\n";
}


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

int main() {
    int a, b, res, plg;
    cin >> a >> b;
    res = 0;
    plg = 1;
    while(plg < b) {
        plg += a - 1;
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int[][] A = new int[N][M];
		int[] B = new int[M];
		for(int i = 0; i < M; i++){
			B[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++){
			for(int j = 0; j < M; j++){
				A[i][j] = sc.nextInt();
			}
		}
		sc.close();
		int result = 0;
		for(int i = 0; i < N; i++){
			int r = multiply(A[i], B, C);
			if(r > 0) result++;
		}
		System.out.println(result);
	}
	
	
	public static int multiply(int[] A, int[] B, int C){
		int result = 0;
		for(int i = 0; i < A.length; i++){
			result += (A[i] * B[i]);
		}
		return result + C;
		
	}
	

}


Measured memory_bytes: 23764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    long long ans = 0;
    for (int i = 1; i < N; i++) {
        if (A[i-1] > A[i]) {
            ans += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int ans=0,a=0;
    rep(i,s.size()){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') a++;
        else a=0;
        ans=max(ans,a);
    }
    cout<<ans;
}

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

struct Card{
    char suit;
    int value;
};

void BubbleSort(struct Card C[], int N);
void SelectionSort(struct Card C[], int N);
void printCardArray(struct Card C[], int N){
    for (int i=0; i<N; i++){
        if(i==N-1) cout << C[i].suit << C[i].value << endl;
        else cout << C[i].suit << C[i].value << ' ';}
}
//バブルソートと選択ソートの結果を比較して安定性を調べる
bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i=0; i<N; i++){
        if (C1[i].suit != C2[i].suit)
            return false;
    }
    return true;
}
int main(){
    Card card1[40], card2[40];
    int num;
    cin >> num;
    for (int i=0; i<num; i++){
        cin >> card1[i].suit >> card1[i].value;
        card2[i] = card1[i];
    }

    BubbleSort(card1, num);
    SelectionSort(card2, num);

    printCardArray(card1, num);
    cout << "Stable\n";
    printCardArray(card2, num);
    if(isStable(card1, card2, num))
        cout << "Stable\n";
    else cout << "Not stable\n";

    return 0;
    
}

void BubbleSort(struct Card C[], int N){
    for(int j=0; j<N; j++){
        for(int i=N-1; i>j; i--){
            if(C[i].value < C[i-1].value){
                Card t = C[i-1];
                C[i-1] = C[i];
                C[i] = t;
            }
        }
    }
}
void SelectionSort(struct Card C[], int N){
    int minj;
    for (int j=0; j<N; j++){
        minj = j;
        for (int i=j+1; i<N; i++){
            if(C[minj].value > C[i].value){
                minj = i;
            }
        }
        if(minj != j){
            Card t = C[minj];
            C[minj] = C[j];
            C[j] = t;
        }
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

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

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, k;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    int g = n / k;
    ll res = (ll) g * g * g;
    if (k % 2 == 0) {
        int cnt = 0;
        FOR(i,1,n)
            if (i % k == k / 2) cnt++;
        res += (ll) cnt * cnt * cnt;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  cin >> n;
  int x=0,y=0;
  rep(i,n) {
    int z;
    R z;
    if(z%2) x++;
    else y++;
  }
  if(x%2==0) pr("YES");
  else pr("NO");
}

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


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

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	ll n, m, ans = 0; cin >> n >> m;
	if (n >= m/2) {
		ans = m/2;
	} else {
		ans = n + (m - 2*n)/4;
	}
	cout << ans << endl;
	return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main() {
    ll n;
    cin >> n;
    ll h[100010];
    ll dp[100010];

    NREP() {
        cin >> h[i];
        dp[i] = LONG_LONG_MAX;
    }

    dp[0] = 0;
    NREP() {
        if (i == 0) continue;
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    MSG(dp[n - 1])
}


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

int n[100];

int main()
{
	string n;
	cin >> n;
	int k = n.size();
	for (int i = 0; i < k; ++i)
	{
		cin >> n[i];
		if (n[i] == '9')
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
readInt :: String -> Int
readInt = read

main = do
 _ <- getLine
 arr <- (map readInt . words) <$> getLine
 case foldr foo' (Just(2,2)) arr of
  Nothing -> print(-1)
  Just (a,b) -> putStrLn(show a++" "++show b)

type Cand = [Int]
type Cand' = (Int,Int)

foo' :: Int -> Maybe Cand' -> Maybe Cand'
foo' divisor Nothing = Nothing
foo' divisor (Just(a,b)) = if lower > upper then Nothing else Just(lower,upper+divisor-1)
 where 
  lower = ((-a)`div`divisor)*(-divisor)
  upper = (b`div`divisor)*divisor
  
  
-- reverse action
foo :: Int -> Cand -> Cand
foo divisor cand = [ c+rem | c <- newcand, rem <- [0..divisor-1] ]
 where newcand = [c | c <- cand, c `mod` divisor == 0]

Measured memory_bytes: 61820
#include <bits/stdc++.h>
#define ll long long int
#define N 1000
#define M 1000000007
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define mp make_pair
#define bs binary_search
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Rishabh
  *
  */
double dp[3001][3001];
double solve(vector<double>&a,int i,int x)
{
	if(x==0)
	return 1;
	if(i==0)
	return 0;
	if(dp[i][x]>-0.9)
	return dp[i][x];
	
	return dp[i][x]=a[i]*solve(a,i-1,x-1)+(1-a[i])*solve(a,i-1,x);
}
int main()
{
	ibs;
	cti;
	int n;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	vector<double>a(n+1);
	for(int i=1;i<=n;i++)
	cin>>a[i];
	double ans=solve(a,n,(n+1)/2);
	cout<<fixed<<setprecision(10)<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i = l; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
  int n,max = 0,i,j,count;
  cin >> n;
  vector<string> a(n);
  vector<string> b;
  vector<pair<string,int>> v;
  rep(i,0,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  for(i = 0; i < n;) {
    count = 0;
    for(j = i; j < n; j++) {
      if(a.at(i) == a.at(j)) count++;
      else break;
    }
    if(max < count) max = count;
    v.push_back(make_pair(a.at(i),count));
    i = j;
  }
  for(i = 0; i < v.size(); i++) {
    if(v.at(i).second == max) cout << v.at(i).first << "\n";
  }
  return 0;
}

Measured memory_bytes: 18676
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
  
	long long a, b;
	cin >> a >> b;
	bitset<32> b1(a), b2(b);
	cout << (b1&b2) << '\n' << (b1|b2) << '\n' << (b1^b2) << '\n';
	//long long n;
	//cin >> n;
	//bitset<32> b(n);
	//cout << b << '\n' << (~b) << '\n' << (b<<1) << '\n' << (b>>1) << '\n';
    return 0;
}



Measured memory_bytes: 3204
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;

vector<int>nums(4);

int main() {
	//int N,K;cin>>N>>K;
	//bool ok=N>K*2-2;
	//if (ok) {
	//	cout<<"YES"<<endl;
	//}
	//else {
	//	cout<<"NO"<<endl;
	//}

	for (int i = 0; i < 3; ++i) {
		int a,b;cin>>a>>b;
		a--;b--;
		nums[a]++;
		nums[b]++;
	}
	int sum=0;
	sort(nums.begin(),nums.end());
	if (nums == vector<int>{ 1,1,2,2 })cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << '[' << *it << " = " << a << "]  ";
    err(++it, args...);
}

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<lli, lli> tii;
typedef tuple<lli, lli, lli> tiii;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;


void solve(){
	int n,m; cin>>n>>m;
	vi a(n);
	int s=0;
	rep(i,n){
		cin>>a[i];
		s+=a[i];
	}
	int ans=0;
	rep(i,n){
		if(a[i]*4*m >= s) ans++;
	}
	if(ans>=m) cout<<"Yes";
	else cout<<"No";

}

int main(){
	fast_io
	int tc=1;
	//cin>>tc;
	while(tc--){solve();}
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;


/*A
简单比较大小 
*/ 

int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	if(t>=n) printf("0\n");
	else printf("%d\n",n-t);
	return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e4+7;

int MAX=1000100;
vector<vector<int> >trie(MAX,vector<int>(26));
vector<int>leaf(MAX);

int sz=1;
void add_string(string s){
    int v=0;
    for(auto c:s){
        if(!trie[v][c-'a']){
            trie[v][c-'a']=sz;
            sz++;
        }
        v=trie[v][c-'a'];
    }
    leaf[v]=1;
}

signed main(){
    ll n;cin>>n;
    vector<string>a(n);
    rep(i,n){
        cin>>a[i];
        reverse(all(a[i]));
        add_string(a[i]);
    }
    ll ans=0;
    rep(i,n){
        string s;
        s=a[i];
        vector<ll>cnt(26);
        for(auto c:s){
            cnt[c-'a']++;
        }
        ll v=0;
        rep(j,s.size()){
            rep(x,26){
                if(cnt[x]&&trie[v][x]){
                    ans+=leaf[trie[v][x]];
                }
            }
            cnt[s[j]-'a']--;
            v=trie[v][s[j]-'a'];
        }
        ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 259504
import sys

inf = 1<<60
ans = inf

def solve():
    H, W = map(int, input().split())
    calc(H, W)
    calc(W, H)
    print(ans)

def calc(H, W):
    global ans

    for a in range(1, W):
        s0 = a * H

        s1 = H * ((W - a + 1) // 2)
        s2 = H * ((W - a) // 2)

        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))

        s1 = (W - a) * ((H + 1) // 2)
        s2 = (W - a) * (H // 2)

        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2)) 

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	vector<int> s,j;
	int k;
	for(int i=0;i<3;i++)
	{
		cin >> k;
		s.pb(k);
	}
	cin >> k;j.pb(k);
	cin >> k;j.pb(k);
	SORT(s);
	SORT(j);
	cout << s[0]+j[0]-50 << endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define mp make_pair
#define f first
#define s second
#define pb push_back

int main()
{
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);

    int a,b;
    cin>>a>>b;
    int curr = 1;
    int ans = 0;
    while(curr<b)
        curr+=a-1,ans++;
    cout<<ans;
}


Measured memory_bytes: 256
import sys

S = list(input())

if S[0] == "A":
    S.remove("A")
else:
    print("WA")
    sys.exit()

if S[1:-1].count("C") == 1:
    S.remove("C")
else:
    print("WA")
    sys.exit()

if "".join(S).islower():
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
// Problem : A - Five Variables
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_a?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int arr[6];
    int ans=0;
    for(int i=0;i<5;i++){
    	cin>>arr[i];
    	if(arr[i]==0){
    		ans=i+1;
    	}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string s;

  cin >> s;

  int ans = INF;
  
  for(int i=0;i+3<=s.size();i++){
    int v = stoi(s.substr(i, 3));
    ans = min(ans, abs(753 - v));
  }

  cout << ans << endl;
  
  return 0;
}




Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    d:isize,
    }
    println!("{}",if d%2==0{a-b}else{b-a})
}

Measured memory_bytes: 2108
#include <stdio.h>

int main(void)
{
	int n, a, b, c, d, count;
	while(scanf("%d", &n) != EOF){
		count = 0;
		for(a = 0; a < 10; a++){
			if(a > n) break;
			for(b = 0; b < 10; b++){
				if(a + b > n) break;
				for(c = 0; c < 10; c++){
					if(a + b + c > n) break;
					for(d = 0; d < 10; d++){
						if(a + b + c + d == n){
							count++;
							break;
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
    int key;
    Node *prev;
    Node *next;
};

Node *nil;

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key){
    Node *x = (Node*)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t){
    if( t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(cur != nil){
        if(isf++ > 0)printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main(){
    int n;
    scanf("%d", &n);
    int i, key;
    char command[100];
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d", command, &key);
        if(command[0] == 'i'){
            insert(key);
        }else if(command[0] == 'd'){
            if(strlen(command) > 6){
                if(command[6] == 'F'){
                    deleteFirst();
                }else if(command[6] == 'L'){
                    deleteLast();
                }
            }else{
                deleteKey(key);
            }
        }
    }
    printList();

    return 0;
}


Measured memory_bytes: 33840
#include <cstdio>
#include <cmath>

int main(){
	while(1){
		int n, s[1000];
		double m=0, alpha=0;
		
		scanf(" %d", &n);
		if(n==0) break;
		
		for(int i=0; i<n; ++i){
			scanf(" %d", &s[i]);
			m += s[i];
		}
		
		m /= (double)n;
		
		for(int i=0; i<n; ++i)
			alpha += pow(s[i]-m, 2.0);
		alpha /= (double)n;
		
		printf("%lf\n", sqrt(alpha));
	}	
		return 0;
}

Measured memory_bytes: 1064
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline
import copy

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

h,w,k = map(int, input().split())

d = []
for i in range(h):
    s = input()
    d.append(list(s[:-1]))


c_h = 2**h
c_w = 2**w
ans = 0
ans_d = defaultdict(int)


for i in range(c_h):
    d_ = copy.deepcopy(d)
    for _h in range(h):
        if i >> _h & 1:
            for _ in range(w):
                d_[_h][_] = 0

    for j in range(c_w):
        d2_ = copy.deepcopy(d_)
        for _w in range(w):
            if j >> _w & 1:
                for _ in range(h):
                    d2_[_][_w] = 0

        val = 0
        for s1 in range(h):
            for s2 in range(w):
                if d2_[s1][s2] == '#':
                    val += 1
        if val == k:
            ans += 1
        # print(f'(i,j), {i},{j}, {val}, {d2_}')
        del d2_

print(ans)





Measured memory_bytes: 84628
#include<iostream>

using namespace std;

int main(){
	int n;
	cin>>n;
	while(n){
		n--;
		int y,m,d;
		cin>>y>>m>>d;
		int ans=0;
		{
			int a=1000/3;
			int b=y/3;
			int c=a-b;
			ans+=c*200;
			ans+=(1000-y-c-1)*195;
		}
		{
			if(y%3==0){
				ans+=(10-m)*20;
			}
			else{
				int a=10-m;
				int b=a/2;
				ans+=20*b+19*b+(a%2!=0)*19;
			}
		}
		{
			if(y%3==0||m%2!=0){
				ans+=(20-d);
			}
			else ans+=(19-d);
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include <string.h>
int main(){
  int i,num,total=0;
  char number[1001];

  while(1){
    scanf("%s",number);
    if(number[0] == '0')break;

    for(i = 0; i<strlen(number);i++){
      num = number[i] - '0';
      total = total + num;
    }
    printf("%d\n",total);
    total = 0;
  }

  return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int main()
{
	int n=gi(),m=gi();
	printf("%d\n",(1900*m+100*(n-m))<<m);
	return 0;
}


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

int main(void) {
  char S[27];
  cin >> S;

  int CNT[26];
  rep(i, 26) CNT[i] = 0;
  for (int i = 0; S[i] != '\0'; i++) {
    CNT[S[i] - 'a']++;
  }
  rep(i,26) {
      if(1 < CNT[i]) {
        cout << "no" << endl;
        return 0;
      }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define case "Case " << l << ":"
#define quit return 0

using namespace std;
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    char a;
    cin >> a ;
    if(isupper(a))
        cout << "A" ;
    else
        cout << "a" ;

    quit;
}


Measured memory_bytes: 3632
#include <stdio.h>
int N;
int a[100001];
int c[100001];
int main(){
  int i,j;
  int count=0;
  int x;
  scanf("%d",&N);
  for(i=1;i<=N;i++)scanf("%d",&a[i]);
  for(i=1;i<=N;i++){
    x=a[i];
    if(c[i]==0){
      if(a[x]==i){
	count++;
	c[i]=1;c[x]=1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  int ans = 0;
  int w = 10;
  for (int i = 0; i < 5; i++) {
    int x;
    cin >> x;
    ans += (x + 9) / 10 * 10;
    if (x % 10 != 0) {
      w = min(w, x % 10);
    }
    debug(ans);
  }
  ans += -10 + w;
  cout << ans;
  return 0;
}




Measured memory_bytes: 3552
#include <iostream>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MARK 'X'
using namespace std;

int H, W;
char map[100][100], f;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

void dfs(int x, int y)
{
  map[x][y] = MARK;
  REP(i,4){
    int next_x = x+dx[i], next_y = y+dy[i];
    if(next_x < 0 || next_x >= H || next_y < 0 || next_y >= W || map[next_x][next_y] != f) continue;
    dfs(next_x,next_y);
  }
}

int main()
{
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    int ans = 0;
    REP(i,H) REP(j,W) cin >> map[i][j];
    REP(i,H){
      REP(j,W){
        if(map[i][j] != MARK){
          f = map[i][j];
          dfs(i,j);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3476
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <deque>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 2e5 + 10;
int n;
long double a,b;
int main()
{
	/*
	int T;
	scanf("%d",&T);
	while(T --)
	{
		
	}
	*/
	cin >> a >> b;
	cout << (ll)(a * b) << endl;
	return 0;
} 

Measured memory_bytes: 3236