akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>


int main()
{
	int K, S;
	int count;
	int i, j, k;


	scanf("%d %d", &K, &S);
/*
	// これだと解けるが制限時間に間に合わない
	count = 0;
	for(i = 0; i <= K; i++){
		for(j = 0; j <= K; j++){
			for(k = 0; k <= K; k++){
				if(i + j + k == S)
					count++;
			}
		}
	}
*/

	count = 0;
	for(i = 0; i <= K; i++){
		for(j = 0; j <= K; j++){
			k = S - i - j;
			if(0 <= k && k <=K)
				count++;
		}
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
	public static void main(String[] args){
 		int n=0;
		String s;
		char m;
 		Scanner sc = new Scanner(System.in);
		s=sc.nextLine();
		for(n=0;n<s.length();n++){
		  m=s.charAt(n);
		  if(m>='A' && m<='Z')
		   System.out.print((char)(m+32));
		  else if(m>='a' && m<='z')
		   System.out.print((char)(m-32));
		  else
		   System.out.print(m);
		   }
		System.out.println();
		}
}


Measured memory_bytes: 26900
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, A, B; cin >> N >> A >> B;
  cout << N/(A+B)*A + min(N%(A+B),A) << endl;
}

Measured memory_bytes: 256
def match(data,sample,y,x)
    h = sample.length
    w = sample[0].length 
    return false if h+y > 8
    return false if w+x > 8
    for i in 0..h-1 do
        for j in 0..w-1 do
            return false if data[y+i][x+j]!=sample[i][j]
        end
    end
    true
end

while true
    data = Array.new
    for i in 0..8-1 do
        s = STDIN.gets.chomp
        data.push Array.new(8)
        for j in 0..8-1 do
            data[i][j] = s[j].to_i
        end
    end

    a = [[1,1], \
         [1,1]]
    b = [[1],\
         [1],\
         [1],\
         [1]] 
    c = [[1,1,1,1]]
    d = [[0,1],\
         [1,1],\
         [1,0]]
    e = [[1,1,0],\
         [0,1,1]]
    f = [[1,0],\
         [1,1],\
         [0,1]]
    g = [[0,1,1],\
         [1,1,0]]

    for i in 0..8-1 do
        for j in 0..8-1 do
            print "A\n" if match(data,a,i,j)
            print "B\n" if match(data,b,i,j)
            print "C\n" if match(data,c,i,j)
            print "D\n" if match(data,d,i,j)
            print "E\n" if match(data,e,i,j)
            print "F\n" if match(data,f,i,j)
            print "G\n" if match(data,g,i,j)
        end
    end


    exit 0 if not STDIN.gets
end

Measured memory_bytes: 6104
s=input()
kit=[]
for i in range(4):
  if not s[i] in kit:
    kit.append(s[i])
if len(kit)!=2:
  print('No')
else:
  counter=0
  for i in range(4):
    if kit[0]==s[i]:
      counter+=1
  if counter==2:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 38256
x, n = map(int, input().split())
p = set(map(int, input().split()))
INF = 10**10

dist = []
for i in range(102):
    if i in p:
        dist.append((i, INF))
    else:
        dist.append((i, abs(x - i)))

dist.sort(key=lambda x: x[1])
print(dist[0][0])


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

int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    string s;
    cin >> s;
    int cnt = 0;
    int ans;

    for(int i = 0; i < n-1; i++){
        if(s[i] != s[i+1]) cnt++;
    }
    while(k!=0){
        cnt -=2;
        k--;
        if(cnt <= 0) break; 
    }
    if(cnt <= 0) ans = n-1;
    else ans = n - cnt -1;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
    int n,m;cin >> n >> m ;

    int a[51],b[51],c[51],d[51],res[51];

    for(int i = 0 ; i < n ; i++){
        cin >> a[i] >> b[i] ;        
    }
    for(int i = 0 ; i < m ; i++){
        cin >> c[i] >> d[i] ;        
    }

    for(int i = 0 ; i < n ; i++){
        int x=a[i];
        int y=b[i];
                
        res[i]=1;
        int distance = abs(x-c[0])+abs(y-d[0]);
        for(int j = 1 ; j < m ; j++){
            int tmp_distance = abs(x-c[j])+abs(y-d[j]);

            if(distance>tmp_distance){
                distance=tmp_distance;
                res[i]=j+1;
            }
        }
    }

    for(int i = 0 ; i < n ; i++){
        p(res[i])
    }
}

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


#define int         long long
#define fast        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);


