akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a_list = list(map(int, input().split()))

def rate_color(rate):
    if 1 <= rate and rate < 400:
        return 'ash'
    elif 400 <= rate and rate < 800:
        return 'brown'
    elif 800 <= rate and rate < 1200:
        return 'green'
    elif 1200 <= rate and rate < 1600:
        return 'lightblue'
    elif 1600 <= rate and rate < 2000:
        return 'blue'
    elif 2000 <= rate and rate < 2400:
        return 'yellow'
    elif 2400 <= rate and rate < 2800:
        return 'orange'
    elif 2800 <= rate and rate < 3200:
        return 'red'
    else:
        return 'anycolor'


color_list = []
for i in range(N):
    color_list.append(rate_color(a_list[i]))


basic_color_list = ['ash', 'brown', 'green', 'lightblue', 'blue', 'yellow', 'orange', 'red', 'anycolor']

count_list = []
for _ in basic_color_list:
    count_list.append(color_list.count(_))

count_list_but_anycolor = count_list[:-1]

count_anycolor = count_list[-1]
count_0 = count_list_but_anycolor.count(0)

max_result = 8 - count_0 + count_anycolor
min_result = 8 - count_0

if max_result == 0:
    max_result = 1
else:
    pass

if min_result == 0:
    min_result = 1
else:
    pass

print(min_result, max_result)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int gcd(int a, int b) {
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}

int main() {
    int x, y;
    cin >> x >> y;
    cout << gcd(max(x, y), min(x, y)) << endl;

    return 0;
}


Measured memory_bytes: 3116
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

struct state {
	int p, d;
	state(int p, int d) : p(p), d(d) {} ;
};

int main()
{
	int n, m;
	while(cin >> n >> m, n|m) {
		vvi f(n, vi(n));

		int a, b;
		REP(i, m) {
			cin >> a >> b;
			f[a-1][b-1] = 1;
			f[b-1][a-1] = 1;
		}

		vi check(n);
		queue<state> Q;
		Q.push(state(0, 0));

		while(!Q.empty()) {
			state st = Q.front();
			Q.pop();
			check[st.p] = 1;

			if(st.d == 2) {
				continue;
			}

			REP(i, n) {
				if(f[st.p][i] && !check[i]) {
					Q.push(state(i, st.d+1));
				}
			}
		}

		int ans = 0;
		REP(i, n) {
			ans += check[i];
		}

		cout << ans-1 << endl;
	}
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define ll long long

int main(){
  	ll n, q;
  	cin >> n >> q;
  	fenwick_tree<ll> bit(n);
  	for(int i = 0; i < n; i++){
      	ll a; cin >> a;
      	bit.add(i, a);
    } 	
    for(int i = 0; i < q; i++){
		ll t, a, b;
      	cin >> t >> a >> b;
      	if(!t)bit.add(a, b);
      	else cout << bit.sum(a, b) << endl;
    } 	
}

Measured memory_bytes: 8212
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long solve(long r, long c, long m, std::vector<std::vector<long> > field){
    std::vector<std::vector<std::vector<long> > > dp(r, std::vector<std::vector<long> >(c, std::vector<long>(5)));//when picked up k
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            for(int k = 0; k < 5; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    //printf("pass\n");
    dp[0][0][0] = 0;
    if(field[0][0] > 0){
        dp[0][0][1] = field[0][0];
    }
    /*
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            printf("(");
            for(int k = 0; k < 4; k++){
                printf("%2ld,", dp[i][j][k]);
            }
            printf("), ");
        }
        printf("\n");
    }
    printf("\n");
    //*/
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            if(i > 0){
                dp[i][j][0] = std::max(dp[i][j][0], dp[i-1][j][4]);
                dp[i][j][1] = std::max(dp[i][j][1], dp[i-1][j][4] + field[i][j]);
            }
            for(int k = 0; k < 4; k++){
                if(j > 0){
                    dp[i][j][k] = std::max(dp[i][j][k], dp[i][j-1][k]);
                    if(k > 0){
                        dp[i][j][k] = std::max(dp[i][j][k], dp[i][j-1][k-1] + field[i][j]);
                    }
                }
                dp[i][j][4] = std::max(dp[i][j][4], dp[i][j][k]);
            }
        }
    }
    /*
    (int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            printf("(");
            for(int k = 0; k < 5; k++){
                printf("%2ld,", dp[i][j][k]);
            }
            printf("), ");
        }
        printf("\n");
    }
    //*/
    long ans = 0;
    for(int k = 0; k < 4; k++){
        ans = std::max(ans, dp[r-1][c-1][k]);
    }
    return ans;
}

