akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long double A, B, H, M;
cin >> A >> B >> H >> M;
long double AX, AY, BX, BY;
long double Akaku, Bkaku;
long double pi = 3.141592653589793;
Akaku=H*30+360*M/720;
Bkaku=360*M/60;
AX=cos((pi/2)-(pi*Akaku/180))*A;
AY=sin((pi/2)-(pi*Akaku/180))*A;
BX=cos((pi/2)-(pi*Bkaku/180))*B;
BY=sin((pi/2)-(pi*Bkaku/180))*B;
long double X, Y, Z;
X=(AX-BX)*(AX-BX);
Y=(AY-BY)*(AY-BY);
Z=X+Y;
Z=sqrt(Z);
cout << setprecision(15) << Z << endl;
//cout << sin((pi*Akaku/180)-(pi/2))<< endl;//30°
//cout << cos((pi*Akaku/180)-(pi/2))<< endl;//30°
}

Measured memory_bytes: 4136
import sys
n=int(input())
s=[list(input()) for i in range(n)]
L1=[]
L2=[]
for i in range(n):
  ct3=0
  l=[0]
  for j in s[i]:
    if j=='(':
      ct3+=1
      l.append(ct3)
    else:
      ct3-=1
      l.append(ct3)
  if l[-1]>=0:
    L1.append((min(l),l[-1]))
  else:
    L2.append((min(l)-l[-1],-l[-1]))

L1.sort()
L1.reverse()
ct4=0
for i in L1:
  if ct4+i[0]<0:
    print('No')
    sys.exit()
  ct4+=i[1]

L2.sort()
L2.reverse()
ct5=0
for i in L2:
  if ct5+i[0]<0:
    print('No')
    sys.exit()
  ct5+=i[1]

if ct4!=ct5:
  print('No')
  sys.exit()

print('Yes')

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

using namespace std;

const int N = 100;
struct Point {
    int x, y;
    int id;
};
vector<Point> points;

