akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    ll x;
    cin >> x;
    ll cur = 100;
    for (int i = 1; i < 4000; i++) {
        cur *= 1.01;
        if (cur >= x) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3600
s = input()
t = input()

n = [0]*(len(s) - len(t) + 1)

for i in range(len(s) - len(t) + 1):
  for j in range(len(t)):
    if t[j] == s[i+j]:
      n[i] += 1

print(len(t) - max(n))

Measured memory_bytes: 72912
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;

ld dp[2][3005];

ld Ans;
int N;

int main() {
	ios::sync_with_stdio(false);

	cin >> N; dp[0][0] = 1;
	for(int i = 1; i <= N; i++) {
		ld p; cin >> p;
		for(int j = 0; j < i; j++) {
			dp[1][j] += dp[0][j] * (-p + 1);
			dp[1][j+1] += dp[0][j] * p;
		}
		for(int j = 0; j <= i; j++) {
			dp[0][j] = dp[1][j];
			dp[1][j] = 0;
		}
	}

	for(int i = N/2+1; i <= N; i++)
		Ans += dp[0][i];
	
	printf("%.20Lf\n", Ans);
	return 0;
}

Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
m=max(a)
aset=set()
dp=[0]*(m+1)
for i in a:
  dp[i]=1
for i in sorted(a):
  if dp[i]!=0:
    for j in range(1,m//i):
      dp[i*(j+1)]=0
for i in a:
  if i in aset:
    dp[i]=0
  else:
    aset.add(i)
print(sum(dp))

Measured memory_bytes: 139224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define MAXN 100010
int par[MAXN], sz[MAXN];
void init(int n) {
  rep(i,n)
  {
    par[i] = i;
    sz[i] = 1;
  }
}
int find(int x) {
  if (par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;
  if (sz[x] > sz[y]){
    par[y] = x;
    sz[x]+=sz[y];
  }else {
    par[x] = y;
    sz[y]+=sz[x];
  }
}
bool same(int x, int y) {
  return find(x) == find(y);
}
int treesize(int x) {
  return sz[find(x)];
}
int main() {
  int n, m, k, a, b;
  cin>>n>>m>>k;
  int block[n + 1] = { };
  init(n + 1);
  rep(i,m)
  {
    cin>>a>>b;
      unite(a, b);
    block[a]++;
    block[b]++;
  }
  rep(i,k)
  {
    cin>>a>>b;
    if (same(a, b)) {
      block[a]++;
      block[b]++;
    }
  }
  rep(i,n)
    cout << treesize(i + 1) - block[i + 1] - 1 << " ";
}


Measured memory_bytes: 2048
from itertools import product

def main():
    N, A, B, C = map(int, input().split())
    L = list(int(input()) for _ in range(N))
    ans = 0
    # A => 0
    # B => 1
    # C => 2
    ans = float('inf')
    for item in product(range(4), repeat=N):
        length_A = 0
        cnt_A = 0
        score_A = 0
        length_B = 0
        cnt_B = 0
        score_B = 0
        length_C = 0
        cnt_C = 0
        score_C = 0
        for i,j in enumerate(item):
            if j == 0:
                length_A += L[i]
                cnt_A += 1
            if j == 1:
                length_B += L[i]
                cnt_B += 1
            if j == 2:
                length_C += L[i]
                cnt_C += 1
        if cnt_A == 0 or cnt_B == 0 or cnt_C == 0:
            continue
        score_A += abs(A - length_A) + 10 * (cnt_A - 1)
        score_B += abs(B - length_B) + 10 * (cnt_B - 1)
        score_C += abs(C - length_C) + 10 * (cnt_C - 1)
        ans = min(ans, score_A + score_B + score_C)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 74288
s = gets.to_i
def dfs(n, upper, ans)
	return if n > upper
	ans.push(n) if n.to_s.include?('3') && n.to_s.include?('5') && n.to_s.include?('7')
	dfs(n*10+3, upper, ans)
	dfs(n*10+5, upper, ans)
	dfs(n*10+7, upper, ans)
end
ans=[]
dfs(0,s,ans)
puts ans.count

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

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

	vector<vector<int>>hune(N);
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		hune[a].push_back(b);
	}

	bool flag = false;

	for (int i = 0; i < hune[0].size(); i++) {
		for (int j = 0; j < hune[hune[0][i]].size(); j++) {
			if (hune[hune[0][i]][j] == N - 1)flag = true;
		}
	}

	cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}



Measured memory_bytes: 8576
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

H, N = MAP()
A, B = [0]*N, [0]*N
for i in range(N):
	A[i], B[i] = MAP()


dp = [[INF]*(H+1) for _ in range(N+1)]
dp[0][0] = 0


for i in range(N):
	for j in range(H+1):
		if j < A[i]:
			dp[i+1][j] = min(dp[i][j], B[i])
		else:
			dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i])

#for i in range(0, N+1):
#	print(dp[i])

print(dp[N][H])