int main(){
    long r, c, k;
    scanf("%ld%ld%ld", &r, &c, &k);
    std::vector<std::vector<long> > field(r, std::vector<long>(c, 0));
    for(int i = 0; i < k; i++){
        long a, b, v;
        scanf("%ld%ld%ld", &a, &b, &v);
        field[a-1][b-1] = v;
    }

    printf("%ld\n", solve(r, c, k, field));
}


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

typedef long long ll;
typedef pair<ll,ll> ii;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
const int INF=2012345678;
const ll LLINF=4012345678012345678LL;
const ll MOD=1000000007;
const long double PI=3.1415926535;
const long double EPS=1e-9;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll expo(ll b,ll p,ll m){ll res=1; while(p){if(p&1)res=(res*b)%m; b=(b*b)%m; p>>=1;} return res;}
inline ll modinv(ll a,ll m){return expo(a,m-2,m);}


int main(){
	int k;
	char str[105];
	scanf("%d%s",&k,str);
	if(strlen(str)<=k)printf("%s",str);
	else{
		for(int i=0;i<k;i++)printf("%c",str[i]);
		printf("...");
	}
}


Measured memory_bytes: 3736
h, w = map(int, input().split())
maiz = []
edge = ['#'] * (w+2)
point = 0
for _ in range(h):
    line = list(input())
    line = ['#'] + line + ['#']
    point += len([i for i in line if i == '.'])
    maiz.append(line)
maiz = [edge] + maiz + [edge]

def bfs(maiz, h, w):
    queue = [[1, 1]]
    visited = [[False]*(w+2) for _ in range(h+2)]
    maiz[1][1] = 0
    while queue:
        x, y = queue.pop(0)
        visited[y][x] = True
        hjkl = [[x-1, y], [x, y-1], [x+1, y], [x, y+1]]
        for dx, dy in hjkl:
            if (maiz[dy][dx] == '.') and (visited[dy][dx] is False):
                queue.append([dx, dy])
                maiz[dy][dx] = maiz[y][x]+1
    tf = False if maiz[h][w] == '.' else True
    return maiz[h][w], tf

n, tf = bfs(maiz, h, w)
if tf is False:
    print(-1)
    exit()

print(point-n-1)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

struct Process{
  char name[100];
  int t;
};

struct Process Q[1001];
int n;
void enqueue(struct Process x){
  struct Process S;
  int i;
  S = x;
  for(i = 0 ; i < n ; i++){
    if(i == n-1){
      Q[i] = S;
    }
    else {
      Q[i] = Q[i+1];
    }
  }
}
struct Process dequeue(void){
  struct Process R;
  int i;
  R = Q[0];
  for(i = 0 ; i < n ; i++){
    if(i == n-1){
      n = n-1;
    }
    else {
      Q[i] = Q[i+1];
    }
  }
  return R;   
}