signed main()
{
    fast;
    int t = 1;
    //cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n;
        int a[n],s=0,h[n+1]={};
        for(int i=1;i<n;i++)
        {
            cin>>a[i];
            h[a[i]]++;
        }
        for(int i=1;i<=n;i++)
            cout<<h[i]<<'\n';
    }
	cerr << "\nTime elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}


Measured memory_bytes: 6932
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define INF 1e15
#define MOD 1000000007
int n, a[111];
vector<int>v, ans;
signed main() {
	cin >> n;
	rep(i, n) {
		int A;
		cin >> A;
		v.push_back(A);
	}
	rep(i, n) {
		for (int j = v.size() - 1; j >= 0; j--) {
			if (v[j] == j + 1) {
				ans.push_back(j + 1);
				v.erase(v.begin() + j);
				goto ok;
			}
		}
		puts("-1");
		return 0;
	ok:;
	}
	reverse(ans.begin(), ans.end());
	for (int i : ans)cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n;
    cin>>n;
    vector<vector<ll>> a(n,vector<ll>(3));
    for(auto &i:a){
        for(auto &t:i){cin>>t;}
    }
    vector<vector<ll>> dp(n+1,vector<ll>(3,0));
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int t=0;t<3;t++){
            for(int h=0;h<3;h++){
                if(t==h){continue;}
                dp[i+1][t]=max(dp[i+1][t],dp[i][h]+a[i][t]);
                ans=max(ans,dp[i+1][t]);
            }
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 11136
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(read())
x = np.arange(N + 1, dtype=np.int64)
x[::3] = 0
x[::5] = 0
print(x.sum())


Measured memory_bytes: 34424
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
using namespace std;

    const ll N = 1e2 + 7;
    const ll mod = 1e9 + 7;
    const ll inf = 1e9;



void solve(){
    string s , t;
    cin >> s >> t;
    t.pop_back();
    if(s == t){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

int main(){

ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


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

int main(){
	
	int x,y;
	int W,H,r;
	
	cin>>W>>H>>x>>y>>r;
	
	if(W<x||H<y||W<x+r||H<y+r||x<0||y<0||x-r<0||y-r<0)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	
}

Measured memory_bytes: 1156
from operator import itemgetter

w, h, n = map(int, input().split())
binary = [[0 for _ in range(h)] for i in range(w)]

for i in range(n):
    x,y,a = map(int, input().split())
    if a == 1:
        for j in range(x):
            for k in range(h):
                binary[j][k] += 1
    elif a == 2:
        for j in range(x,w):
            for k in range(h):
                binary[j][k] += 1
    elif a == 3:
        for j in range(w):
            for k in range(y):
                binary[j][k] += 1
    elif a == 4:
        for j in range(w):
            for k in range(y,h):
                binary[j][k] += 1

total = 0
for i in range(len(binary)):
    total += binary[i].count(0) 
print(total)

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

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  if (A <= X && X <= A + B) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char a;
  int i,c[27]={0};
  while(scanf("%c",&a)!=EOF){
    if(a>=65&&a<=90){
      c[a-65]++;
    }
    if(a>=97&&a<=122){
      c[a-97]++;
    }
  }
  for(i=0;i<26;i++){
    printf("%c : %d\n",i+97,c[i]);
  }
}

Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int N ;
  cin >> N ;
  double a[N] ;
  for(int i =0 ; i < N ;i++) 
    cin >> a[i] ;
  double s =0 ;
  for(int i=0 ; i < N;i++) 
    s+=(1.0/a[i]) ;
  	s = (1.0/s) ;
  printf("%.12f",s);
 return 0 ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  long long x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d>=k)cout<<x-k*d;
    else {
      k-=x/d;
      if(k%2)cout<<d-x%d;
      else cout<<x%d;
    }
  return 0;
}


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

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

        for(int i = 0; i < line.length(); i++){
            char a = line.charAt(i);

            for(int j = 0; j < 3; j++){
                if(a == 'A'){
                    a = 'Z';
                }else{
                    a = (char)(a-1);
                }
            }

            System.out.print(a);
        }
        
        System.out.println();
    }

}

Measured memory_bytes: 24968
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] a = new int[100002];
        for (int i = 0; i < 100002; i++) {
            a[i] = 0;
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if(a[temp] == 0){
                ans += 1;
                a[temp] = 1;
            }
        }
        System.out.println(ans -((N-ans)%2));
    }