Measured memory_bytes: 290268
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r,d,x,ans[10];cin>>r>>d>>x;
    ans[0]=r*x-d;;
    for (size_t i = 1; i < 10; i++) {
        ans[i]=r*ans[i-1]-d;
    }
    for (size_t i = 0; i < 10; i++) {
        std::cout << ans[i] << '\n';
    }
}


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

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
	     int W = sc.nextInt();
	     int H = sc.nextInt();
	     int x = sc.nextInt();
	     int y = sc.nextInt();
	     int r = sc.nextInt();
	     
	     if((x-r>=0&&x+r<=W)&&(y-r>=0&&y+r<=H)){
	    	 System.out.println("Yes");
	     }
	     else{
	    	 System.out.println("No");
	     }
	    
	}

}



Measured memory_bytes: 26344
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    if(a * c + b * d == a * e + b * f){
        cout << "infinity" << endl;
        return 0;
    }
    if(c == e){
        cout << "infinity" << endl;
        return 0;
    }

    ll ans = 0;

    if(a * c + b * d < a * e + b * f){
        swap(c,e);
        swap(d,f);
    }

    // A の方が速い.

    if(c > e){
        cout << '0' << endl;
        return 0;
    }

    ll diff = a * c + b * d - a * e - b * f;
    ll ma = a * e - a * c;

    if(ma % diff == 0){
        ans = ma / diff * 2 - 1 + 1;
    }else{
        ans = ma / diff * 2 + 1;
    }


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


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

int main(int argc, char **argv) {
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif

  int n, k; cin >> n >> k;
  vector<int> a;
  string s; cin >> s;

  char cur = '?';
  int cnt = 0;
  for(char c : s) {
    if(cur == '?') { cur = c; cnt = 1; }
    else if(cur == c) { cnt++; }
    else {
      a.push_back(cnt);
      cur = c;
      cnt = 1;
    }
  }

  if(cnt) a.push_back(cnt);

  int res = 0;
  int g = a.size();
  for(int x : a) res += x - 1;

  while(k > 0 && g > 1) {
    if(g >= 3) {
      g -= 2;
      res+=2;
    }
    else {
      g -= 1;
      res++;
    }
    k--;
  }

  cout << res << endl;

  return 0;
}

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

int n,x,d,t,ans;

int lg(int x) {
	if (x==1) return 0;
	return lg(x>>1)+1;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&x);
		int c=lg(x); d=0;
		if (x!=1<<c) d=1;
		if (t>c) t=c,d=0;
		if (t<c) ans+=c-t,t=c;
		if (d) ans++,t++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