int main(){
  struct Process A;
  int i,q,time1=0,time2=0;
  scanf("%d %d",&n,&q);
  
  for(i = 0 ; i < n ; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }

  while(1){
    time1 = Q[0].t - q;
    if(time1 <= 0){
      time2 += Q[0].t;
      Q[0].t = time2;
      A = dequeue();
      printf("%s %d\n",A.name,A.t);
      if(n == 0) break;
      
    }
    else {
      Q[0].t = time1;
      enqueue(Q[0]);
      time2 += q;
    }
  }
  return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

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


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;




int main(){
  i64 a, b, n;

  while(cin >> a >> b >> n){

    auto f =
      [&](i64 x){
        return (a * x) / b - a * (x / b);
      };

    /*FORE(i,0,100){
      cerr << f(i) << " ";
    }cerr << endl;
    
    */

    i64 ans = f(min(b-1, n));

    pout(ans);    
  }
  
  return 0;
}


Measured memory_bytes: 3652
import math
def primeFactors(n):
    pri = []
    while n % 2 == 0:
        pri.append(2)
        n = n // 2
    for i in range(3, int(math.sqrt(n)) + 1, 2):
        while n % i == 0:
            pri.append(i)
            n = n // i
    if n > 2:
        pri.append(n)
    return pri
n = int(input())
if n==1:
    print(0)
    exit(0)
fact = set()
for i in range(2,int(n**0.5)+1):
    if n%i==0:
        fact.add(i)
        fact.add(n//i)
fact.add(n)
fact = sorted(fact)
cnt = 0
for i in fact:
    p = primeFactors(i)
    if p.count(p[0])==len(p):
        if n%i==0:
            n//=i
            # print(i, n)
            if n >= 1:
                cnt += 1
            else:
                break
print(cnt)

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


int main() {
    int n,x,y,ans[2000]={0};
    cin >> n >> x >> y;
    x--;
    y--;
    for(int begin=0;begin<n-1;begin++){
        for(int end = begin + 1; end < n; end++){
            if(begin <= x && y <= end){
                ans[end-begin-((y-x) - 1)]++;
            }else{
                int hoge = abs(x - begin) + abs(y - end) + 1;
                ans[min(end-begin,hoge)]++;
            }
        }
    }
    for(int i=1;i<n;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		//固定端を原点として，デカルト座標系における各針の先端の座標を計算．
		double Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360);
		double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360);

		double Bx = B * Math.sin(Math.PI * M / 30);
		double By = B * Math.cos(Math.PI * M / 30);

		double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By);
		double d = Math.sqrt(d_square);

		System.out.println(d);
	}
}


Measured memory_bytes: 35808
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        
        out.println(n * n * n);
        out.close();
        
    }
}

Measured memory_bytes: 32436
#include<iostream>
using namespace std;
int main()
{
    long long  x,y,z,ans ;
    cin>>x>>y>>z;
    if(x==0){
            ;
            ans=(y/z)+1;
             }
             else{
                  ans=(y/z)-(x-1)/z;
                  
                  
                  }
                  cout<<ans;
        return 0;
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 3e5 + 1, mod = 1e9 + 7;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

const int go[8][2] = {{2, 1}, {4, 3}, {6, 5}, {3, 3}, {7, 1}, {2, 1}, {2, 2}, {4, 4}};

char ss[N];
int f[N][8];

int main() {
	scanf("%s", ss + 1);
	reg n = strlen(ss + 1);
	f[0][0] = 1;
	fo(i, 1, n) fo(j, 0, 7) if(f[i - 1][j]){
		if(ss[i] != '0') f[i][go[j][1]] = (f[i][go[j][1]] + f[i - 1][j]) % mod;
		if(ss[i] != '1') f[i][go[j][0]] = (f[i][go[j][0]] + f[i - 1][j]) % mod;
	} pr2((f[n][1] + f[n][3]) % mod);
	return 0;
}



Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi, yi, q;
vector<ll>v;
set<int>s;
map<string, ll >mp;
bool PE ( int x )
{
    for ( int i = 2; i * i <= x; i++ )
        if ( x % i == 0 )
            return false;
    return true;
}
bool PR ( string s )
{
    int n = s.length();
    for ( int i = 0; i < n / 2; i++ )
        if ( s[i] != s[n - i - 1] )
            return false;
    return true;
}

int main ( void )
{ 
    int n;
    cin>>n;
    ll a[n];
    for (int i = 0 ;i < n;i++)
    cin>>a[i];
    
    sort (a,a+n);
    if (a[0]==0)cout<<0;
    else
    {
        t=1;
        const ll cop =(ll) 1e18;
        for (int i = 0 ;i < n;i++)
        
        {
            if (cop/t<a[i]){
            cout<<-1;
            return 0;}
            else 
            {
                t*=a[i];
            }
        }
        if (t>1e18)cout<<-1;
        else
        cout<<t;
    }
    
     
     
    
   
}


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

int dp[31];

int main() {
    dp[0] = 1;
    for (int i=1; i<31; ++i) {
        int sum = 0;
        for (int j=i-1; j>=i-3 && j>=0; --j) {
            sum += dp[j];
        }
        dp[i] = sum;
    }
    int n;
    while (cin >> n, n) {
        if (dp[n] % 3650 == 0) {
            cout << dp[n] / 3650 << endl;
        } else {
            cout << dp[n] / 3650 + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <map>

using namespace std;

int MOD = 1000000007;

int main(void){
  int N;
  cin >> N;
  //入力終わり

  //Nを素因数分解した結果を入れていく
  map<int, int> fact;

  //N！を考える
  for(int i=2; i<=N; i++){ //O(N)
    int n = i;
    //nを素因数分解し，素因数をfactに入れていく
    for(int j=2; j<=n; j++){ //nが素数の時が最悪でO(N)
      //jで割り切れれば，jを素因数に持つ
      if(n % j == 0){
	fact[j]++;
	//nを割っていけば計算量が減って嬉しい
	n /= j;
	//2から割り直すための処理
	//2(<- 例えば)で複数回割れる時に困るため
	j = 1;
      } //if
    } //j roop
  }

  //約数の個数の性質を使う
  long long ans = 1;
  for(auto m : fact)
    ans = (ans*(m.second+1) ) % MOD;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t;
    cin>>n>>t;
    int T=t+3002;
    int dp[T];
    memset(dp,0,sizeof(dp));
    vector<pair<int,int> > v;
    ll a,b;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.pb(make_pair(a,b));
    }
    sort(be(v));
    for(int i=0;i<n;i++){
        for(int j=t-1;j>=0;j--){
            dp[j+v[i].first]=max(dp[j]+v[i].second,dp[j+v[i].first]);
        }
    }
    int ans=0;
    for(int i=0;i<T;i++){
        ans=max(ans,dp[i]);
    }
    cout << ans<<endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int A, B, C; cin >> A >> B >> C;
  ll K; cin >> K; K %= 2;
  int result = (A-B) * pow(-1,K);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        StringBuilder builder = new StringBuilder();
        System.out.println(reader.readLine().toUpperCase());
    }
}

Measured memory_bytes: 16852
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    ans += A;
  }
  if (ans > N) {
    cout << "-1" << endl;
  }
  else {
    cout << N - ans << endl;
  }
}
    


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int maxn = 3e3 + 7;