//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        long N  = scanner.nextLong();
//        long amari = N % 11;
//        int ans = 0;
//        if(amari > 6)ans += 1;
//
//        System.out.println(2 * (N / 11) + ans + 1);
//    }







}




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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

#define INF 1300500000

ll dp[2][256];
ll sample[20010];


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

  while (1) {
    int N, M, code[16];
    cin >> N >> M;
    if (N == 0 && M == 0) break;
    REP(i, M) cin >> code[i];
    REP(i, N) cin >> sample[i];

    fill(dp[0], dp[0]+256, INF);
    dp[0][128] = 0;

    REP(i, N) {
      fill(dp[(i+1)%2], dp[(i+1)%2]+256, INF);
      REP(j, 256) {
	REP(k, M) {
	  int next = max(0, min(255, j + code[k]));
	  ll diff = sample[i] - next;
	  dp[(i+1)%2][next] = min(dp[(i+1)%2][next], dp[i%2][j] + diff * diff);
	}
      }
    }
    ll ans = INF;
    REP(i, 256) ans = min(ans, dp[N%2][i]);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1360
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

const int N=300+3;
const int p=1e9+7;

int C[N][N],F[N][N],G[N][N],pw[N][N],iv[N][N];
int n,m,res;

int Pow(int a,int b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p) if (b&1) res=1ll*res*a%p;
	return res;
}

int main(){
	For(i,0,N){
		C[i][0]=1;
		For(j,1,i+1) C[i][j]=(C[i-1][j-1]+C[i-1][j])%p;
	}
	For(i,0,N) For(j,0,N){
		pw[i][j]=Pow(i,j);
		iv[i][j]=Pow(pw[i][j],p-2);
	}
	n=IN(),m=IN();
	For(b,0,m+1){
		For(a,1,n+1){
			F[a][b]=pw[a][b];
			For(i,1,a){
				F[a][b]=(F[a][b]-1ll*G[a][i]*pw[a-i][b]%p+p)%p;
			}
			For(i,a+1,n+1){
				G[i][a]=(G[i][a]+1ll*C[i-1][a-1]*iv[i-a][b]%p*F[a][b])%p;
			}
		}
	}
	printf("%d\n",F[n][m]);
}

Measured memory_bytes: 2048
from math import sin, cos, pi

A, B, H, M = map(int, input().split())

r1 = 2 * pi * (60 * H + M) / (12 * 60)
x1, y1 = A * cos(r1), A * sin(r1)

r2 = 2 * pi * M / 60
x2, y2 = B * cos(r2), B * sin(r2)

diff = (x1 - x2) ** 2 + (y1 - y2) ** 2
print(diff ** 0.5)

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

using namespace std;

int p, q, r, a, b, c, maxx;
vector <int> v;

int main() {
    cin >> p >> q >> r;
    a = p + q;
    b = q + r;
    c = r + p;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    cout << v[0];
}

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

/* constant */

const double PI = acos(-1);
const double PI2 = PI * 2;

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt v) const { return x * v.x + y * v.y; }
  T cross(Pt v) const { return x * v.y - y * v.x; }
  Pt<T> mid(const Pt pt) { return Pt<T>((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt<T> rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt<T>(c * x - s * y, s * x + c * y);
  }

  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }

  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
  void print() { print("%.6lf"); }
};

typedef Pt<double> pt;

struct CL {
  pt p;
  double t0, t1;
  void print() {
    printf("CL:(%.6lf,%.6lf), t0=%.6lf, t1=%.6lf\n", p.x, p.y, t0, t1);
  }
};

/* global variables */

/* subroutines */

bool cross_lines(const pt& a0, const pt& da, const pt& b0, const pt& db,
                 CL& cl) {
  double op01 = da.cross(db);
  if (op01 == 0.0) return false; /* need to handle parallel?? */

  pt v = b0 - a0;
  double op0 = v.cross(da);
  double op1 = v.cross(db);

  cl.t0 = op1 / op01;
  cl.t1 = op0 / op01;
  cl.p = db * cl.t1 + b0;

  return (cl.t0 >= 0.0 && cl.t1 >= 0.0 && cl.t1 <= 1.0);
}

/* main */

int main() {
  double r = (double)1.0 / sqrt(3);
  double d30 = PI / 6;

  pt a0(0, 0);
  pt b0(r, 0), db(-cos(d30), sin(d30));
  
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    if (n % 3 == 0) n /= 3;
    double ar, th;
    
    if (n == 1)
      ar = pt(1, 0).cross(pt(cos(PI / 3), sin(PI / 3))) / 2;
    else {
      int n3 = n * 3;
      th = PI / n3;
    
      pt da(cos(th), sin(th));
      CL cl;

      cross_lines(a0, da, b0, db, cl);
      //cl.print();
      ar = b0.cross(cl.p) * n3;
    }

    printf("%.6lf\n", ar);
  }

  return 0;
}