main() {
    string S; cin >> S;
    bool can1=false,can2=false;
    rep(i,S.size()){
        if(!can1){
            if(S[i]=='C') can1=true;
        }
        else {
            if(S[i]=='F') can2=true;
        }
    }
    if(can2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=40003;
const ll INF=1LL<<63;
int num[4];
int expr(string S,int &i);
int number(string S,int &i);

int expr(string S,int &i){
    int res=0;
    if(S[i]=='['){
        i++;
        char c=S[i];
        i++;
        
        res=expr(S,i);
        if(c=='+'){
            res|=expr(S,i);
        }else if(c=='*'){
            res&=expr(S,i);
        }else{
            res^=expr(S,i);
        }
        
        i++;
        
    }else{
        res=number(S,i);
        i++;
    }
    
    return res;
}

int number(string S,int &i){
    return num[S[i]-'a'];
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        string S,T;cin>>S>>T;
        if(S==".") break;
        vector<int> cnt(100);
        int ans;
        for(char a='0';a<='9';a++){
            for(char b='0';b<='9';b++){
                for(char c='0';c<='9';c++){
                    for(char d='0';d<='9';d++){
                        string U;
                        U+=a;
                        U+=b;
                        U+=c;
                        U+=d;
                        num[0]=a-'0';
                        num[1]=b-'0';
                        num[2]=c-'0';
                        num[3]=d-'0';
                        int i=0;
                        int x=expr(S,i);
                        
                        cnt[x]++;
                        
                        if(T==U) ans=x;
                    }
                }
            }
        }
        
        cout<<ans<<" "<<cnt[ans]<<endl;
    }
}




Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
ll n, ans;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  ans = n*(n+1)*(n+2)/6;
  FOR(_, 1, n){
    ll a, b;
    cin >> a >> b;
    if(a>b) swap(a, b);
    ans -= a*(n-b+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
h,w,k = map(int, input().split())
board = [list(map(lambda x: int(x=="#"), input())) for i in range(h)]

ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        nboard = [board[i][:] for i in range(h)]
        for x in range(h):
            if i & (1<<x):
                for z in range(w):
                    nboard[x][z] = 0
        for y in range(w):
            if j & (1<<y):
                for z in range(h):
                    nboard[z][y] = 0
        if sum(sum(x) for x in nboard) == k:
            ans += 1
print(ans)

Measured memory_bytes: 69068
function main(input) {
    input = input.split(' ').map(Number);
    var N = input[0];
    var A = input[1];
    var B = input[2];
    if(N * A <= B){
        console.log(N*A);
    } else {
        console.log(B);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, x;
VL a;

signed main() {
    cin >> N >> x;
    ll tmp = 0, ans = 0;
    REP(i, N) {
        a.emplace_back(IN());
        tmp += a[i];
        if(tmp > x) {
            ans += tmp - x;
            a[i] -= tmp - x;
            tmp -= tmp - x;
        }
        if(i > 0) tmp -= a[i - 1];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1400
function getLcs(strX, strY) {
    const sizeX = strX.length;
    const sizeY = strY.length;
    strX = ' ' + strX;
    strY = ' ' + strY;

    const com = [];
    for (let i = 0; i <= sizeX; i++) {
        for (let ji = 0; ji <= sizeY; ji++) {
            if(!com[i]) com[i] = [];
            com[i][ji] = 0;
        }
    }

    for (let i = 1; i <= sizeX; i++) {
        for (let ji = 1; ji <= sizeY; ji++) {

            if (strX[i] === strY[ji]) {
                com[i][ji] = com[i - 1][ji - 1] + 1;
            } else if (com[i - 1][ji] >= com[i][ji - 1]) {
                com[i][ji] = com[i - 1][ji];
            } else {
                com[i][ji] = com[i][ji - 1];
            }
        }
    }
    return com[sizeX][sizeY];
}


function main(_stdin) {
    const stdin = _stdin.split('\n');
    let q = parseInt(stdin.shift(), 10);

    while (q) {
        console.log(getLcs(stdin.shift(), stdin.shift()));
        q--;
    }
}


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



Measured memory_bytes: 112804
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long A, B, C, D;
	cin >> A >> B >> C >> D;

	long long area1 = A * B;
	long long area2 = C * D;

	if (area1 > area2)
	{
		cout << area1;
	}
	else
	{
		cout << area2;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);

        int[][][] log = new int[4][3][10];
        for(int i = 0; i < n; i++) {
          line = sc.nextLine();
          String[] l = line.split(" ");

          int b = Integer.parseInt(l[0]) - 1;
          int f = Integer.parseInt(l[1]) - 1;
          int r = Integer.parseInt(l[2]) - 1;
          int v = Integer.parseInt(l[3]);

          log[b][f][r] += v;
        }

        for(int b = 0; b < 4; b++) {
          for(int f = 0; f < 3; f++) {
            for(int r = 0; r < 10; r++) {
              System.out.print(" " + log[b][f][r]);
            }
            System.out.println();
          }
          if(b != 3) {
            System.out.println("####################");
          }
        }
    }
}

Measured memory_bytes: 27012
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)



string d[2]={{".#.#"},{"..##"}};

int main(){
	int n;
	cin>>n;
	
	
	string ans[2]={"",""};
	bool left = false;
	while(1){
		bool f=false;
		rep(i,4){
			if(left==false)	cout<< ans[0]+d[0][i] <<'\n'<< ans[1]+d[1][i] <<endl;
			else			cout<< d[0][i]+ans[0] <<'\n'<< d[1][i]+ans[1] <<endl;
			string res;
			cin>>res;
			if(res=="end")return 0;
			if(res=="T"){
				if(left==false){
					ans[0] += d[0][i];
					ans[1] += d[1][i];
				}
				else{
					ans[0] = d[0][i]+ans[0];
					ans[1] = d[1][i]+ans[1];
				}
				
				f=true;
				break;
			}
		}
		if(f==false)left=true;
	}
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var targetChars = new Char[] { 'A','T','C','G' };
            var maxLenght = 0;
            var matchCnt = 0;
 
            var inputChars = input.ToCharArray();
            for (var i=0;i<inputChars.Length;i++)
            {
                var isMatch = false;
                // ATCGのうちどれかと合っているか確認
                foreach (var targetChar in targetChars)
                {
                    if (inputChars[i] == targetChar)
                    {
                        isMatch = true;
                        break;
                    }
                }
 
                if (isMatch)
                {
                    matchCnt++;
                    if(matchCnt > 0 && matchCnt > maxLenght)
                    maxLenght = matchCnt;
                }
                else
                {
                    matchCnt = 0;
                }
 
            }
 
            Console.WriteLine(maxLenght);
        }
    }
 
}

Measured memory_bytes: 13140
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF 999999999
unsigned int dp[2][10010][2]; //0 : A, 1 : B
int t[10010];
int main(void){
  int n;
  for(int i = 0;i <= 10000; i++)
    dp[0][i][0] = dp[0][i][1] = dp[1][i][0] = dp[1][i][1] = INF;

  scanf("%d", &n);
  for(int i = 0;i < n - 1; i++) scanf("%d", t + i);

  for(int i = 0;i < n; i++){
    for(int j = 0;j <= n / 2; j++)
      dp[(i+1) % 2][j][0] = dp[(i+1) % 2][j][1] = INF;

    dp[i % 2][i][0] = t[i];
    for(int j = 0;j <= n / 2; j++){
      if(dp[i % 2][j][0] != INF){
        dp[(i+1) % 2][j][1] = min(dp[(i+1) % 2][j][1], dp[i % 2][j][0] + t[i]);
        dp[(i+1) % 2][j + 1][0] = min(dp[(i+1) % 2][j + 1][0], dp[i % 2][j][0] - t[i - 1] + t[i]);
      }
      if(dp[i % 2][j][1] != INF){
        dp[(i+1) % 2][j][1] = min(dp[(i+1) % 2][j][1], dp[i % 2][j][1] - t[i - 1] + t[i]);
        dp[(i+1) % 2][j + 1][0] = min(dp[(i+1) % 2][j + 1][0], dp[i % 2][j][1] + t[i]);
      }
    }
  }
  
  printf("%d\n", min(dp[0][n/2-1][0], dp[0][n/2-1][1]));
}


Measured memory_bytes: 1220
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int dp[1001][1000];
int a[1001][1000];
int ainv[1001][1001];
signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    cin.tie(0);
    cout.tie(0);
    // cin>>TESTS;
    while(TESTS--)
    {   
        int n;
        cin>>n;
        rep(i,1,n+1){
        	rep(j,1,n) cin>>a[i][j];
        }
        int cur[n+1];
        rep(i,1,n+1) cur[i] = 1;
        int ans=0;
       	while(1){
       		int cnt = 0;
       		ans++;
       		bool mark[n+1]={};
       		rep(i,1,n+1){
       			if(cur[i]==n||mark[i]) continue;
       			if(a[a[i][cur[i]]][cur[a[i][cur[i]]]] == i && mark[a[i][cur[i]]] ==0){
       				cnt++;
       				mark[i] = 1;
       				mark[a[i][cur[i]]] = 1;
       				// trace(i,a[i][cur[i]],ans);
       				cur[a[i][cur[i]]]++;
       				cur[i]++;
       			}
       		}
       		if(cnt==0){
       			bool yes = 1;
       			rep(i,1,n+1) if(cur[i]!=n) yes = 0;
       			if(yes==0) cout<<-1;
       			else{
       				cout<<ans-1;
       			}
       			r0;
       		}
       	}
    }   
}     


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

int main() {
  int x,n;cin>>x>>n;
  vector<int>d(102);
  rep(i,n){
    int p;cin>>p;
    d[p]=1;
  }
  int a,ans=1e9;
  rep(i,102){
    if(d[i]==0){
      if(abs(x-i)<ans){
        ans=abs(x-i);
        a=i;
      }
    }
  }
  cout<<a<<endl;
}

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

int main() {
	vector<int>A(5);
	int sum = 0;
	int memo = 10;
	for (int n = 0;n<5;++n) {
		cin >> A[n];
		if (0 == A[n]%10) {
			sum += A[n];
		}
		else {
			sum += (A[n] / 10 + 1) * 10;
		}
		if (0 != A[n]%10) {
			memo = min(memo, A[n] % 10);
		}
	}	
	if (10!= memo) {
		sum -= (10 - memo);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3588
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
//#define int long long
#define MAX_N (100001)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	deque<char> d;
	for (auto a : s) {
		d.push_back(a);
	}
	int q; cin >> q;
	bool isre = false;
	rep(i, q) {
		int t; cin >> t;
		if (t == 1) isre = !isre;
		else {
			int f; cin >> f;
			char s2; cin >> s2;
			if ((!isre && f == 1) || (isre && f == 2)) d.push_front(s2);
			else d.push_back(s2);
		}
	}
	if (isre) {
		while (!d.empty()) {
			cout << d.back();
			d.pop_back();
		}
	}else {
		while (!d.empty()) {
			cout << d.front();
			d.pop_front();
		}
	}
	cout << endl;
}

Measured memory_bytes: 976
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
 
using namespace std;
 
#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a) for (int i = 0; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "
 
const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;
 
const int mxn = 300;
 
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int n;
    cin >> n;
 
    vi a(n);
    in(a);
 
    vi dp(n, 0);
    dp[0] = 0;
 
    for (int j = 1; j < n; ++j) {
        dp[j] = min(dp[j - 1] + abs(a[j - 1] - a[j]), (j > 1 ? dp[j - 2] + abs(a[j - 2] - a[j]) : INF));
    }
 
    cout << dp[n - 1];
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){

        IOS;
        int n, m;
        cin >> n >> m;
        if(m == 1)
         { cout << 0 << endl;return 0; }
        int j=n, ans = 1;
        while(j < m){
             j = (j+n)-1;
             ans++;
        }
        cout << ans << endl;

        
    return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
card=[0]*(n+1)
for _ in range(m):
    l,r=map(int,input().split())
    card[l-1]+=1
    card[r]-=1
for i in range(1,n+1):
    card[i]+=card[i-1]
print(card.count(m))

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

int main() {
	while (1) {
		int M, N; cin >> M >> N;
		if (!M)break;
		vector<bool>oks(7368793);
		int used = 0;
		int ans = -1;
		for (int i = M; i < 1e7; ++i) {
			if (!oks[i]) {
				if (used == N) {
					ans = i;
					break;
				}
				for (int j = i; j < 7368793; j += i) {
					oks[j] = true;
				}
				used++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(int argc, char const *argv[]) {
    int k;
    cin >> k;

    vector<int> a(1000001);
    a[1] = 7;
    for (int i = 2; i <= k; i++) a[i] = (a[i-1] * 10 + 7) % k;

    for (int i = 1; i <= k; i++) {
        if (a[i] % k == 0) {
            cout << i << endl;
            return 0;
        }
    }

    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 7224
def cmb(n, r):
    if n < r:
        return 0 # <-直した
    if r > n - r:
        return cmb(n, n - r)
    if r == 0:
        return 1
    if r == 1:
        return n
    res = f[n]
    res *= invs[r]
    res %= MOD
    res *= invs[n - r]
    res %= MOD
    return res


MOD = 10 ** 9 + 7

N, K = map(int, input().split())

f = [-1] * (N * 2 + 1)
f[0] = 1
t = 1
for i in range(1, N * 2 + 1):
    t *= i
    t %= MOD
    f[i] = t

inv = pow(t, MOD - 2, MOD)
invs = [-1] * (N * 2 + 1)
invs[N * 2] = inv
for i in range(N * 2 - 1, 0, -1):
    inv *= (i + 1) # <-直した
    inv %= MOD
    invs[i] = inv

print(N - K + 1)
for i in range(2, K + 1):
    print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % MOD)


Measured memory_bytes: 43376
import sys
input = sys.stdin.readline
import heapq
from operator import itemgetter

def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    h = []
    for v in A:
        heapq.heappush(h, v)

    BC = []
    for _ in range(M):
        BC.append([int(x) for x in input().split()])

    BC_sorted = sorted(BC, key=itemgetter(1), reverse=True)

    is_end = False
    for i in range(M):
        for _ in range(BC_sorted[i][0]):
            x = heapq.heappop(h)
            if BC_sorted[i][1] > x:
                heapq.heappush(h, BC_sorted[i][1])
            else:
                heapq.heappush(h, x)
                is_end = True
                break

        if is_end:
            break

    print(sum(h))



if __name__ == '__main__':
    main()



Measured memory_bytes: 28708
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextInt();
    long power = 1;
    for(int a=1;a<=N;a++){
      power = (power*a)%1000000007;
    }
    System.out.println(power);
  }
}

Measured memory_bytes: 23508
#include <stdio.h>
#include <stdlib.h>
int puz[3][3];
int tmp[3][3];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
void empty(int *x,int *y) {
  int i,j;
  for(i=0; i<3; i++) {
    for(j=0; j<3; j++) {
      if(!puz[i][j]) {
	*x = j;
	*y = i;
	return;
      }
    }
  }
}
void swap(int *a,int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}   
int cal(){
  int i,a,sum=0; 
  for(i=0; i<9; i++){
    a = puz[i/3][i%3];
    if(a){
      a--;
      sum += abs(i/3 - a/3) + abs(i%3 - a%3);
    }
  }    
  return sum;
}
int dfs(int x,int y,int p,int dep,const int lim){
  int i,h,nx,ny,res;   
  h = cal();
  if(h==0) return dep;
  if(dep+h>lim) return -1; 
  for(i=0; i<4; i++){
    nx = x+dx[i];
    ny = y+dy[i];      
    if(~p && i==(p+2)%4) continue;
    if(!(0<=nx && nx<3 && 0<=ny && ny<3)) continue;    
    swap(&puz[y][x],&puz[ny][nx]);
    res = dfs(nx,ny,i,dep+1,lim);
    if(~res) return res;       
    swap(&puz[y][x],&puz[ny][nx]);
  }   
  return -1;
}    
int main() {
  int i,j,ans,x,y,l;
       
  for(i=0; i<3; i++){
    for(j=0; j<3; j++) scanf("%d",&puz[i][j]);
  }
        
  empty(&x,&y);
  for(l=0; l<100; l++){
    for(i=0; i<3; i++){
      for(j=0; j<3; j++) tmp[i][j] = puz[i][j];
    }
           
    ans = dfs(x,y,-1,0,l);
    if(ans!=-1){
      printf("%d\n",ans);
      break;
    }
           
    for(i=0; i<3; i++){
      for(j=0; j<3; j++) puz[i][j] = tmp[i][j];
    }
           
    ans = -1;
    if(l==99) printf("%d\n",ans);
  }
       
  return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

int main()
{
  int n, m, c, i, j;
  cin >> n >> m >> c;
  int b[m], a[n][m];

  for(i=0; i<m; i++){
    cin >> b[i];
  }

  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      cin >> a[i][j];
    }
  }

  int sum =0, count =0;
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      sum += a[i][j] * b[j];
    }
    if(sum+c > 0) count++;
    sum = 0;
  }

  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='o')
            count++;
    }
    cout<<count*100+700<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = input().split()