LL a[maxn][maxn];
LL dp[maxn][maxn][4];

int main() {
    int n,m,k;
    sd(n),sd(m),sd(k);
    rep(i,1,k) {
        int u,v;
        LL w;
        sd(u),sd(v),slld(w);
        a[u][v] = w;
    }
    rep(i,1,n) {
        rep(j,1,m) {
            LL ans1 = 0;
            rep(k,0,3) {
                ans1 = max(ans1,dp[i-1][j][k]);
            }
            LL ans2 = 0;
            rep(k,0,2) {
                ans2 = max(ans2,dp[i][j-1][k]);
                // cout << "i = " << i << " j = " << j << " ans1 = " << ans1 << " ans2 = " << ans2 << endl;
                LL ans3 = max(dp[i][j][k+1],dp[i][j-1][k+1]);
                dp[i][j][k+1] = max(ans3, max(ans1,ans2) + a[i][j]);
            }
        }
    }
    // rep(i,1,n) {
    //     rep(j,1,m) {
    //         cout << "i = " << i << " j = " << j << endl;
    //         rep(k,0,3) {
    //             cout << dp[i][j][k] << " ";
    //         }
    //         cout << endl;
    //     }
    // }
    LL ans = max(dp[n][m][1],max(dp[n][m][2],dp[n][m][3]));
    plld(ans);
    return 0;
}

Measured memory_bytes: 356060
#include<bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
typedef long long int LL;
const int MAX = 1e5 + 1;
const int INF = 1e9;

int s[MAX], p[MAX];

int main() {
	memset(p, 0, sizeof p);
	memset(s, 0, sizeof s);	
	int n, m, x;
	string y;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		if (y == "AC")
			s[x] = 1;
		if (y == "WA" and !s[x])
			p[x]++;
	}
	int ansx = 0, ansy = 0;
	for (int i = 0; i <= n; i++) {
		if (s[i]) {
			ansx++;
			ansy += p[i];
		}
	}
	printf ("%d %d\n", ansx, ansy);
	return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ans = [0] * (m - 1) + [n * (n - 1) // 2]

root = [0] * (n + 1)
count = [1] * (n + 1)

def uf(a):
    if root[a] == 0:
        return a
    else:
        return uf(root[a])

for i in range(m - 1, 0, -1):
    ha = uf(ab[i][0])
    hb = uf(ab[i][1])
    if ha == hb:
        ans[i - 1] = ans[i]
        continue
    ans[i - 1] = max(0, ans[i] - count[ha] * count[hb])
    if count[ha] > count[hb]:
        root[hb] = ha
        count[ha] += count[hb]
    else:
        root[ha] = hb
        count[hb] += count[ha]
for i in ans:
    print(i)

Measured memory_bytes: 34160
import java.util.Scanner;

public class Main {

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

		while (sc.hasNextLine()) {
			String string = sc.nextLine();
			if (string.equals("")) {
				break;

			}
			String[] a = string.split(" ");
			int p = Integer.parseInt(a[0]);
			int q = Integer.parseInt(a[1]);

			int sum = p + q;

			System.out.println(String.valueOf(sum).length());
		}

	}

}