bool compare(Point a, Point b) {
    if(a.x == b.x) {
        return a.y < b.y;
    } else {
        return a.x < b.x;
    }
}
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < (n << 1); ++i) {
        int x, y;
        cin >> x >> y;
        if(i < n) {
            points.push_back({x, y, 0});
        } else {
            points.push_back({x, y, 1});
        }
    }
    sort(points.begin(), points.end(), compare);

    int ans = 0;
    set<int>  s;
    for(int i = 0; i < (n << 1); ++i) {
        if(points[i].id == 0) {
            s.insert(points[i].y);
        } else {
            if(s.size() == 0) {
                continue;
            }
            set<int>::iterator it;
            it = s.lower_bound(points[i].y);
            if(it == s.end()) {
                --it;
                s.erase(it);
                ++ans;
            } else {
                if(it == s.begin()) {
                    continue;
                } else {
                    --it;
                    s.erase(it);
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,z[100],i,s,c;
	while(~scanf("%d%d",&a,&b))
	{
		s=0;
		c=1;
		for(i=0;i<a;i++)
		{
			scanf("%d",&z[i]);
			s+=z[i];
			if(s<=b)
			c++;
		}
		printf("%d\n",c);
	} 
	return 0;
 } 

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int cost[50][50][50][50];
int d[50][50];
bool used[50][50];
int v;

int main() {
    int INF = 9999;
    imfor(i, 50) {
        imfor(j, 50) {
            imfor(k, 50) {
                imfor(l, 50) {
                    cost[i][j][k][l] = INF;
                }
            }
        }
    }
    
    int h, w;
    cin >> h >> w;
    char s[50][50];
    imfor(i, h) {
        imfor(j, w) {
            cin >> s[i][j];
        }
    }
    int black = 0;
    imfor(i, h) {
        imfor(j, w) {
            if (s[i][j] == '#') {
                black++;
                continue;
            }
            cost[i][j][i][j] = 0;
            if (i != 0) {
                if (s[i - 1][j] == '.') {
                    cost[i][j][i - 1][j] = 1;
                }
            }
            if (i != h - 1) {
                if (s[i + 1][j] == '.') {
                    cost[i][j][i + 1][j] = 1;
                }
            }
            if (j != 0) {
                if (s[i][j - 1] == '.') {
                    cost[i][j][i][j - 1] = 1;
                }
            }
            if (j != w - 1) {
                if (s[i][j + 1] == '.') {
                    cost[i][j][i][j + 1] = 1;
                }
            }
        }
    }

    // imfor(i, h) {
    //     imfor(j, w) {
    //         cout << cost[1][1][i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // return 0;

    //dijkstra
    int si = 0;
    int sj = 0;
    imfor(i, 50) {
        imfor(j, 50) {
           d[i][j] = INF;
           used[i][j] = false;
        }
    }
    d[si][sj] = 0;
    while (true) {
        int vi = -1;
        int vj = -1;
        imfor(ui, h) {
            imfor(uj, w) {
                if (!used[ui][uj] && (vi == -1 || d[ui][uj] < d[vi][vj])) {
                    vi = ui;
                    vj = uj;
                }
            }
        }

        if (vi == -1) {
            break;
        }

        used[vi][vj] = true;

        imfor(ui, h) {
            imfor(uj, w) {
                d[ui][uj] = min(d[ui][uj], d[vi][vj] + cost[vi][vj][ui][uj]);
            }
        }
    }
    if (d[h - 1][w - 1] == INF) {
        cout << -1;
    }
    else {
        cout << (h * w) - black - (d[h - 1][w - 1] + 1);
    }
}

Measured memory_bytes: 24704
#include <iostream>
#include <cmath>
using namespace std;
int n, a[2005];
int main()	{
	cin>>n>>a[0]>>a[0];
	for(int i=1; i<=n; i++) cin>>a[i];
	cout<<max(abs(a[n]-a[0]), abs(a[n]-a[n-1]));
	return 0;
}

Measured memory_bytes: 256
N=int(input())

dp=[0]*(N+1)
for i in range(1,N+1):
  ans=dp[i-1]+1
  j=1
  while i>=6**j:
    ans=min(ans,dp[i-6**j]+1)
    j+=1
  j=1
  while i>=9**j:
    ans=min(ans,dp[i-9**j]+1)
    j+=1
  dp[i]=ans
  
print(ans)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

ll comb(int n, int k) {
	if (k == 0 || n == k) return 1;
	ll ret = 1;
	for (int i = n - k + 1; i <= n; ++i) ret *= i;
	for (int i = 1; i <= k; ++i) ret /= i;
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, p;
	cin >> n >> p;
	vector<int> a(n);
	cin >> a;
	int odd = 0, even = 0;
	rep(i, n) {
		if (a[i] % 2 == 0) even++;
		else odd++;
	}
	ll ans = 0;
	if (odd == 0) ans += (1LL << n);
	else ans += (1LL << (n - 1));
	if (p) ans = (1LL << n) - ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N+1);
    vector<int> C(N);
    for(int n=0; n<N; n++) {
        cin >> A[n];
        if(n==0) {
            B[n]=abs(A[n]);
        } else if(n==N-1) {
            B[N]=abs(A[n]);
            B[n] = abs(A[n]-A[n-1]);
            B[n] += B[n-1];
            B[N] += B[N-1];
            
            C[N-1] = abs(A[n-1]);
        } else {
            B[n] = abs(A[n]-A[n-1]);
            B[n] += B[n-1];
        }
        
        if(n==1) {
            C[n-1] = abs(A[n]);
        } else if(n>1) {
            C[n-1] = abs(A[n]-A[n-2]);
        }
    }
    B.insert(B.begin(), 0);
    // for(int i=0; i<N+2; i++) {
    //     cout << B[i] << endl;
    // }

    for(int n=1; n<=N; n++) {
        cout << B[n-1]-B[0]+B[N+1]-B[n+1]+C[n-1] << endl;
    }
    

    return 0;
    
}

Measured memory_bytes: 2424
#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;
    vector<int> box(3);
    cin >> box.at(0) >> box.at(1) >> box.at(2) >> n;

    int ans = 0;
    for(int i = 0; box.at(0) * i <= n; i++) {
        int x = n - box.at(0) * i;
        for(int j = 0; j * box.at(1) <= x; j++) {
            int y = x - box.at(1) * j;
            if(y % box.at(2) == 0) ans++;
        }
    }

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

Measured memory_bytes: 3564
# include <bits/stdc++.h>
# define rep(i, n) for (ll i = 0; i < (n); i++)
# define reps(i, n) for (ll i = 1; i <= (n); i++)
# define foreps(i, m, n) for (ll i = (m); i < (n); i++)
# define len(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const long long mod = 1e9 + 7;
const long long inf = 1e18;

int main() {
    ll x, y; cin >> x >> y;
    
    ll ans = 1e18;
    if (x <= y) ans = min(ans, y - x);
    if (-x <= y) ans = min(ans, y + x + 1);
    if (x <= -y) ans = min(ans, - y - x + 1);
    if (-x <= -y) ans = min(ans, - y + x + 2);

    cout << ans << endl;
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<math.h>
#define MAX 110000

int main(){
    int N;
    int x[MAX], y[MAX], t[MAX];
    int difft, diffx, diffy;
    int ans=0;

    scanf("%d", &N);
    for(int i=1; i<=N; i++){
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }
    t[0]=0; x[0]=0; y[0];

    for(int i=0; i<N; i++){
        difft = t[i+1] - t[i];
        diffx = abs(x[i+1] - x[i]);
        diffy = abs(y[i+1] - y[i]);

        if(difft == diffx+diffy){
            continue;
        }else if(difft < diffx + diffy){
            ans = 1;
            break;
        }else{
            if((diffx+diffy-difft)%2==0){
                continue;
            }else{
                ans = 1;
                break;
            }
        }
    }

    if(ans==0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int dp[50];

int fib(int n){
if(n==0 || n==1) return dp[n]=1;
if(dp[n]!=-1)return dp[n];
return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
int n,i;
for(i=0;i<50;i++)dp[i]=-1;

scanf("%d",&n);
printf("%d\n",fib(n));
return 0;
}
  




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    long A, B, C, K, sum = 0;
    cin >> A >> B >> C >> K;
    if (K > A + B) {
        K -= A + B;
        if (K <= C) {
            sum += A + -1 * K;
        } else {
            sum += A + -1 * C;
        }
    } else {
        if (K <= A) {
            sum += K;
        } else {
            sum += A;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,a[100],sum;
int minj,temp;
int main(){
 cin >> n;
 for(int i = 0;i < n;i++)scanf("%d",&a[i]);

 for(int i = 0;i < n;i++)
 {
  minj = i;
        for(int j = i;j < n;j++)
        {
         if(a[j] < a[minj])
          minj = j;
  }      
  temp = a[i];
  a[i] = a[minj];
  a[minj] = temp;
        if(i != minj) sum++;
 }
 for(int i = 0;i < n;i++)
 {
  if(i != n-1) printf("%d ",a[i]);
        else printf("%d\n",a[i]);
 }
 printf("%d\n",sum);
} 


Measured memory_bytes: 3216
#include <iostream>
#include <string>
using namespace std;
int main(){
 
    string r;
    cin>>r;
    int n,count1=0,count2=0;
    cin>>n;
    string rings;
    for(int i=0;i<n;i++){
        cin>>rings;
        rings=rings+rings;
        count1=rings.find(r);
        if(count1==string::npos){}
        else{
            count2++;
        }
    }
    cout<<count2<<endl;
 
return 0;
}

Measured memory_bytes: 1212
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (a, b, c) = readLongList()

    val ans = if (a % 2 == 0L || b % 2 == 0L || c % 2 == 0L) {
        0
    } else {
        min(min(a * b, b * c), c * a)
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36356
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

int main(int argc, char *argv[]){
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i=0; i<N; i++) {
		cin >> p[i];
	}

	sort(p.begin(), p.end());
	p[N-1] /= 2;

	int sum = 0;
	for (int i=0; i<N; i++) {
		sum += p[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int  pd=0;
	bool ppd=false;
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		if(a[i]==b[i]){
			pd++;
		}
		if(pd>=3){
			ppd=true;
		}
		if(a[i]!=b[i])    pd=0;
	}
	if(ppd){
		cout<<"Yes"<<endl;
	}
	else    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
	if(a>b){
	swap(a,b);
	}if(a>c){
	swap(a,c);
	}if(b>c){
	swap(b,c);
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}

Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            string T = cin.next();
            StringBuilder ans = new StringBuilder();
            for (int i = 0; i < T.Length; i++)
            {
                if(T[i] == '?')
                {
                    ans.Append("D");
                }
                else
                {
                    ans.Append(T[i]);
                }
            }

            Console.WriteLine(ans.ToString());
        }
    }
}


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

using namespace std;
int main() {
	int N,z;
	int n[2];
	cin >> N;
	vector<vector<int>> a(N+1, vector<int>(3,0));
	vector<vector<int>> h(N+1, vector<int>(3,0));
	for (int i = 0; i < N; i++) {
		for (int m = 0; m < 3; m++) {
			cin >> a[i][m];
		}
	}
	for (int i = 0; i <= N; i++) {
		for (int m = 0; m < 3; m++) {
			if (m == 0) {
				n[0] = 1;
				n[1] = 2;
			}
			if (m == 1) {
				n[0] = 0;
				n[1] = 2;
			}
			if (m == 2) {
				n[0] = 0;
				n[1] = 1;
			}
			if (i == 0) {
				h[i][m] = a[i][m];
			}
			else {
				h[i][m] = max(h[i-1][n[0]] + a[i][m], h[i-1][n[1]] + a[i][m]);
			}
		}
	}
	cout << max(h[N][0], max(h[N][1], h[N][2])) << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << 6 - (a + b) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        long n = int.Parse(input.ReadLine());

        return n * n * n;
    }
}


Measured memory_bytes: 11092
#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
k = int(input())
s = list(input())
#print(len(s))
if len(s) <= k:
    print("".join(s))
else:
    t = "".join(s[:k]) + "..."
    print(t) 

Measured memory_bytes: 9040
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
  
        static Dictionary<int,int> Query;
        static int H;  
  
        static int[] A;
  
        static void Main(string[] args)
        {
          //入力を受け取る
          int[] NM = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          var N = NM[0];
          var M = NM[1];
          Query = new Dictionary<int,int>();
          A= Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          Array.Sort(A);
          
          for(int i = 0; i < M ; i++){
            var BC = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var B = BC[0];
            var C = BC[1];
            if(!Query.ContainsKey(C)){
              Query.Add(C,B);
            }else{
              Query[C] += B;
            }
          }
          
          //buildMaxHeap(A);
          
          var SortedQuery = Query.OrderByDescending((x) => x.Key);
          var count = 0;
          foreach(KeyValuePair<int, int> item in SortedQuery) {
            bool flag = true;
            //Console.WriteLine("[{0}:{1}]", item.Key, item.Value); 
            for(int j = 0; j < item.Value ; j++){
              if(count < A.Length && A[count] < item.Key){
                A[count] = item.Key;
                count++;
              }else{
                if(j == 0){
                  flag = false;
                }
                break;
              }
            }
            if(!flag){
              break;
            }
          }
          
          long sum = 0;
          for(int i = 0; i < N ; i++){
            sum += A[i];
          }
          Console.WriteLine(sum); 
          
        }
  

  
 }

Measured memory_bytes: 32316
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
//constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
signed main(){
    int n,sum[1000001],mi[1000001];//a[1000001],b[1000001];
    cin>>n;
    string s[1000001];
    rep(i,n){
        cin>>s[i];
        mi[i]=0,sum[i]=0;
        for(char c:s[i]){
            if(c=='(')sum[i]++;
            else{
                sum[i]--;
                chmin(mi[i],sum[i]);
            }
        }
    }
    vector<P>A,B;
    rep(i,n){
        int a=-mi[i],b=sum[i]-mi[i];
        if(a<b){
            A.pb({a,b});
        }
        else{
            B.pb({b,a});
        }
    }
    sort(all(A));
    sort(all(B),greater<P>());
    for(P &p:B)swap(p.fi,p.se);
    int now=0;
    for(P p:A){
        if(now<p.fi){
            puts("No");
            return 0;
        }
        now+=p.se-p.fi;
    }
    for(P p:B){
        if(now<p.fi){
            puts("No");
            return 0;
        }
        now+=p.se-p.fi;
    }
    if(now==0){
        puts("Yes");
    }
    else{
        puts("No");
    }
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    map<LL,LL> mp;
    REP(i,n){
        LL a;cin>>a;
        mp[a]++;
    }
    LL result = 0;
    for(auto x : mp){
        if(x.first < x.second){
            result += x.second-x.first;
        }
        if(x.first > x.second){
            result += x.second;
        }
    }
    cout<<result<<endl;
    
	return;
}

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

Measured memory_bytes: 9640
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0
for i in range(A+1):
    for j in range(B+1):
        remain=X-i*500-j*100
        if remain >=0 and remain%50==0 and remain/50 <= C:
            count+=1
            
print(count)

Measured memory_bytes: 3064
package main

import "fmt"

func OddJudge(num int) bool {
	if num%2 == 0 {
		return true
	} else {
		return false
	}
}
func fn(num int) {
	if OddJudge(num) {
		num = num / 2
		fn(num)
	} else {
		num = 3*num + 1
		fn(num)
	}
}
func main() {
	var s int
	fmt.Scanf("%d\n", &s)

	rep := make([]int, 1)
	rep[0] = s

A:
	for {
		if OddJudge(rep[len(rep)-1]) {
			tempValue := rep[len(rep)-1] / 2
			for _, v := range rep {
				if v == tempValue {
					break A
				}
			}
			rep = append(rep, rep[len(rep)-1]/2)
		} else {
			tempValue := 3*rep[len(rep)-1] + 1
			for _, v := range rep {
				if v == tempValue {
					break A
				}
			}
			rep = append(rep, tempValue)
		}
	}
	fmt.Println(len(rep) + 1)
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> hight(10);
  for(int i=0; i<10; i++){cin >>hight[i];}
  sort(hight.begin(),hight.end());
  cout <<hight[9]<<endl<<hight[8]<<endl<<hight[7]<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<LL, bool> P;


LL modpow(LL a, LL b) {
  LL r = 1;
  while (b) {
    if (b % 2 == 1) r = r * a % kMod;
    a = a * a % kMod;
    b /= 2;
  }
  return r;
}

LL invmod(LL a) {
  return modpow(a, kMod - 2);
}

LL solve() {
  LL N, K; cin >> N >> K;
  vector<P> ps; ps.reserve(N);
  int pos_cnt = 0;
  for (int i = 0; i < N; ++i) {
    LL A; cin >> A;
    if (A >= 0) {
      ps.push_back({A, true});
      ++pos_cnt;
    } else {
      ps.push_back({-A, false});
    }
  }

  LL ans = 1;
  if (N == K) {
    int cnt = 0;
    for (auto [v, b] : ps) {
      ans = (ans * v) % kMod;
      if (!b) ++cnt;
    }
    return (cnt % 2 == 0) ? ans : -ans;
  }

  if (pos_cnt == 0 && K % 2 == 1) {
    sort(ps.begin(), ps.end());
    for (int i = 0; i < K; ++i) {
      auto [v, b] = ps[i];
      ans = (ans * v) % kMod;
    }
    return -ans;
  }

  sort(ps.rbegin(), ps.rend());
  int cnt = 0;
  LL last_pos = -1, last_neg = -1;
  for (int i = 0; i < K; ++i) {
    auto [v, b] = ps[i];
    ans = (ans * v) % kMod;
    if (b) {
      last_pos = v;
      --pos_cnt;
    } else {
      last_neg = v;
      ++cnt;
    }
  }

  if (cnt % 2 == 0) {
    return ans;
  }

  int i = K;
  LL next_neg = -1, next_pos = -1;
  while (next_neg < 0 || next_pos < 0) {
    if (i >= N) break;
    auto [v, b] = ps[i];
    if (b  && next_pos < 0LL) next_pos = v;
    if (!b && next_neg < 0LL) next_neg = v;
    ++i;
  }

  if (last_pos < 0) {
    LL k = next_pos * invmod(last_neg) % kMod;
    return (k * ans) % kMod;
  } else if (last_neg < 0) {
    LL k = next_neg * invmod(last_pos) % kMod;
    return (k * ans) % kMod;
  } else if (next_neg >= 0 && next_pos >= 0) {
    if (next_pos * last_pos >= next_neg * last_neg) {
      LL k = next_pos * invmod(last_neg) % kMod;
      return (k * ans) % kMod;
    } else {
      LL k = next_neg * invmod(last_pos) % kMod;
      return (k * ans) % kMod;
    }
  } else if (next_neg >= 0) {
    return ((ans * next_neg) % kMod) * invmod(last_pos) % kMod;
  } else {
    return ((ans * next_pos) % kMod) * invmod(last_neg) % kMod;
  }
}

int main() {
  LL ans = solve();
  if (ans < 0) ans = (kMod + ans) % kMod;
  cout << ans << endl;
}


Measured memory_bytes: 6312
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if (a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if (a < b) a = b;}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e18 + 1;


int f(int x, int y, int z) {
	if (x == 0 && y == 0 && z == 0)return 0;
	if (((x & 1) ^ (y & 1)) == (z & 1)) {
		int res1 =  2 * f(x >> 1, y >> 1, z >> 1);
		int res2 = INF;
		if (x > 0)res2 = 1 + 2 * f((x - 1) >> 1, (y + 1) >> 1, z >> 1);
		int res = min(res1, res2);
		if (res >= INF)return INF;
		else return res;
	}
	else {
		return INF;
	}
}

void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N) {
		cin >> A[i];
	}
	int x = A[0], y = A[1];
	int z = 0;
	FOR(i, 2, N)z ^= A[i];
	ll ans = f(x, y, z);
	if (ans >= INF || ans == x)print(-1);
	else print(ans);
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//while (test());
	 //int q;
	 //cin >> q;
	 //while (q--)
	solve();
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int main() {
	int R;
	cin >> R;
	
	string ans;
	if (R < 1200) ans = "ABC";
	else if (R < 2800) ans = "ARC";
	else ans = "AGC";
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>

std::string parse(std::string const& s, size_t& i,
                  std::vector<std::string> const& ops, size_t preced = 0) {

  if (preced == ops.size()) {
    if (s[i] == '(') {
      auto res = parse(s, ++i, ops, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    }
    assert(isalpha(s[i]));
    return std::string(1, s[i++]);
  }

  auto res = parse(s, i, ops, preced+1);
  int left = (ops[preced][0] == 'L');
  while (i < s.length()) {
    char op = s[i];
    if (!std::count(ops[preced].begin()+1, ops[preced].end(), op)) break;
    auto tmp = parse(s, ++i, ops, preced+left);
    res = "(" + res + op + tmp + ")";
  }
  return res;
}

void solve_testcase() {
  size_t G;
  scanf("%zu", &G);

  std::vector<std::string> ops(G);
  for (size_t i = 0; i < G; ++i) {
    char A;
    size_t M;
    scanf(" %c %zu", &A, &M);
    ops[i] += A;
    for (size_t j = 0; j < M; ++j) {
      char op;
      scanf(" %c", &op);
      ops[i] += op;
    }
  }

  size_t N;
  scanf("%zu", &N);
  for (size_t i = 0; i < N; ++i) {
    char buf[128];
    scanf("%s", buf);
    std::string s = buf;
    size_t j = 0;
    printf("%s\n", parse(s, j, ops).c_str());
  }
}

int main() {
  int D;
  scanf("%d", &D);
  for (int i = 0; i < D; ++i) {
    if (i > 0) puts("");
    solve_testcase();
  }
}



Measured memory_bytes: 2664
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        
        if(S.length() <= K){
            System.out.println(S);
        }else{
            System.out.println(S.substring(0,K)+"...");
        }
    }
}


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

int main()
{
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		//cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << " " << xp << " " << yp << " " << endl;
		//AB
		double abx = x2 - x1;
		double aby = y2 - y1;
		//BC
		double bcx = x3 - x2;
		double bcy = y3 - y2;
		//CA
		double cax = x1 - x3;
		double cay = y1 - y3;
		//AP
		double apx = xp - x1;
		double apy = yp - y1;
		//BP
		double bpx = xp - x2;
		double bpy = yp - y2;
		//CP
		double cpx = xp - x3;
		double cpy = yp - y3;

		//AB * BP
		double a = abx*bpy - aby*bpx;
		//BC * CP
		double b = bcx*cpy - bcy*cpx;
		//CA * AP
		double c = cax*apy - cay*apx;

		if ((a > 0 && b > 0 && c > 0) || (a < 0 && b < 0 && c < 0)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 1216
import sys
from math import sqrt
from collections import Counter, defaultdict

input = sys.stdin.readline


def I():
    return int(input())


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


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    a, b, c = MI()
    print("{} {} {}".format(c, a, b))
    pass


if __name__ == "__main__":
    main()


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

struct node{
  unsigned int key;
  struct node *prev;
  struct node *next;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int);
void init(void);
void printList(void);
void deleteNode(NodePointer);
void deleteFirst(void);
void deleteLast(void);
void delete(int);
void insert(int);


int main(void){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf(" %s", com);
    if ( com[0] == 'i' ) {scanf(" %d",&key); insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	scanf(" %d",&key);
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

NodePointer listSearch(int key){
  NodePointer t;
  t = nil->next;
  if(t == nil) return nil;
  while(t != nil){
    if(t->key == key)return t;
    t = t->next;
  }
  return nil;
}

void init(void){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if(cur == nil)break;
    if(isf == 0)printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t != nil ) deleteNode(t);
}

void deleteLast(){
  NodePointer t;
  t = nil->prev;
  if(t != nil) deleteNode(t);
}

void delete(int key){
  NodePointer t;
  if((t = listSearch(key)) == nil);
  else deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  nil->next->prev = x;
  nil->next = x;
}



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

using namespace std;

const long long INF = 1000000000000;

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

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

int main(){
    long long n;
    cin >> n;

    vector<long long> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    
    
    vector<long long> dp(n);
    for(int i=0; i<n; i++){
        dp[i] = INF;
    }
    dp[0] = 0;

    for(int i=1; i<n; ++i){
        chmin(dp[i],dp[i-1]+abs(v[i]-v[i-1]));
        if(i>1){
            chmin(dp[i],dp[i-2]+abs(v[i]-v[i-2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4968
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
N, M=input().split()
N=int(N)
M=int(M)
i=0
ID_list=[]
ID_sublist=[]
gate_possible_list=[]
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
for i in range(N):
 ID_list.append(i+1)
#print(ID_list)
#for i in range(N)
gate_list =  [list(map(int, input().split(" ")))for i in range(M)]
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！

#x=[]
#y=[]
#t, x, y = [0]*(N+1), [0]*(N+1), [0]*(N+1)#N+1個の空のリストを作成(原点を入れて##るから一つ増える)
#delta_t=0
#delta_x=0
#delta_y=0
#l=0
#t[0],x[0],y[0]=[0, 0, 0]
#とりあえず入力までは完成した．
#for i in range(N):
# t[i+1], x[i+1], y[i+1] = map(int, input().split())
#child_i =  list(map(int, input().split()))
#w_len=len(w)
#w_list=list(w)
#print(len(w_list))
#print(w_list)
#child_il=sorted(child_i)
#print(child_il)#リストの右端のほうが大きい
i=0
j=0
k=0
l=0
m=0
mini=gate_list[0][0]
maxi=gate_list[0][1]
for i in range(M):
  if mini <gate_list[i][0]:
      mini=gate_list[i][0]
i=0
for i in range(M):
  if maxi >gate_list[i][1]:
      maxi=gate_list[i][1]
#print(maxi, mini)
if maxi-mini<0:
    print(0)
else:
 print(maxi-mini+1)


      
#for i in range(M):#ゲートの個数分回す
# for j in range(gate_list[i][1]-gate_list[i][0]+1):
#     gate_possible_list.append(gate_list[i][0]+j)
 #print(gate_possible_list)
# for k in range(len(ID_list)):
#     for j in range(len(gate_possible_list)):
#      if ID_list[k]==gate_possible_list[j]:
#         ID_sublist.append(gate_possible_list[j])
#      else:
#          pass
#
# gate_possible_list=[]
# ID_list=[]
# for m in range(len(ID_sublist)):
#  ID_list.append(ID_sublist[m])
# #print(ID_list)
# ID_sublist=[]
#print(len(ID_list))
#これ時間かかりまくり


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

//https://atcoder.jp/contests/abc076/submissions/1696628
int n, t[109], v[109],s[109],p[40009];

int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%d",&t[i]);
        t[i]*=2;
        s[i+1]=s[i]+t[i];
    }
    for (int i=1;i<=n;i++) {
        scanf("%d",&v[i]);
        v[i]*=2;
    }
    for(int i=0;i<=s[n+1];i++) {
        for (int j=1;j<=n+1;j++) {
            if (s[j]>=i) {
                p[i]=v[j-1];
                break;
            }
        }
        for (int j=0;j<=n+1;j++) {
            int dst=abs(s[j]-i);
                p[i]=min(p[i],dst+min(v[j-1],v[j]));
        }
    }
    int sum=0;
    for (int i=0;i<=s[n+1];i++) sum+=p[i];
    printf("%.12Lf\n",0.25l*sum);
    return 0;
}


Measured memory_bytes: 384
if __name__ == '__main__':
    N = int(input())
    res = []
    for _ in range(N):
        res.append(str(input()))
    print('AC x {}'.format(res.count('AC')))
    print('WA x {}'.format(res.count('WA')))
    print('TLE x {}'.format(res.count('TLE')))
    print('RE x {}'.format(res.count('RE')))

Measured memory_bytes: 16128
import numpy as np
import sys
n,k,q = map(int,input().split())
p = np.array([k]*n)
if k > q:
    for i in range(q):
        a = int(input())
    for i in range(n):
        print('Yes')
    sys.exit()
for i in range(q):
    p[int(input())-1] += 1
for i in range(n):
    print('Yes' if p[i]>=q+1 else 'No')


Measured memory_bytes: 14024
#include <iostream>

using namespace std;

int main() {
    int a;
    int b;
    cin>>a;
    cin>>b;
if (a==b){cout<<"Draw";}
else if (a==1){cout<<"Alice";}
    else if (b==1){cout<<"Bob";}
    else if (a>b){cout<<"Alice";}
    else(cout<<"Bob");


    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c,d;
	int n;
	int ans;

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

Measured memory_bytes: 0
import sys
from io import StringIO
import unittest
def resolve():
    a1=list(map(int,input().strip().split()))
    a2=list(map(int,input().strip().split()))
    a3=list(map(int,input().strip().split()))
    n = int(input().strip())
    b=[]
    for i in range(n):
        tmp=int(input().strip())
        b.append(tmp)

    if a1[0] in b and a1[1] in b and a1[2] in b:
        print("Yes")
        return
    
    if a2[0] in b and a2[1] in b and a2[2] in b:
        print("Yes")
        return
    
    if a3[0] in b and a3[1] in b and a3[2] in b:
        print("Yes")
        return

    # t
    if a1[0] in b and a2[0] in b and a3[0] in b:
        print("Yes")
        return
    
    if a1[1] in b and a2[1] in b and a3[1] in b:
        print("Yes")
        return
    
    if a1[2] in b and a2[2] in b and a3[2] in b:
        print("Yes")
        return

    # na
    if a1[0] in b and a2[1] in b and a3[2] in b:
        print("Yes")
        return

    if a1[2] in b and a2[1] in b and a3[0] in b:
        print("Yes")
        return
    print("No")
    return

resolve()

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

#define ll long long 

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};


int main(){
	int n , q;
	cin >> n >> q;
	BIT<ll> bit(n);
	for(int i = 0 ; i < n ; i++){
		int p;
		cin >> p;
		bit.add(i,p);
	}
	while(q--){
		int t , l , r;
		cin >> t >> l >> r;
		if(t==0){
			bit.add(l,r);
		}
		else
			cout<<bit.sum(l,r)<<"\n";
	}
	
			
		
}


Measured memory_bytes: 8220
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "Possible" << endl;
  exit(0);
}

void no(){
  cout << "Impossible" << endl;
  exit(0);
}


int main() {
  ll a,b; cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) yes();
  else no();
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
int n,num[26],ans=1;char s[N];
inline int fas(int x,int p){
	int res=1;
	while(p){
		if(p&1)res=1ll*res*x%mod;
		p>>=1;
		x=1ll*x*x%mod;
	}
	return res;
}
inline int MOD(int x,int y){x+=y;x-=x>=mod? mod:0;x+=x<0? mod:0;return x;}
int main(){
	scanf("%d",&n);scanf("%s",s+1);
	for(register int i=1;i<=n;i++)num[s[i]-'a']++;
	for(register int i=0;i<26;i++)
		ans=1ll*ans*(num[i]+1)%mod;
	printf("%d\n",MOD(ans,-1));
	return 0;
}

Measured memory_bytes: 384
//g++  5.4.0

  #include <iostream>
  #include<cmath>
  #include<cassert>
  using namespace std;
  //#define long long ll
  int main()
  {
      
      //std::cout << "Hello, world!\n";
      long long n,k;cin>>n>>k;
      long long ar[n],mem[n] = {0};
      for(int i = 0;i < n;i++){
          cin>>ar[i];// = 1e5;
      }
      mem[0] = 0;
      //mem[1] = (int)abs(ar[1]-ar[0]);
      for(int i = 1;i < n;i++){
          mem[i] = 2e9;//abs(ar[i] - ar[max(0ll,i-k)]) + mem[max(0ll,i-k)];
          for(int j = max(0ll,i-k);j < i;j++){

              mem[i] = min(mem[i],(int)abs(ar[i]-ar[j])+mem[j]);
          }
                 //mem[i] = min(mem[i],abs(ar[i] - mem[i-j]));
      }
      
      cout<<mem[n-1]<<"\n";
      
  }

Measured memory_bytes: 1792