R = 0
G = 0
B = 0

Z = 1

for aa in A:
    a = int(aa)
    x = 0
    if a == R and a == G and a == B:
        x = x + 3
        R = R + 1
    elif a == R and a == G:
        x = x + 2
        R = R + 1
    elif a == R and a == B:
        x = x + 2
        R = R + 1
    elif a == G and a == B:
        x = x + 2
        G = G + 1
    elif a == R:
        x = x + 1
        R = R + 1
    elif a == B:
        x = x + 1
        B = B + 1
    elif a == G:
        x = x + 1
        G = G + 1
    Z = Z * x % 1000000007

print(Z)

Measured memory_bytes: 10644
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    x.pb(X);
    sort(All(x));
    vector<int> dif;
    rep(i, N) dif.pb(x[i + 1] - x[i]);
    int res = dif[0];
    rep(i, N) { res = gcd(res, dif[i]); }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int32_t main(){
	#ifndef ONLINE_JUDGE
    	// for getting input from input.txt
    	freopen("input.txt", "r", stdin);
    	// for writing output to output.txt
    	freopen("output.txt", "w", stdout);
    	// for debug in error.txt
    	freopen("error.txt", "w", stderr);
	#endif
	int t =1;
	while(t--) {
		ll n, k;
		cin >> n >> k;
		std::vector<ll> v(n);
		for(int i = 0; i < n; i++) {
			cin >> v[i];
		}
		for(int i = k; i < n; i++) {
			if(v[i] > v[i-k]) {
				cout << "Yes" << '\n';
			}else{
				cout << "No" << '\n';
			}
		}
	}
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    string temp = t.substr(0,s.length());
    if(temp==s){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n=s.size()-2;

    int ans = inf;
    rep(i,n){
        int x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        ans = min(ans,abs(x-753));
    }
    cout << ans << endl;

        return 0;
    }

Measured memory_bytes: 3576
import java.util.Scanner;

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int N = scanner.nextInt();
    int sr = scanner.nextInt();
    int sc = scanner.nextInt();
    char[] S = scanner.next().toCharArray();
    char[] T = scanner.next().toCharArray();
    if (possible(H, W, N, sr, sc, S, T)) {
      System.out.println("NO");
    } else {
      System.out.println("YES");
    }
  }

  private static boolean possible(int H, int W, int N, int sr, int sc, char[] S, char[] T) {
    int[] count = new int[4];
    for (int i = 0; i < N; i++) {
      switch (S[i]) {
        case 'U':
          count[0]++;
          break;
        case 'R':
          count[1]++;
          break;
        case 'D':
          count[2]++;
          break;
        case 'L':
          count[3]++;
          break;
      }
      if (sr - count[0] <= 0) return true;
      if (sr + count[2] > H) return true;
      if (sc - count[3] <= 0) return true;
      if (sc + count[1] > W) return true;
      switch (T[i]) {
        case 'U':
          if (sr + count[2] > 1) count[2]--;
          break;
        case 'R':
          if (sc - count[3] < W) count[3]--;
          break;
        case 'D':
          if (sr - count[0] < H) count[0]--;
          break;
        case 'L':
          if (sc + count[1] > 1) count[1]--;
          break;
      }
    }
    return false;
  }
}