Measured memory_bytes: 1188
#include <iostream>


int main() {
  char string[1200];
  int ascii_code;

  std::cin.getline(string, sizeof(string));

  for (int i = 0; string[i] != '\0'; i ++) {
    ascii_code = (int)string[i];
    if (65 <= ascii_code && ascii_code <= 90) {
      ascii_code += 32;
    } else if (97 <= ascii_code && ascii_code <= 122) {
      ascii_code -= 32;
    }
    std::cout << (char)ascii_code;
  }

  std::cout  << std::endl;

  return 0;
}



Measured memory_bytes: 2964
S=input()
K=int(input())

try:
    if S[0:K] =='1'*K:
        print(1)
    else:
        S=list(S)
        print([i for i in S if i  != '1'][0])
except:
    if S[0:100] =='1'*100:
        print(1)
    else:
        S=list(S)
        print([i for i in S if i  != '1'][0])

Measured memory_bytes: 3060
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=1e5+5;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
int n;
char s[N];
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	scanf("%s",s+1);n=strlen(s+1);
	if(s[1]=='0'||s[n]=='1'){puts("-1");return 0;}
	for(int i=2;i<n;i++)if(s[i]=='1'&&s[n-i]!='1'){puts("-1");return 0;}
	int rt=1;
	for(int i=2;i<=n;i++){printf("%d %d\n",rt,i);if(s[i-1]=='1')rt=i;}
	return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll modularExponentiation(ll x,ll n,ll M){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
ll binaryExponentiation(ll x,ll n){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return binaryExponentiation(x*x,n/2);
    else
        return x*binaryExponentiation(x*x,(n-1)/2);
}
ll GCD(ll A, ll B){
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll modPrimeInverse(ll A,ll M){
    return modularExponentiation(A,M-2,M);
}
int main(){

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

    ll n;
    cin >> n;
    ll ans = (n / 500)*1000;
    n = n % 500;
    ans += (n/5)*5;
    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{
int a,b,c,d,sum,sum1;
scanf("%d%d%d%d",&a,&b,&c,&d);
sum=a+b;
sum1=c+d;
if(sum>sum1)
    printf("Left");
else if(sum<sum1)
    printf("Right");
else
    printf("Balanced");

return 0;

}


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

int main() {
  int n;
  cin >> n;
  vector<int> a;
  int pre = 0, now;
  for (int i = 0; i < n; i++) {
    cin >> now;
    if (pre != now) a.push_back(now);
    pre = now;
  }
  if (a.size() == 1) {
    cout << 1000 << endl;
    return 0;
  } else if (a.size() == 2) {
    if (a[0] >= a[1]) {
      cout << 1000 << endl;
    } else {
      cout << 1000 + (1000 / a[0]) * (a[1] - a[0]) << endl;
    }
    return 0;
  }
  vector<int> a2;
  if (a[0] < a[1]) a2.push_back(a[0]);
  for (int i = 1; i < (int)a.size() - 1; i++) {
    if (a[i] > a[i - 1] && a[i] > a[i + 1]) a2.push_back(a[i]);
    else if (a[i] < a[i - 1] && a[i] < a[i + 1]) a2.push_back(a[i]);
  }
  if (a2.size() % 2 == 1) a2.push_back(a[a.size() - 1]);
  long long ans = 1000;
  for (int i = 0; i < (int)a2.size(); i += 2) {
    ans += (ans / a2[i]) * (a2[i + 1] - a2[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
s=input()
# アルファベット(a〜z)→数値(1〜26)小文字限定
a2n = lambda c: ord(c) - ord('a') + 1
# 数値(1〜26)→アルファベット(a〜z)
n2a = lambda c: chr(c+64).lower()

if len(s)<26:
  for i in range(1,27):
    if n2a(i) not in s:
      print(s+n2a(i))
      exit()
f=False
for i in range(1,26):
  if a2n(s[-i-1])>a2n(s[-i]):
    continue
  else:
    f=True
    break
if f==False:
  print(-1)
  exit()

ans=s[:-i-1]
mini=min([a2n(d) for d in s[-i:] if a2n(d)>a2n(s[-i-1])])
ans+=str(n2a(mini))
print(ans)


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

int main(){
	int n , k ,q;
	cin >> n >> k >> q;
	int a[n + 1] ;
	int neg = 0;
	for(int i = 1 ; i <= n ;i++) a[i] = k;
	for(int i = 1 ; i <= q ;i++){
		int x;
		cin >> x; 
		a[x]+= 1;
		neg++;
	}
	
	for(int i = 1 ; i <= n ;i++){
		cout << (a[i] - neg  <= 0 ? "No\n" : "Yes\n"); 
	}
	return 0;
}

Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        s: chars,
        t: chars,
    }

   let ss: String = s.into_iter().collect();
   let ts: String = t.into_iter().collect();
   
   println!("{}", [ts,ss].concat());
}

Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
    return 0;
}


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

int main(){
  int n, ans = 0;
  cin >> n;
  
  vector<int> a(n);
  
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  int i = 0, cnt = 0;
  while(i < n - 1){
    if(a[i] >= a[i + 1]){
      cnt++;
    }
    else{
      cnt = 0;
      i++;
      continue;
    }
    ans = max(ans, cnt);
    i++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
       int n, count=0;
       cin >> n;
       
       for(int i=0; i < n; i++) {
           for(int j=0; j < n; j++) {
               for(int k=0; k < n; k++) {
                    count++;   
               }
           }
       }
       cout << count << endl;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
result=0
for p in range(0,max(x)+1):
  s=0
  for i in range(0,n):
    s+=(x[i]-p)**2
  if p==0:
    result=s
  else:
    if s<result:
      result=s
print(result)

Measured memory_bytes: 3060
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func reva(b []int) {
	for i := 0; i < len(b)/2; i++ {
		b[i], b[len(b)-1-i] = b[len(b)-1-i], b[i]
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt(sc)
	}
	q := nextInt(sc)
	for i := 0; i < q; i++ {
		b := nextInt(sc)
		e := nextInt(sc)
		reva(a[b:e])
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		if i > 0 {
			fmt.Fprint(wtr, " ")
		}
		fmt.Fprint(wtr, a[i])
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}



Measured memory_bytes: 1136
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
	int n, i, j, k;
	long long a[1001];
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			//if (i == j) continue;
			for (k = j + 1; k < n; k++) {
				//if (j == k || i == k) continue;
				if (i < j && j < k && k < n&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]) {
					long long b[3];
					b[0] = a[i], b[1] = a[j], b[2] = a[k];
					sort(b, b + 3);
					if (b[0] + b[1] > b[2]) {
						ans++;
					}
				}

			}
		}
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 3188
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
ans = 10 ** 9 + 7
for i in range(N - K + 1):
    left = A[i]
    right = A[i + K - 1]
    if right < 0:  temp = -left
    elif left >= 0:  temp = right
    else:  temp = right - left + min(-left, right)
    ans = min(ans, temp)
print(ans)

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	string n; cin >> n;
	cout << (n[0] == n[2] ? "Yes\n": "No\n");
}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'A' or s[i] == 'G' or s[i] == 'C' or s[i] == 'T'){
            cnt++;
        }
        else{
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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


int main() {
  int N;
  cin >> N;
  
  if(N%10==3){
    cout << "bon" <<endl;
  }
  else if(N%10 ==0){
    cout << "pon" <<endl;
  }
  else if(N%10 ==1){
    cout << "pon" <<endl;
  }
  else if(N%10 ==6){
    cout << "pon" <<endl;
  }
  else if(N%10 ==8){
    cout << "pon" <<endl;
  }
  else{
    cout << "hon" <<endl;
  }
}

Measured memory_bytes: 3636
A, B, C, X, Y = map(int, input().split())
ans = A * X + B * Y
M = max(X, Y)
N = min(X, Y)
if A + B > C * 2:
    ans -= N * (A + B) - 2 * C * N
    if A > 2 * C and X > Y:
        ans = 2 * C * X
    elif B > 2 * C and X < Y:
        ans = 2 * C * Y
print(ans)


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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(),a.end());
  if(sum%10==0) {
    rep(i,n) {
      if(a[i]%10!=0) {
        sum -= a[i];
        break;
      }
      if(i==n-1) sum = 0;
    }
  }

  cout << sum << endl;
}


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

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n;
  string s,t;
  cin >> n >> s;
  t = s.substr(0,n / 2);
  if (s == t + t){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def main(n,ki,uv):
  # n: 頂点数
  # ki: 木
  # Euler Tour の構築
  S=[] # Euler Tour
  F=[0]*n # F[v]:vにはじめて訪れるステップ
  depth=[0]*n # 0を根としたときの深さ
  def dfs(v,pare,d):
    F[v]=len(S)
    depth[v]=d
    S.append(v)
    for i,w in ki[v]:
      if w==pare:continue
      dfs(w,v,d+1)
      S.append(v)
  dfs(0,-1,0)
  # Sをセグメント木に乗せる
  # u,vのLCAを求める:S[F[u]:F[v]+1]のなかでdepthが最小の頂点を探せば良い
  # F[u]:uに初めてたどるつくステップ
  # S[F[u]:F[v]+1]:はじめてuにたどり着いてつぎにvにたどるつくまでに訪れる頂点
  # 存在しない範囲は深さが他よりも大きくなるようにする
  INF = (n, None)
  # LCAを計算するクエリの前計算
  M = 2*n
  M0 = 2**(M-1).bit_length() # M以上で最小の2のべき乗
  data = [INF]*(2*M0)
  for i, v in enumerate(S):
    data[M0-1+i] = (depth[v], i)
  for i in range(M0-2, -1, -1):
    data[i] = min(data[2*i+1], data[2*i+2])
  # LCAの計算 (generatorで最小値を求める)
  def _query(a, b):
    yield INF
    a += M0; b += M0
    while a < b:
      if b & 1:
        b -= 1
        yield data[b-1]
      if a & 1:
        yield data[a-1]
        a += 1
      a >>= 1; b >>= 1
  # LCAの計算 (外から呼び出す関数)
  def query(u, v):
    fu = F[u]; fv = F[v]
    if fu > fv:
      fu, fv = fv, fu
    return S[min(_query(fu, fv+1))[1]]
  
  todo=[[0,[]]]
  path=[[]]*n
  mi=[1]*n
  while todo:
    v,ary=todo.pop()
    path[v]=ary
    mi[v]=0
    for i,nv in ki[v]:
      if mi[nv]==1:
        todo.append([nv,ary+[i]])
        mi[nv]=1

  for i in range(n):
    path[i]=set(path[i])
  memo=[set(())]*m
  for c in range(m):
    u,v=uv[c]
    dd=query(u,v)
    tmp=path[u]|path[v]
    tmp-=path[dd]
    memo[c]=tmp

  ans=0
  for i in range(2**m):
    chk=set(())
    for j in range(m):
      if (i>>j)&1:
        chk.add(j)
    must_w=set(())
    for c in chk:
      tmp=memo[c]
      must_w|=tmp
    t=n-1-len(must_w)
    if len(chk)%2==1:
      ans-=pow(2,t)
    else:
      ans+=pow(2,t)
  print(ans)
if __name__=='__main__':
  n=int(input())
  ki=[[] for _ in range(n)]
  for i in range(n-1):
    u,v=map(int,input().split())
    u,v=u-1,v-1
    ki[u].append([i,v])
    ki[v].append([i,u])
  m=int(input())
  uv=[]
  for _ in range(m):
    u,v=map(int,input().split())
    u,v=u-1,v-1
    uv.append([u,v])
  main(n,ki,uv)


Measured memory_bytes: 74400
object Main {
  val sc = new java.util.Scanner(System.in)

  def sin(n: Int): Seq[Int] = Seq.fill(n)(sc.nextInt())

  def main(args: Array[String]): Unit = {
    val n = sc.nextInt()
    sc.nextLine()
    val s = sc.nextLine()
    val k = sc.nextInt()

    println(
      s.foldLeft("")((b: String, c: Char) => b + (if (c == s(k - 1)) c else '*'))
    )
  }
}

Measured memory_bytes: 25416
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int main()
{
	int t,n;
	ll ans;
	double x;
	cin>>t;
	if(t&1)
	{
		n=t/2+1;
		x=n*1.0/t;
	 } 
	 else
	 {
	 	n=t/2;
	 	x=n*1.0/t;
	 }
	printf("%.10lf",x);
	return 0;
 } 

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            Long d = Long.parseLong(in.next());
            long[] x = new long[n];
            long[] y = new long[n];
            for (int i = 0; i < n; i++) {
                x[i] = Long.parseLong(in.next());
                y[i] = Long.parseLong(in.next());
            }
            int ans = 0;
            double distance = 0;
            for (int i = 0; i < n; i++) {
                distance = Math.sqrt((x[i] * x[i]) + (y[i] * y[i]));
//            out.println(distance);
                if (distance <= (double) d) ans++;
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 63396
acute=0
right=0
obtuse=0

while True:
    a, b, c = map(int, input().split())
    e = sorted([a, b, c])
    a, b, c = (e[0], e[1], e[2])
    if a + b < c:
        break
    elif a**2 + b**2 > c**2:
        acute += 1
    elif a**2 + b**2 == c**2:
        right += 1
    else:
        obtuse += 1
print(acute+right+obtuse, right, acute, obtuse)


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

#define int long long 

using namespace std;

void solve()
{
	int n,t,k;
	cin >> n >> t >> k;
	if(n%t==0)
		cout << k*(n/t) << endl;
	else
		cout << k*(n/t+1) << endl;
}


int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	//int t;cin >> t;while(t--)
		solve();

	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);

typedef long long LL;

long long N, K;
vector<long long> A;

int ubound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] <= b){
			s = m;
		}
		else{
			e = m;
		}
	}
	if(v[max(s - 1, 0)] > b) return max(s - 1, 0);
	else if(v[s] > b) return s;
	else if(v[min(s + 1, l - 1)] > b) return min(s + 1, l - 1);
	else return v.size();
}