Measured memory_bytes: 26404
#include <stdio.h>
 
int main(void){
 
    int x, y, q, r;
    long long int a,b,z;
 
    while(scanf("%lld %lld", &a, &b)!=EOF){
 
    x = a;
    y = b;
 
    if(x < 0) x = -x;
    if(y < 0) y = -y;
    for(;;){
        q = x/y;
        r = x - q*y;
        if(r == 0) break;
        x = y;
        y = r;
    }
    z=a*b/y;
    printf("%d %lld\n",y,z);
    }
    return 0;
}


Measured memory_bytes: 1992
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;
int main() {
	stack<int> S;
	int a, b, x;
	string s;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}else if(s[0] == '-') {
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a - b);
		}else if (s[0] == '*') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		}else {
			S.push(atoi(s.c_str()));
		}
	}
	cout << S.top() << endl;
	return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<pii> p(n);
  rep(i, n) cin >> p[i].F >> p[i].S;

  sort(all(p));

  double sum = 0;

  do {
    rep(i, n - 1) sum += hypot(p[i + 1].F - p[i].F, p[i + 1].S - p[i].S);
  } while (next_permutation(all(p)));

  rep(i, n) sum /= (i + 1);

  printf("%.10f\n", sum);
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
	
    public static void main(String[] args) {
         
        Scanner cin=new Scanner(System.in);
        while(true) {
        	
        	int n=cin.nextInt();
        	if(n==0)break;
        	//else if(n==1)System.out.println(cin.next());
        	
        	int v[]=new int[26];
        	int winv=0,secv=0,time=0; char winner=0;
        	
        	List<Character> data=new ArrayList<>();
        	
        	for(int i=0;i<n;i++) {
        		String str=cin.next();
        		char t[]=str.toCharArray();
        		data.add(t[0]);
        	}
        	
        	for(int i=1;i<=n;i++) {
        		winv=0;secv=0;winner=0;
        		v[data.get(i-1)-65]++;
        		
        		//当確チェック
        		//1位のチェック
        		
        		for(int j=0;j<26;j++) {
        			if(v[j]>winv) {
        				winv=v[j];winner=(char)(j+65);
        			}
        		}
        		
        		//System.out.println("WINNER : "+winner);
        		
        		//2位のチェック
        		for(int j=0;j<26;j++) {
        			if(j==winner-65)continue;
        			if(v[j]>secv) secv=v[j];
        		}
        		
        		if(winv>secv+(n-i)) {
        			time=i;
        			break;
        		}
        	}
        	if(winv==secv)System.out.println("TIE");
        	else System.out.println(winner+" "+time);
        }
        
    }
}


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

  int lenOfSeq = 0,i = 0,term[100] = {};

  scanf("%d",&lenOfSeq);

  for(i = 0;i <= lenOfSeq - 1; i = i + 1){
    scanf(" %d",&term[i]);
  }

  for(i = lenOfSeq - 1; i >= 0; i = i - 1){
    printf("%d",term[i]);
    i != 0 ? printf(" "):printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
ll F[500005];
ll I[500005];
ll exp(ll a, ll x){
    if (x == 0) return 1ll;
    ll p = exp(a,x/2);
    p = (p*p)%mod;
    if (x&1) p = (p*a)%mod;
    return p;
}
ll P(int n, int k){
    return (F[n]*I[n-k])%mod;
}
ll C(int n, int k){
    return (((F[n]*I[k])%mod)*I[n-k])%mod;
}
ll ans = 0;
int n,m;
int main(){
    scanf("%d%d",&n,&m);
    F[0] = I[0] = 1;
    for (int i = 1; i <= 500000; i++){
        F[i] = (F[i-1]*i)%mod;
        I[i] = exp(F[i],mod-2);
    }
    for (int i = 0; i <= n; i++){
        ll EX = (P(n,i)*C(m,i))%mod;
        ll TR = P(m-i,n-i);
        TR = (TR*TR)%mod;
        //printf("%lld %lld\n",EX,TR);
        if (i & 1) ans -= (EX*TR)%mod;
        else ans += (EX*TR)%mod;
        ans %= mod;
    }
    ans = (ans+mod)%mod;
    printf("%lld",ans);

}


Measured memory_bytes: 11640
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    ll = MII()
    cnt = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                a = ll[i]
                b = ll[j]
                c = ll[k]
                if a == b or b == c or c == a:
                    continue
                if a + b > c and b + c > a and c + a > b:
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
    string str;
    cin>>str;
    if(str[2] == str[3] && str[4] == str[5])
    {
      cout<<"Yes"<<endl;
    }
    else
    {
      cout<<"No"<<endl;
    }

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
def ptbl():
    n_max = 55555
    arr = [True for _ in range(n_max + 1)]
    for i in range(2, n_max + 1):
        if arr[i]:
            j = i + i
            while j < (n_max + 1):
                arr[j] = False
                j += i
    res = []
    for i in range(2, n_max + 1):
        if arr[i]:
            res.append(i)
    return res

n = int(input())
ans = []
cnt = 0
for x in ptbl():
    if x % 10 == 1:
        ans.append(x)
        cnt += 1
        if cnt == n:
            break
print(' '.join(map(str, ans)))

Measured memory_bytes: 3736
def GCD(a, b):
    while(b):
        a, b = b, a % b
    return(a)

def LCM(a, b):
    return(a * b // GCD(a, b))

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    lcm = LCM(N, M)
    l = []
    if(N != lcm):
        for i in range(lcm // N):
            for j in range(N):
                l.append(A[j])
    else:
        l = A
    ans = 0
    for i in range(lcm // M):
        temp = []
        for j in range(M):
            temp.append(l[M * i + j])
        ans += max(temp) - min(temp)
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 13144
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int n, k;
    double p[200200], s[200200];
    cin >> n >> k;
    rep(i, n) {
        double x;
        cin >> x;
        p[i] = (1. + x) / 2.;
    }

    s[0] = 0.;
    rep(i, n) s[i + 1] = s[i] + p[i];

    double ans = 0;
    rep(i, n - k + 1) {
        chmax(ans, s[i + k ] - s[i]);
    }
    print(ans);

    return 0;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifdef local
	#include "debug/debug.h"
#endif


#ifndef local
	#define deb(x...) ;	
#endif

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

int H, W, M;


void solve()
{
	cin >> H >> W >> M;
	
	vi rct(H, 0), cct(W, 0);
	vii targets;
	int x, y;
	rep(i,0,M)
	{
		cin >> x >> y;
		x--; y--;
		targets.pb({x, y});
		rct[x]++;
		cct[y]++;
	}
	set<int> rows, cols;
	int maxR = *max_element(all(rct)), maxC = *max_element(all(cct));
	
	rep(i,0,H) if (rct[i] == maxR) rows.insert(i);
	rep(i,0,W) if (cct[i] == maxC) cols.insert(i);
	
	int ect = 0;
	for (pii target: targets)	
	{
		if (rows.find(target.ff) != rows.end() && cols.find(target.ss) != cols.end()) ect ++;
	}
	
	int ans = maxR + maxC - 1;
	if (ect < rows.size()*cols.size()) ans++;
	cout << ans << "\n";
	
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	// cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 40644
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a, n) for (int i = a; i < n; i++)
#define foj(a, n) for (int j = a; j < n; j++)
#define foin(a, n) for (int i = n; i >= a; i--)
#define fojn(a, n) for (int j = n; j >= a; j--)
#define isp2(x) x && (!(x & (x - 1)))
#define ee 1000000007
#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
#define cases                                                                  \
  long long t;                                                                 \
  cin >> t;                                                                    \
  while (t--)

using namespace std;

int main() {
  ll n;
  cin >> n;
  ll a[n];
  for (ll i = 0; i < n; ++i)
    cin >> a[i];
  ll sum = accumulate(a, a + n, 0);
  for (ll i = 0; i < n; ++i) {
    if (sum - a[i] <= a[i]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 3604
int main(int n)
{
	int c,p=0;
	char d;
	for(scanf("%d\n",&n);n--&&p>=0;)
	{
		scanf("%c %d\n",&d,&c);
		p+=d=='('?c:-c;
	}
	puts(p?"NO":"YES");
        exit(0);
}

Measured memory_bytes: 584
from collections import deque

N = int(input())
tree = [[] for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1; b -= 1
  tree[a].append(b); tree[b].append(a)

def calc_dist(node):
  dist = [-1] * N
  dist[node] = 0
  d = deque([[node, -1]])
  while d:
    node, p = d.pop()
    children = tree[node]
    for child in children:
      if child == p:
        continue
      dist[child] = dist[node] + 1
      d.append([child, node])
  return dist

d1 = calc_dist(0)
dN = calc_dist(N-1)

fennec = snuke = 0
for node in range(1, N-1):
  if d1[node] <= dN[node]:
    fennec += 1
  else:
    snuke += 1

if fennec > snuke:
  print('Fennec')
else:
  print('Snuke')

Measured memory_bytes: 29336
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String ss = sc.next();
		
		int ans = 0;
		Stack stack = new Stack();
		
		for(int i = 0;i < ss.length();i++){
			if(stack.isEmpty()){
				stack.push(ss.charAt(i));
			}else{
				if(stack.peak() != ss.charAt(i)){			//01 or 10 なら削除
					ans += 2;
					stack.pop();
				}else{								//追加
					stack.push(ss.charAt(i));
				}
				
			}
		}
		System.out.println(ans);
		
	}
	
	
}


class Stack{
	int data[];
	int top;
	private	int max =100000000;

	Stack(){
		data = new int[max];
	}
	Stack(int size){
		top =0;
		max = size;
		try{
			data = new int[max];
		}catch(OutOfMemoryError e){
			max = 0;   
		}
	}

	void push(int x)throws RuntimeException{
		if(top >= max)
			throw new RuntimeException();
		data[top] = x;
		top++;
		return ;
	}

	int pop() throws RuntimeException{
		if(top<=0){
			throw new RuntimeException();

		}return data[--top];

	}

	boolean isEmpty(){
		if(top == 0){
			return	true;
		}else{
			return	false;
		}

	}

	int peak(){
		top--;					//pushの時は次の配列にいってるので戻す
		return data[top++];		
	}

}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,k,x,y;cin>>n>>k>>x>>y;
  if(n<=k)cout<<n*x<<endl;
  else cout<<k*x+(n-k)*y<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>

using namespace std;

int main(){
	int N;
  	cin >> N;
  	vector<double> v(N);
  	for(int i = 0; i < N; i++){
    	cin >> v[i];
    }
  	sort(v.begin(), v.end());
  	double res;
  
  	for(int i = 0; i < N-1; i++){
    	v[i+1] = (v[i] + v[i+1])/2;
    }
  
  	cout << v[N-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  string s;
  cin >> s;
  bool flag = 1;
  if(s[0] != 'A') flag = 0;

  int cnt = 0;
  for(int i = 2; i <= s.size()-2; i++)
    if(s[i] == 'C') cnt++;

  if(cnt != 1) flag = 0;

  int cnt2 = 0;
  for(int i = 0; i < s.size(); i++) 
    if(s[i] != tolower(s[i])) cnt2++;
  
  if(cnt2 != 2) flag = 0;

  if(flag)
    cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n, w;
  cin >> n >> w;

  vector<int> weight(n), value(n);
  REP(i, n) cin >> weight[i] >> value[i];

  int vMax = n * 1000;
  vector<vector<ll>> dp(n+1, vector<ll>(vMax+1, INF));
  dp[0][0] = 0;
  REP(i, n){
    REP(j, vMax+1){
      chmin(dp[i+1][j], dp[i][j]);
      if(j+value[i] > vMax) continue; 
      chmin(dp[i+1][j+value[i]], dp[i][j] + weight[i]);
    }
  }
  int ans = 0;
  REP(i, vMax+1){
    if(dp[n][i] <= w) chmax(ans, i);
  }
  cout << ans << endl;
  return 0;
}

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

struct Item {
	int v;
	int w;
	long double frac;
};

bool fracGreater(const Item& item1, const Item& item2) { return item1.frac > item2.frac; }

int main()
{
	int N, W; std::cin >> N >> W;
	
	Item* items = new Item[N];
	for (int i=0; i<N; i++) {
		std::cin >> items[i].v >> items[i].w;
		items[i].frac = (double)items[i].v / items[i].w;
	}

	std::sort(items, items + N, fracGreater);
	//std::sort(items, items + N);
	
	long double max_value = 0;
	int total_weight = 0;
	for (int i=0; i<N; i++) {
		if (total_weight + items[i].w > W) {
			max_value += (long double)items[i].v * (W - total_weight) / items[i].w;
			break;
		} else {
			max_value += items[i].v;
			total_weight += items[i].w;
		}
	}
	std::cout << std::fixed << max_value << std::endl;
	
	return 0;
}



Measured memory_bytes: 6320
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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

signed main() {
	
	string s;

	cin >> s;

	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A;
  int B;
  cin >> A >> B;
  if(A>=13){
    cout << B;
  }
  else if(A<=5){
	cout << 0;
  }
  else{
    cout << B/2;
  }
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int h,w;
    
    while(cin>>h>>w){
    if(h==0&&w==0)return 0;
    vector<vector<char>> v(h,vector<char>(w));
    vector<vector<bool>> f(h,vector<bool>(w,false));
    
    rep(i,0,h){
        rep(j,0,w){
            cin>>v[i][j];
        }
    }
    int x=0,y=0;
    
    while(!f[y][x]){
        
        f[y][x]=true;
        if(v[y][x]=='>')x++;
        else if(v[y][x]=='<')x--;
        else if(v[y][x]=='v')y++;
        else if(v[y][x]=='^')y--;
        else if(v[y][x]=='.'){
            cout<<x<<" "<<y<<endl;
            goto AWAY;
        }
        
        
    }
    if(f[y][x])cout<<"LOOP"<<endl;
    AWAY:;
    v.clear();
    f.clear();
    }
    
    return 0;
}




Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct pos{
    int x;
    int y;
};
int main(){
    int N;
    vector<pair<pos, bool>> R, B;
    cin >> N;
    R.resize(N);
    B.resize(N);

    for (int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        pos p = {a, b};
        R[i] = make_pair(p, false);
    }
    for (int i = 0; i < N; i++)
    {
        int c, d;
        cin >> c >> d;
        pos p = {c, d};
        B[i] = make_pair(p, false);
    }
    sort(B.begin(), B.end(), [](const pair<pos, bool> &m, const pair<pos, bool> &n) { return m.first.x < n.first.x; });
    sort(R.begin(), R.end(), [](const pair<pos, bool> &m, const pair<pos, bool> &n) { return m.first.y > n.first.y; });

    int count = 0;
    for (int i = 0; i < N; i++){
        pos b = B[i].first;
        for (int j = 0; j < N; j++){
            if((R[j].first.y < b.y) && (R[j].first.x < b.x) && !R[j].second){
                count++;
                R[j].second = true;
                break;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

ll pow(ll x,ll y){
  if(y==0){
    return 1;
  }else if(y==1){
    return x%MOD;
  }else if(y%2==0){
    return pow(x,y/2)*pow(x,y/2)%MOD;
  }else{
    return pow(x,y-1)*x%MOD;
  }
}
int main(){
  ll H,W,A,B;cin >> H >> W >> A >> B;
  vector<ll> fact(H+W);
  vector<ll> factINV(H+W);
  fact[0]=1;factINV[0]=1;
  for(ll i=1;i<H+W;i++){
    fact[i] = fact[i-1]*i % MOD;
    factINV[i] = pow(fact[i],MOD-2);
  }
  ll ans = 0;
  for(ll i=1;i+B<=W;i++){
    ll x = fact[H-A+B-2+i]*fact[W+A-B-1-i]%MOD;
    x = x*factINV[W-B-i]%MOD*factINV[B-1+i]%MOD;
    ans = (ans+x)%MOD;
  }
  ans = ans *factINV[H-A-1]%MOD*factINV[A-1]%MOD;
  cout << ans << endl;
}


Measured memory_bytes: 6408
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,M;
    map<int,int> T;
    cin >> N;
    for(int i = 0;i < N;i++){
        int t;
        cin >> t;
        T[t]++;
    }
    cin >> M;
    vector<int> D(M);
    for(int i = 0;i < M;i++){
        cin >> D[i];
    }
    for(int i = 0;i < M;i++){
        if(T[D[i]] > 0){
            T[D[i]]--;
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

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

	int number = 0;

	for (int i = 0; i <= C; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= A; k++) {
				if (500*k + 100*j + 50*i == X) {
					number++;
				}
			}
		}
	}

	cout << number << endl;

	return 0;
}

Measured memory_bytes: 256