Measured memory_bytes: 29808
/*************************************
>>> Author:  xiaofan
>>> Blog:    https://xiaofan7.cn
>>> Date:    2020-01-07 22:32:01
**************************************/

#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int INF = 0x3f3f3f3f;

inline int read () {
	register int s = 0, w = 1;
	register char ch = getchar ();
	while (! isdigit (ch)) {if (ch == '-') w = -1; ch = getchar ();}
	while (isdigit (ch)) {s = (s << 3) + (s << 1) + (ch ^ 48); ch = getchar ();}
	return s * w;
}




int main() {
	IOS;
	//freopen("D:\\in.txt","r",stdin);
	//freopen("D:\\out2.txt","w",stdout);
	int n;
	cin>>n;
	if(n%2==0)
		cout<<n/2*n/2<<endl;
	else
		cout<<n/2*(n+1)/2<<endl;




	return 0;
}



Measured memory_bytes: 256
import java.awt.geom.Point2D.Double;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      Point2D p0, p1, p2;
      String[] line = br.readLine().split(" ");
      int q = parseInt(br.readLine());
      p1 = new Point2D(parseInt(line[0]), parseInt(line[1]));
      p2 = new Point2D(parseInt(line[2]), parseInt(line[3]));

      Vector v = new Vector();
      StringBuilder buf = new StringBuilder();
      for(int i=0; i<q; i++) {
        line = br.readLine().split(" ");
        p0 = new Point2D(parseInt(line[0]), parseInt(line[1]));
        buf.append(v.reflect(p1, p2, p0)).append("\n");
      }

      System.out.print(buf);

    }
    catch( IOException e ) {
      System.out.println(e);
    }
  }
  private class Point2D extends Double {
    private static final long serialVersionUID = 1L;
    double EPS = 1e-10;

    public Point2D() { super(); }
    public Point2D(double x, double y) { super(x, y); }

    public boolean equals (double a, double b) {
      return Math.abs(a-b) < EPS;
    }
    public Point2D sum(Point2D b) {
      return new Point2D(x+b.x, y+b.y);
    }
    public Point2D diff(Point2D b) {
      return new Point2D(x-b.x, y-b.y);
    }
    public Point2D multiple(double k) {
      return new Point2D(x*k, y*k);
    }

    @Override
    public String toString() {
      return String.format("%.10f %.10f", x,y);
    }
  }

  private class Vector extends Point2D {

    private static final long serialVersionUID = 1L;

    public Vector() { super(); }
    public Vector(double x, double y) { super(x, y); }
    public Vector(Point2D p) { super(p.x, p.y); }

    public double norm() {
      return x * x + y * y;
    }
    public double dot(Point2D a, Point2D b) {
      return a.x * b.x + a.y * b.y;
    }
    public double cross(Point2D a, Point2D b) {
      return a.x * b.y - a.y * b.x;
    }
    public boolean isOrthogonal(Point2D a, Point2D b) {
      return equals(dot(a,b) , 0.0);
    }
    public boolean isOrthogonal(Point2D a1, Point2D a2, Point2D b1, Point2D b2) {
      return isOrthogonal(a1.diff(a2), b1.diff(b2));
    }
    public boolean isParallel(Point2D a, Point2D b) {
      return equals(cross(a, b), 0.0);
    }
    public boolean isParallel(Point2D a1, Point2D a2, Point2D b1, Point2D b2) {
      return isParallel(a1.diff(a2), b1.diff(b2));
    }

    public Point2D project(Point2D sp1, Point2D sp2, Point2D p) {
      Vector base = new Vector( sp2.diff(sp1) );
      double r = dot(p.diff(sp1), base) / base.norm();

      return sp1.sum(base.multiple(r));
    }
    public Point2D reflect(Point2D sp1, Point2D sp2, Point2D p) {
      return p.sum(project(sp1,sp2,p).diff(p).multiple(2.0));
    }
  }
}