LL GCD(LL x, LL y){
        LL r=0;
	if( x<y ) swap(x, y);
        r = x % y;
        while(r!=0){
                x = y;
                y = r;
                r = x % y;
        }
        return y;
}

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

	cin >> N >> K;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());

	if(N == 1){
		if(K == A[0]){
			printf("POSSIBLE\n");
		}
		else{
			printf("IMPOSSIBLE\n");
		}
		return 0;
	}

	if(K > A[A.size()-1]){
		printf("IMPOSSIBLE\n");
		return 0;
	}
	if(A[0] == 1){
		printf("POSSIBLE\n");
		return 0;
	}
	int pos = ubound(A, K);
	if(pos > 0 && A[pos-1] == K){
		printf("POSSIBLE\n");
		return 0;
	}

	LL d = GCD(A[0], A[1]);
	for(int i=2; i<A.size(); i++){
		d = GCD(d, A[i]);
	}
	if((K % d) == 0){
		printf("POSSIBLE\n");
	}
	else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}


Measured memory_bytes: 4168
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void)
{
	int n, *A, sousa, num, len = 0;

	cin >> n;
	A = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> sousa;
		if (sousa == 1 || sousa == 0) cin >> num;
		if (sousa == 0) A[len++] = num;
		else if (sousa == 1) cout << A[num] << endl;
		else A[--len] == NULL;
	}
	return 0;
}