Measured memory_bytes: 36200
#include <stdio.h>

int main(void) {
	int W,H,x,y,r,i;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	i=0;
	if(H<(y+r))i=1;
	if(W<(x+r))i=1;
	if(0>(y-r))i=1;
	if(0>(x-r))i=1;
	if(i==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 2104
def main():
    H = int(input())
    div = {2**i for i in range(40)}
    ans = 0
    from math import log2, ceil
    if not(H in div):
        for h in range(int(log2(H)) + 1):
            ans += 2**h
        print(ans)
    else:
        for h in range(int(log2(H)) + 1):
            ans += 2**h
        print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll h,w,k; cin>>h>>w>>k;
    vector<string> s(h);
    rep(i,h) cin>>s[i];

    ll ans=0;

    rep(is,1<<h)rep(js,1<<w){
        ll cnt=0;
        rep(i,h)rep(j,w){
            if(is & 1<<i) continue;
            if(js & 1<<j) continue;
            if(s[i][j]=='#') ++cnt;
        }
        if(cnt==k) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  double ans = (double)(n/2)/n;
  ans = 1-ans;
  cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
import itertools
L=[N-i for i in range(N,0,-1) for j in range(i)]
a=[0]*N
stop=[i for i in range(N)]
dict=[chr(ord('a')+i) for i in range(N)]
def content(a):
  ans=''
  for i in a:
    ans+=dict[i]
  return ans
print(content(a))
def saiki(a,p):
  nowp=N-1
  nowv=max(a)+1
  x=a[:]
  #print('a',p,nowp)
  while nowp>p:
    #print('b',p,nowp)
    if nowp==N-1:
      for X in range(nowv+1):
        a[nowp]=X
        print(content(a))
        #a=saiki(a,nowp)
    else:
      for X in range(1,nowv+1):
        a[nowp]=X
        a=saiki(a,nowp)
    a[nowp]=0
    nowp-=1
  return x
P=N-1
if N>1:
  a[-1]+=1
  print(content(a))
while P>0:
  a=saiki(a,P)
  P-=1
  a=[0]*N
  a[P]=1
  

Measured memory_bytes: 4460
#include <bits/stdc++.h> 
using namespace std;
#define llu long long unsigned 
int main() 
{  
    int n1,n2;
  	cin>>n1>>n2;
  	if(n1==1 && n2==2)
      cout<<"3";
  	else if(n1==1 && n2==3)
      cout<<"2";
  	else if(n1==2 && n2==3)
      cout<<"1";
  else if(n1==2 && n2==1)
      cout<<"3";
  else if(n1==3 && n2==2)
      cout<<"1";
  else if(n1==3 && n2==1)
      cout<<"2";
    return 0; 
} 

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

int main()
{
    int n; cin>>n;
    double sum=0;
    for(int i=0;i<n;i++){
        double x;
        string u;
        cin>>x>>u;
        if(u=="JPY")sum+=x;
        else sum+=380000.0*x;
    }
    printf("%.10lf\n",sum);
    return 0;
}

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

int n, s;
int dp[120][10000];
int wi[105];
int vi[105];

int memo(int id, int rW){
	if(id == n || rW == 0) return 0;
	if(rW - wi[id] < 0) return memo(id+1,rW);
	if( dp[id][rW] != -1){return dp[id][rW];}
	else{
		dp[id][rW] = max( vi[id] + memo(id+1,rW-wi[id] ), max( vi[id] + memo(id,rW-wi[id]),memo(id+1,rW) ) );
	}
	return dp[id][rW];
}

int main(){
	cin.tie(0);
        ios_base::sync_with_stdio(0);
	cin>>n>>s;
	for(int i = 0; i<n;i++) cin>>vi[i]>>wi[i];
	for(int i = 0; i<=n+10;i++) for(int j = 0; j<=s+10; j++) dp[i][j] = -1;
	int ans = memo(0,s);
	cout<<ans<<"\n";
}



Measured memory_bytes: 8252
#include<iostream>
#define INF 1e9
using namespace std;
int main(){
  
  int N;
  cin >>N;
  int A[N];
  int dp[N+1];
  for(int i=0 ; i < N ; i++)cin >>A[i];
  for(int i=0 ; i < N+1 ; i++)dp[i]=INF;

  for(int i=0 ; i < N ; i++){
    *lower_bound(dp,dp+N+1,A[i])=A[i];
  }

  cout <<lower_bound(dp,dp+N+1,INF)-dp<<endl;
  
  return 0;
}

Measured memory_bytes: 1940
#include "stdio.h"
#include "string.h"
int main()
{
	char a[1000000];
	gets(a);
	int i=0,q=0;
	char r[1000000];
	for(i=0;a[i];i++)
		if(i%2==0)
			r[q++]=a[i];
	r[q]='\0';
	puts(r);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int n, m, p1, p2, p3;
vector< pair<int, int> > v[200002];
ll t[2 * OFF + 5];
ll p[2 * OFF + 5];

void prop(int x) {
	t[x*2] += p[x];
	t[x*2+1] += p[x];
	p[x*2] += p[x];
	p[x*2+1] += p[x];
	p[x] = 0;
}

void update(int a, int b, int l, int r, int x, ll kol) {
	if (r <= a || b <= l) return;
	if (a <= l && r <= b) {
		p[x] += kol;
		t[x] += kol;
		return;
	}
	
	prop(x);
	
	update(a, b, l, (l+r)/2, x*2, kol);
	update(a, b, (l+r)/2, r, x*2+1, kol);
	t[x] = min(t[x*2], t[x*2+1]);
}

ll query(int a, int b, int l, int r, int x) {
	if (r <= a || b <= l) return INF;
	if (a <= l && r <= b) return t[x];
	
	prop(x);
	
	return min(query(a, b, l, (l+r)/2, x*2), query(a, b, (l+r)/2, r, x*2+1));
}

int main () {

	cin >> n >> m;
	ll sol = 0, minus = 0;
	for (int i = 0; i < m; i++) {
		cin >> p1 >> p2 >> p3;
		v[p2].push_back({p1, p3});
		sol += p3;
	}
	
	for (int i = 1; i <= n+1; i++) {
		for (int j = 0; j < v[i-1].size(); j++) {
			update(0, v[i-1][j].X, 0, OFF, 1, v[i-1][j].Y);
		}
		
		ll tren = query(0, i, 0, OFF, 1);
		update(i, i+1, 0, OFF, 1, tren);
		minus = min(minus, tren);	
	}
	
	sol -= minus;
	cout << sol;

	return 0;
}

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

public class Main {
	
	static int n;
	static ArrayList<Integer>[] adjList;
	static int[] counter, value;
	static boolean[] vis;
	
	public static void dfs(int u, int c) {
		vis[u] = true;
		c += counter[u];
		value[u] = c;
		
		for(int v : adjList[u])
			if(!vis[v])
				dfs(v, c);
	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st;
		
		st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		int q = Integer.parseInt(st.nextToken());
		
		adjList = new ArrayList[n];
		for(int i = 0; i < n; i++)
			adjList[i] = new ArrayList<Integer>();
		
		for(int i = 0; i < n - 1; i++) {
			st = new StringTokenizer(br.readLine());
			int u = Integer.parseInt(st.nextToken()) - 1, v = Integer.parseInt(st.nextToken()) - 1;
			adjList[u].add(v);
			adjList[v].add(u);
		}
		
		counter = new int[n];
		for(int i = 0; i < q; i++) {
			st = new StringTokenizer(br.readLine());
			counter[Integer.parseInt(st.nextToken()) - 1] += Integer.parseInt(st.nextToken());
		}
		
		value = new int[n];
		vis = new boolean[n];
		dfs(0, 0);
		
		for(int i = 0; i < n; i++)
			pw.print(value[i] + (i == n - 1 ? "\n" : " "));
		
		pw.flush();
		pw.close();
	}
}


Measured memory_bytes: 129468