Measured memory_bytes: 3800
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long ans = 0;
        for (long i = 1; i < 1000000001; i++)
        {
            long tmp = i * i;
            if (tmp > n)
            {
                Console.WriteLine(ans);
                break;
            }
            ans = tmp;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//オーバーフローに注意 long long　にする
//'1'+=16;      で大文字Aに
//'大文字'+=32;  で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


 
int main() {
 
  int n;
  cin >> n;
  
  vector<long double> p(n);
  
  long double ans = 0;
  
  rep(i,n) {
    cin >> p[i];
    string s;
    cin >> s;
    if(s=="JPY") ans+=p[i]*1.0;
    else ans+=p[i]*380000.0;
  }
  
  cout << fixed << setprecision (20); 
  cout << (long double)ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    int  N,W;
    cin>>N>>W;
    int w[N];
    int v[N];
    for(int i=0;i<N;i++)
      cin>>w[i]>>v[i];

    ll dp[2][W+1];
    for(int i=0;i<2;i++)
      for(int j=0;j<=W;j++)
        dp[i][j] = 0;
    bool turn = 1;
    for(ll i=0;i<N;i++)
    {
      for(ll wt=0;wt<=W;wt++)
      {
        dp[turn][wt] = dp[1-turn][wt];
        if(wt-w[i]>=0)
          dp[turn][wt] = max(dp[1-turn][wt],v[i]+dp[1-turn][wt-w[i]]);
      }
      turn = 1-turn;
    }
    cout<<dp[1-turn][W]<<endl;
    return 0;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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

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


auto solve() {
    int N;
    cin >> N;
    vector<double> p(N);
    for (auto &&e: p) cin >> e;

    auto dp = vector<vector<double>>(N + 1, vector<double>(N + 1, 0.0));
    dp[0][0] = 1.0;
    REP(i, N) {
        REP(j, i + 1) {
            if (dp[i][j] == 0.0) continue;
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
            dp[i + 1][j + 1] += dp[i][j] * (p[i]);
        }
    }

    double res = 0.0;
    FOR(i, (N + 1) / 2, N + 1) {
        res += dp[N][i];
    }

    return res;
}


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

//    cout << (solve() ? "even" : "odd") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int a,b;
 a=b=0;
  for(int i =0 ; i<3 ; i++)
  {if(s[i]=='A')
    a++;
   else
     b++;
  }
  if(a&&b)
    cout<<"Yes\n";
  else
   cout<<"No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define SS size()
#define PB push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

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


int no() {
	cout << "No" << endl;
	return 0;
}

int main() {
	// freopen("./aaa.txt", "r", stdin);
 	// ios::sync_with_stdio(0);

	int h, w; cin >> h >> w;
	vector<string> g;
	string s; 
	REP(i,h) {
		cin >> s; 
		g.PB(s);
	}

	REP(r,h) REP(c,w) {
		if (g[r][c]!='#') continue; 
		int x = 0;
		if (r>0 && g[r-1][c]=='#') x++;
		if (c>0 && g[r][c-1]=='#') x++;
		if (r<h-1 && g[r+1][c]=='#') x++;
		if (c<w-1 && g[r][c+1]=='#') x++;
		if (x==0) return no();
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
def main():
    s = input().rstrip()
    t = [-1]*len(s)
    for i in range(len(s)):
        if s[i] == "T":
            t[i] = 1
    for i in range(1, len(s)):
        t[i] += t[i-1]
    print(2*max(t))

if __name__ == "__main__":
    main()

Measured memory_bytes: 11240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,i;
    cin>>a;
    map<int,int>mp;
    int s[a],ss=0;
    for(i=1; i<a; i++)
    {
        cin>>s[i];
        mp[s[i]]++;
    }
    for(i=1; i<=a; i++)
    {
        cout<<mp[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 13784
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x;
#define outb(x) cout << x << ' ';
#define outn(x) cout << x << '\n';

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for (int i = s; i < e; ++i)
#define fors(i, n) for (int i = 1; i*i <= n; ++i)

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	ini(x1);ini(y1);ini(x2);ini(y2);
	int dx = x2-x1, dy = y2-y1;
	cout << x2-dy << ' ' << y2+dx << ' ' << x1-dy << ' ' << y1+dx;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <tuple>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int P = 1000000007;

int n, x, y, z;

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

  cin >> n >> x >> y >> z;
  y += x;
  z += y;
  vector<map<int, int>> trans((1 << z) + 1);
  trans[1 << z].insert(make_pair(1 << z, 10));
  for (int s = 0; s < (1 << z); ++s) {
    for (int i = 1; i <= 10; ++i) {
      int t = 1, v = s;
      t |= ((v & ((1 << x) - 1)) << i) & ((1 << (x + 1)) - 1);
      v &= ~((1 << x) - 1);
      t |= ((v & ((1 << y) - 1)) << i) & ((1 << (y + 1)) - 1);
      v &= ~((1 << y) - 1);
      t |= ((v & ((1 << z) - 1)) << i) & ((1 << (z + 1)) - 1);
      ++trans[s][min(t, 1 << z)];
    }
  }
  vector<int> dp((1 << z) + 1);
  dp[1] = 1;
  while (n--) {
    vector<int> newDp((1 << z) + 1);
    for (int s = 0; s <= (1 << z); ++s)
      for (const auto& pr : trans[s])
        newDp[pr.first] = (newDp[pr.first] + dp[s] * (ll)pr.second) % P;
    dp = newDp;
  }
  cout << dp[1 << z];

  return 0;
}


Measured memory_bytes: 42368
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define fuck int main
#define cao char
#define number int
#define forever while
#define nani if
#define offfff else
#define loooop for
using namespace std;
number a[10],x;
cao c;
fuck()
{
    forever(cin>>c&&c!='\0')
    {
        nani(c=='0') a[x++]=0;
        offfff nani(c=='1') a[x++]=1;
        offfff
        {
            nani(x) x--;
        }
    }
    nani(x)
    {
        loooop(number i=0;i<x;i++) printf("%d",a[i]);
        printf("\n"); 
    }
    return (0-0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    string n; cin >> n;
    if((n[0]==n[1] && n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int N;
    cin >> N;
    set<string> ans;
    for (int i = 0; i < N; i++) {
        string temp;
        cin >> temp;
        ans.insert(temp);
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 19228