akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    string s, t;
    cin >> s >> t;
    priority_queue<char, vector<char>, greater<char>> qs;
    priority_queue<char> qt;
    rep(i, s.size()) { qs.push(s[i]); }
    rep(j, t.size()) { qt.push(t[j]); }

    string ss = "", tt = "";
    while (!qs.empty()) {
        ss += qs.top();
        qs.pop();
    }

    while (!qt.empty()) {
        tt += qt.top();
        qt.pop();
    }

    if (ss < tt)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main() {
	int n, pt = 0, ph = 0;
	string t, h;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t >> h;
		if (t.compare(h) == 0) {
			pt++;
			ph++;
		} else if (t.compare(h) > 0) {
			pt += 3;
		} else {
			ph += 3;
		}
	}

	cout << pt << " " << ph << endl;
	return 0;
}


Measured memory_bytes: 3180
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 21
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k;
string s,s1;
//Variables End

ll sub(ll a, ll b){return (a-b+MOD)%MOD;}
ll add(ll a, ll b){return (a+b)%MOD;}
ll mul(ll a, ll b){return (a*b)%MOD;}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;
		vector<vi> ar(n+1,vi(n+1,0));
		m=1<<n;
		rep(i,0,n)rep(j,0,n)cin>>ar[i][j];
		vi prev(m,0);
		prev[0]=1;
			rep(mask,0,m)
			{
				ll i=setbitc(mask);
				rep(j,0,n)
				{
					if(ar[i][j] && (!(mask&(1<<j))))
					{

						prev[mask|(1<<j)]=add(prev[mask|(1<<j)],prev[mask]);
					}
				}
			}


		cout<<prev[m-1]<<endl;
    }
    return 0;
        
}

Measured memory_bytes: 16640
import sys
range = xrange
input = raw_input

n = int(input())
pairs = []
for _ in range(n):
     a,b = input().split()
     b = -int(b)
     pairs.append((a,b))

order = sorted(range(n), key = lambda i:pairs[i])

print '\n'.join(str(x+1) for x in order)


Measured memory_bytes: 28012
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

signed main()
{
	char c;
	std::cin>>c;
	if(c>='a'&&c<='z') puts("a");
	else puts("A");
	return 0;
}
// ----------------------------
// by imzzy


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,Y,A,B,C; cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A),q(B),r(C);
    for (int i=0;i<A;++i) cin >> p[i];
    for (int i=0;i<B;++i) cin >> q[i];
    for (int i=0;i<C;++i) cin >> r[i];
    sort(p.begin(),p.end()); reverse(p.begin(),p.end());
    sort(q.begin(),q.end()); reverse(q.begin(),q.end());
    sort(r.begin(),r.end()); reverse(r.begin(),r.end());
    ll ans=0;
    for (int i=0;i<X;++i) ans+=p[i];
    for (int i=0;i<Y;++i) ans+=q[i];
    --X,--Y;
    for (int i=0;i<C;++i){
        if ((X<0||r[i]<=p[X])&&(Y<0||r[i]<=q[Y])) continue;
        if (X>=0&&(Y<0||p[X]<q[Y])) ans+=r[i]-p[X--];
        else if (Y>=0) ans+=r[i]-q[Y--];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 2560
//
//  main.cpp
//  C - Attack Survival
//
//  Created by Hashizo on 2019/09/15.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef LONG_MAX
#undef LONG_MIN

#define LONG_MAX	9223372036854775807
#define LONG_MIN	(-LONG_MAX  -1)

#define ll long long

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

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

	vector<ll> point(n);
	REP(i, n) {
		point[i] = k;
	}

	ll a;
	REP(i, q) {
		cin >> a;
		point[a-1]++;
	}

	
	REP(i, n) {
		if (point[i] > q) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll n;
    ll W;
    ll a[200005];
    ll val[200005];
    ll b[200005];
    ll c[200005];
    ll dp[200][100005];
    ll recurse(ll pos,ll weight){
       if(pos>n)
       return 0;
       if(dp[pos][weight]!=-1)
       return dp[pos][weight];
       else if(weight+a[pos]>W)
       return dp[pos][weight]=recurse(pos+1,weight);
       return dp[pos][weight]=max(recurse(pos+1,weight),val[pos]+recurse(pos+1,weight+a[pos]));
	}
    int main()
    {
        fastread;
        ll i,j,k,l,m;
        cin>>n>>W;
        for(i=1;i<=n;i++){
        	for(j=0;j<=100000;j++)
        	dp[i][j]=-1;
		}
        for(i=1;i<=n;i++)
        cin>>a[i]>>val[i];
        cout<<recurse(1,0);
    	return 0;
    }

Measured memory_bytes: 83584
import java.util.*;
import java.awt.*;

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

    int H = sc.nextInt();
    int W = sc.nextInt();
    int possible_field_count = 0;
    char[][] field = new char[H][W];
    for (int i = 0; i < H; i++) {
      field[i] = sc.next().toCharArray();
      for (int j = 0; j < W; j++) {
        if (field[i][j] == '.') possible_field_count++;
      }
    }

    Queue<Point> q = new ArrayDeque<>();
    q.add(new Point(0, 0));

    int[][] count = new int[H][W];
    count[0][0] = Integer.MIN_VALUE;

    int[] h_move = {1,-1,0,0};
    int[] w_move = {0,0,1,-1};

    while (true) {
      int e = q.size();
      if (e == 0) break;

      for (int x = 0; x < e; x++) {
        Point point = q.poll();

        for (int i = 0; i < 4; i++) {
          int next_h = point.x + h_move[i];
          int next_w = point.y + w_move[i];

          if (next_h >= 0 && next_h < H && next_w >= 0 && next_w < W) {
            if (field[next_h][next_w] == '.') {
              if (count[next_h][next_w] > count[point.x][point.y] + 1) {
                count[next_h][next_w] = count[point.x][point.y] + 1;
                q.add(new Point(next_h, next_w));
              }
            }
          }
        }
      }
    }

    if (count[H-1][W-1] == 0) {
      System.out.println(-1);
    } else {
      System.out.println(possible_field_count - (count[H-1][W-1] - count[0][0] + 1));
    }
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int> >;
 
int main(){
  int a, b, c; cin >> a >> b >> c;
  string ans = "No";
  if(a == b and a !=c) ans = "Yes";
  else if(a == c and a!=b) ans = "Yes";
  else if(b == c and a!=b) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
public class Main {

  private static void solve() {
    int n = ni();
    int r = ni();

    if (n <= 10) {
      System.out.println(r + 100 * (10 - n));
    } else {
      System.out.println(r);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define N 1005
#define S 5005
#define INF 0x3f3f3f3f
int n,f[2][S],g[N],fa[N],cnt[N],ch[N][N],x[N];
void dp(int u)
{
	for(int i=1;i<=cnt[u];++i) dp(ch[u][i]);
	int o=0;
	memset(f[0],INF,sizeof(f[0]));f[0][0]=0;
	for(int i=1;i<=cnt[u];++i)
	{
		int v=ch[u][i];
		o^=1;memset(f[o],INF,sizeof(f[o]));
		for(int j=0;j<=x[u];++j)
		{
			if(j>=g[v]) f[o][j]=min(f[o][j],f[o^1][j-g[v]]+x[v]);
			if(j>=x[v]) f[o][j]=min(f[o][j],f[o^1][j-x[v]]+g[v]);
		}
	}
	for(int i=0;i<=x[u];++i) g[u]=min(g[u],f[o][i]);
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;++i) scanf("%d",&fa[i]),ch[fa[i]][++cnt[fa[i]]]=i;
	for(int i=1;i<=n;++i) scanf("%d",&x[i]);
	memset(g,INF,sizeof(g));
	dp(1);
	if(g[1]<INF) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
} 

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,m;
    cin>>n>>m;
    for(int i=m/n;i>=1;i--){
        if(m%i==0)
        {
            cout<<i<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def calc(take, a, b, c):
    if take == N:
        return abs(a-A)+abs(b-B)+abs(c-C) -30 if min(a,b,c)>0 else INF
    ret0 = calc(take+1, a, b, c)
    ret1 = calc(take+1, a+l[take], b, c) + 10
    ret2 = calc(take+1, a, b+l[take], c) + 10
    ret3 = calc(take+1, a, b, c+l[take]) + 10
    return min(ret0, ret1, ret2, ret3)
    
print(calc(0,0,0,0))

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

public class Main {
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int H = in.i();
        int W = in.i();
        int A = in.i();
        int B = in.i();
        if (A <= W - A && B <= H - B) {
            char[] c = new char[W];
            char[] d = new char[W];
            for (int i = 0; i < A; i++) {
                c[i] = '0';
                d[i] = '1';
            }
            for (int i = A; i < W; i++) {
                c[i] = '1';
                d[i] = '0';
            }
            for (int i = 0; i < B; i++) {
                out.println(c);
            }
            for (int i = B; i < H; i++) {
                out.println(d);
            }
        } else {
            out.println("No");
        }
        out.flush();
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 34160
s = input()
import sys

n = len(s) - 1
if n == 0:
    print(int(s))
    sys.exit()

sums = 0
for i in range(2**n):
    bit = bin(i)[2:]
    if len(bit) <= n:
        bit = '0'*(n-len(bit)) + bit

    if bit.count('1') == 0:
        sums += int(s)
    elif bit.count('1') == 1:
        pos = bit.index('1')
        sums += int(s[:pos+1]) + int(s[pos+1:])
    else:
        num = bit.count('1')
        count = 0
        string = ''
        pos = 0
        for j,k in enumerate(bit):

            if k == '1' and count == 0:
               string += s[:j+1] + '+'
               count += 1
               pos = j
            elif k == '1':
                string += s[pos+1:j+1] + '+'
                pos = j
                count += 1
            if k == '1' and count == num:
                string += s[j + 1:]

        sums += sum([int(x) for x in string.split('+')])

print(sums)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n && i <= y / 10000; i++) {
		int f = y - i * 10000;
		int g = n - i;
		int h = f - g * 1000;
		if (h < 0)continue;
		if (g - (h / 4000) < 0)continue;
		if (h % 4000 == 0) {
			cout << i << " " << h / 4000 << " " << g - (h / 4000) << endl;
			getchar();
			getchar();
			return 0;
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pdd pair<double, double>
#define V vector<int>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define db(x) cout << #x << "=" << (x) << endl
#define db2(x, y) cout << #x << "=" << (x) << " " << #y << "=" << (y) << endl
#define db3(x, y, z) cout << #x << "=" << (x) << " " << #y << "=" << (y) << " " << #z << "=" << (z) << endl

using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
const double eps = 1e-9;

int main()
{
    #ifdef AFei
    freopen("in.txt", "r", stdin);
    #endif

    int N, K;
    cin >> N >> K;
    int ans = 0;
    for(int x, i = 0; i < N; ++ i)
    {
        cin >> x;
        ans += x >= K;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// int n = 5;
// // {0, 1, ..., n-1} の部分集合の全探索
// for (int bit = 0; bit < (1<<n); ++bit)
// {
//     /* bit で表される集合の処理を書く */
//     // bit の表す集合を求める
//     for (int i = 0; i < n; ++i) {
//         if (bit & (1<<i)) { // i が bit に入るかどうか
//             cout << i << endl ;
//         }
//     }
// }

#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PI 3.14159265358979323846
using namespace std;
void debugVV(vector<vector<int> >& deV) {
    for (int i = 0; i < deV.size(); i++) {
        cout << i << " ";
        for (int j = 0; j < deV[i].size(); j++) {
            cout << "[" << j << "]= " << deV[i][j] << ",";
        }
        cout << endl;
    }
}
void debugV(vector<int>& deV) {
    for (int i = 0; i < deV.size(); i++) {
        cout << "[" << i << "]= " << deV[i] << ",";
    }
    cout << endl;
}

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    vector<vector<int> > s;
    REP(i, m) {
        cin >> k[i];
        s.push_back(vector<int>());
        REP(j, k[i]) {
            int a;
            cin >> a;
            s[i].push_back(a);
        }
    }
    vector<int> p(m);
    REP(i, m) { cin >> p[i]; }
    int ans = 0;

    // int n = 5;
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1 << n); ++bit) {
        /* bit で表される集合の処理を書く */
        // bit の表す集合を求める
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {  // i が bit に入るかどうか
                S.push_back(i);
            }
        }

    //    cout << "DEGUG S" << endl;
    //    debugV(S);

        REP(i, m) {  // 各電球ごと
            int ONcnt = 0;
            REP(jj, k[i]) {          //各電球のすいっち
                REP(kk, S.size()) {  // ONの個数
                    if (S[kk] == s[i][jj]-1){
                        ONcnt++;
             //           cout << kk<<"'s on" <<endl ;
                    }
                        
                }
            }
         //   cout << i << ",on=" << ONcnt << endl;
            if (ONcnt % 2 != p[i])
                break;
            if (i == m - 1) {
                ans++;
            //    cout << "itisOK" << endl;
            }
        }
    }

    cout << ans << endl;

    // debugVV(s);

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
c1 = 0
c2 = 2
p,q,r,s = a[0],0,a[1]+a[2],a[3..-1].inject(:+)
ans = 10**9
for i in 1..n-3
  q += a[i]
  r -= a[i]
  while c1+1 < i && (q-p).abs > (p+2*a[c1+1]-q).abs
    c1 += 1
    p += a[c1]
    q -= a[c1]
  end
  while (r-s).abs > (r+2*a[c2+1]-s).abs && c2+1 < n-1
    c2 += 1
    r += a[c2]
    s -= a[c2]
  end
  temp = [p,q,r,s]
  ans = [ans,temp.max-temp.min].min
end
puts ans

Measured memory_bytes: 21908
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	const ll MOD = 1e9 + 7;
	ll N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	vector<ll> v(N + 1);
	vector<ll> vi(N + 1);
	vector<ll> inv(N + 1);
	for (int i = 0; i <= N; ++i) {
		if (i < 2) {
			v[i] = 1;
			vi[i] = 1;
			inv[i] = 1;
		} else {
			inv[i] = (-MOD / i) * inv[MOD % i] % MOD;
			v[i] = v[i - 1] * i % MOD;
			vi[i] = vi[i - 1] * inv[i] % MOD;
		}
	}
	vector<vector<ll>> dp(B + 1, vector<ll>(N + 1, 0));
	dp[A - 1][0] = 1;
	for (int i = A; i <= B; ++i) {
		for (int j = 0; j <= N; ++j) {
			if (dp[i - 1][j] == 0) { continue; }
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;

			ll tmp = 1;
			for (int k = 1; (k <= D) && (j + i*k <= N); ++k) {
				int key = N - j - i*(k - 1);
				tmp = tmp * v[key] % MOD * vi[i] % MOD * vi[key - i] % MOD * inv[k] % MOD;
				if (k >= C) {
					dp[i][j + i*k] = (dp[i][j + i*k] + dp[i - 1][j]*tmp + MOD) % MOD;
				}
			}
		}
	}

	ll res = (dp[B][N] + MOD) % MOD;
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int arr[5], z=-1;
  for(int i=0; i<5; i++){
    cin>>arr[i];
    if(arr[i]== 0){
      z = i+1;
    	break;
    }
  }
  cout<<z;
  return 0;
}

Measured memory_bytes: 3556
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N;
    cin >> N;
    vector<char> c(N);
    rep(i,0,N) cin >> c[i];
    int left = 0;
    int right = N-1;
    int ans = 0;
    while (true) {
        if (right <= left) break;
        while (c[left] == 'R') {
            left++;
            if (left == N) break;
        }
        while (c[right] == 'W') {
            right--;
            if (right == 0) break;
        }
        if (right <= left) break;
        ans++;
        c[left] = 'R';
        c[right] = 'W';
        left++;
        right--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n,K;
    R(n,K);
    VI AA(n+1);
    FOR(i,1,n){
        R(AA[i]);
        AA[i]--;
    }
    LL an=0;
    map<int,int>ker;
    ker[0]++;
    int now=0;
    int now2=0;
    FOR(i,1,n){
        if(i-K>=0){
            now2=(now2+AA[i-K])%K;
            ker[now2]--;
        }
        now=(now+AA[i])%K;
        an+=ker[now];
        ker[now]++;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>

int main(){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  
  if(A==B){
    printf("%d",C);
  }else if(B==C){
    printf("%d",A);
  }else{
    printf("%d",B);
  }
}

Measured memory_bytes: 128
n1 = list(map(int, input().split()))
n2 = (n1[1] - 1)//(n1[0] - 1)
n3 = (n1[1] - 1)%(n1[0] - 1)
if n3 > 0:
    a1 = n2 + 1
else:
    a1 = n2
print(a1)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	//fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// Priority Queue
type Item struct {
	priority, index int
}

type PQ []*Item

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

// Priority Queue

type PQ2 []*Item

func (pq PQ2) Len() int {
	return len(pq)
}

func (pq PQ2) Less(i, j int) bool {
	return pq[i].priority > pq[j].priority
}

func (pq PQ2) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PQ2) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PQ2) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([]int, N*3)
	for i := 0; i < N*3; i++ {
		a[i] = getInt()
	}

	out(N, a)

	pqf := make(PQ, 0)
	pqt := make(PQ2, 0)
	heap.Init(&pqf)
	heap.Init(&pqt)
	f := 0
	t := 0
	for i := 0; i < N; i++ {
		heap.Push(&pqf, &Item{a[i], 0})
		heap.Push(&pqt, &Item{a[3*N-1-i], 0})
		f += a[i]
		t += a[3*N-1-i]
	}

	nf := make([]int, N+1)
	nt := make([]int, N+1)
	nf[0] = f
	nt[0] = t
	for i := 0; i < N; i++ {
		f += a[N+i]
		heap.Push(&pqf, &Item{a[N+i], 0})
		item := heap.Pop(&pqf).(*Item)
		out("front", item.priority)
		f -= item.priority
		nf[i+1] = f

		t += a[2*N-1-i]
		heap.Push(&pqt, &Item{a[2*N-1-i], 0})
		item = heap.Pop(&pqt).(*Item)
		out("tail", item.priority)
		t -= item.priority
		nt[i+1] = t
	}

	out(nf)
	out(nt)

	ma := -(math.MaxInt64 >> 4)
	for i := 0; i <= N; i++ {
		d := nf[i] - nt[N-i]
		if d > ma {
			ma = d
		}
	}
	fmt.Println(ma)
}


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

using ll = long long int;

int solve(){
    int K, S;
    cin >> K >> S;
    vector<vector<ll> > dp(4,vector<ll>(S+2));
    dp[0][0] = 1;
    for(int i=0;i<3;i++){
        for(int j=0;j<=S;j++){
            dp[i][j+1] += dp[i][j];
            if(j <= K) dp[i+1][j] += dp[i][j];
            else dp[i+1][j] += dp[i][j] - dp[i][j-K-1];
        }
    }
    cout << dp[3][S] << endl;
    return 0;
}

int main(){
    solve();
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int n,x; scanf("%d%d",&n,&x);
   vector<int> a(n); rep(i,0,n)scanf("%d",&a[i]);
   int g=a[0]; rep(i,1,n)g=__gcd(g,a[i]);
   if(x%g!=0||*max_element(ALL(a))<x)puts("IMPOSSIBLE");
   else puts("POSSIBLE");
   return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a;
    a.push_back(1);
    ll c = 1;
    for(ll i = 1; i <= 100; i++){
        c*=6; a.push_back(c);
        if(c*6>100000) break;
    }
    c = 1;
    for(ll i = 1; i <= 100; i++){
        c*=9; a.push_back(c);
        if(c*9>100000) break;
    }
    sort(a.begin(), a.end());
    vector<ll> ans(100030, 1e+6);
    for(ll i = 1; i <= 100000; i++)
        ans[i] = i;
    for(ll i = 1; i < a.size(); i++){
        ans[a[i]] = 1;
        for(ll j = a[i]; j <= 100000; j++){
            ans[j] = min(ans[j], min(ans[j-1]+1, ans[j-a[i]]+1));
        }
    }
      cout << ans[n] << endl;
    return 0;
}


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

int main()
{   
    int n;
    cin>>n;
    string s;
    cin>>s;
    int max=0;
    int x=0;
    
    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            x++;
            if(max<x) max=x;
        }
        if(s[i]=='D') x--;
    }

    cout<<max<<endl;
    
}

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

int main(void){
    
    ll n, ans=0, tmp=0;
    ll a, b;
    map<ll, ll> m;
    
    cin >> n;
    
    for(ll i=1; i<=n; i++){
        
        cin >> a;
        b = a - i;
        tmp = b;
        
        if(m.count(tmp)!=0){
            
            ans += m.at(tmp);
            
        }
        
        tmp = 0 - b - 2 * i;
        m[tmp] += 1;
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 16096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;


 
int main () {
	llint n, k, size = 0, start = 1;
	cin>>n>>k;
	vector <llint> v(n + 1);
	loop(i, n) cin>>v[i+1];
	bool vis[n+1];
	memset(vis, 0, sizeof(vis));
	stack <llint> s;
	vis[1] = 1;
	llint vn[n+1];
	memset(vn, 0, sizeof(vn));
	s.push(1);
	vn[1] = 1;
	while(!s.empty()){
		k--;
		llint x = s.top();
		s.pop();
		if(k == 0){ start = v[x]; break; }
		if(!vis[v[x]]) { s.push(v[x]); vn[v[x]] = vn[x] + 1; vis[v[x]] = 1;}
		else { size = vn[x] - vn[v[x]]; start = v[x]; }
	}
	k = k % (size + 1);
	//k--;
	//debug(k);
	llint ans= -1;
	while(k--){
		ans = v[start];
		start = ans;
	}
	cout<<start;
	return 0;
}


Measured memory_bytes: 6696
#include <stdio.h>
int main(void){
  int n,a,i;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&a);
    if (a%2){
      printf("first");
      return 0;
    }
  }
  printf("second");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS



    int n;
    cin >> n;

    vector<int> v(n);

    for(int i = 0; i < n; i++)
    {
      cin >> v[i];
    }

    sort(all(v));

    int ans = 0;

    for(int i = 0; i < n; i++)
    {
      for(int j = i + 1; j < n; j++)
      {
        for(int k = j+1; k < n; k++)
        {
          if(v[i] != v[j] and v[j] != v[k] and v[i] != v[k])
          {
            if(v[i] + v[j] > v[k])ans++;
          }
        }
      }
    }

    cout << ans ;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
using namespace std;
int main() 
{
  int a, b, c, k; cin >> a>> b >> c >> k;
  int ans = 0;
  ans += min(k, a);
  k -= min(k, a);
  k -= min(k, b);
  ans -= min(k, c);
  cout << ans << endl;
}

Measured memory_bytes: 3164
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int r;

    cin >> r;
    cout << r * r << endl;

    return 0;
}

Measured memory_bytes: 256
# 数字を取得
A,B = map(int,input().split())

# 比較条件に沿ったメッセージを出力
if A == B:
  print("Draw")
else:
  if B != 1 and A > B\
  or A == 1:
    print("Alice")
  else:
    print("Bob")

Measured memory_bytes: 9068
// "header" {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,W;
    cin >> N >> W;

    vector<int> w(N+1),v(N+1);
    vector<vector<int> > dp(N+1,vector<int>(1e3 * N+1,LINF));

    reps(i,N){
        cin >> w[i] >> v[i];
    }
    dp[0][0] = 0;

    reps(i,N){
        dp[i][0] = 0;
        reps(j,1e3 * N){
            if(j - v[i] >= 0) dp[i][j] = min({dp[i-1][j-v[i]] + w[i],dp[i-1][j]});
            else dp[i][j] = dp[i-1][j]; 
        }
    }

    for(int i = 1e3 * N;i >= 0;--i){
        if(dp[N][i] <= W) return cout << i << '\n',0;
    }

    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示
#include <map>
#include<set>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

#define MAX_N 50005//ここにNの最大値を入れる
#define MAX_K 100005



template<class T> inline bool chmax(T & a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmin(T & a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
long double a, b , h, m;

int main() {
    cin >> a >> b >> h >> m;
    cout << fixed << setprecision(15);
    long double s = 2.0 * PI * m / 60.0 - (2.0 * PI *h / 12.0 + 2.0 * PI / 12.0 * m / 60.0);
    
    if (s > PI) s = 2.0 * PI - s;

    cout << sqrt(a*a+ b*b - 2 * a * b * cos(s)) << endl;
    return 0;

}

Measured memory_bytes: 4156
H, W = map(int, input().split())

def solve(H, W):
    if H % 3 == 0 or W % 3 == 0:
        return 0
    # 横３分割または縦３分割
    record = min(H, W)

    #  ##&
    #  **&
    # (H // 2) * x
    # (H - H // 2) * x
    # (W - x) * H
    
    
    xt = (W // 3) * 2
    for x in range(max(1, xt - 100), min(W, xt + 100)):
        a1 = (H//2) * x
        a2 = H * x - a1
        a3 = (W - x) * H
        dif = max(a1, a2, a3) - min(a1, a2, a3)
        if dif < record:
            record = dif
    
    H, W = W, H
    xt = (W // 3) * 2
    for x in range(max(1, xt - 100), min(W, xt + 100)):
        a1 = (H//2) * x
        a2 = H * x - a1
        a3 = (W - x) * H
        dif = max(a1, a2, a3) - min(a1, a2, a3)
        if dif < record:
            record = dif
    
    return record

print(solve(H, W))

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

char S[4]; 
int main(){
	cin >> S[0] >> S[1] >> S[2];
	if(S[0] == S[1] || S[0] == S[2] || S[1] == S[2]){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}

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

const int MAX_N = 1 << 17;
int dat[MAX_N * 2 - 1];
int n;

void init(int _n){
    n = 1;
    while(n < _n){
        n *= 2;
    }
    for(int i = 0; i < 2 * n - 1; i++){
        dat[i] = INT_MAX;
    }
}

void update(int k, int a){
    k += n - 1;
    dat[k] = a;
    //cout << dat[k] << ", " << k << endl;
    while(k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
    }
}

int query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l){
        return INT_MAX;
    }
    if(a <= l && r <= b){
        return dat[k];
    }
    int vl = query(a, b, 2 * k + 1, l, (l + r)/2);
    int vr = query(a, b, 2 * k + 2, (l + r)/2, r);
    return min(vl, vr);
}
int main(void){
    // Your code here!
    int N;
    int q;
    cin >> N >> q;
    
    init(N);
    for(int i = 0; i < q; i++){
        int com;
        int x;
        int y;
        cin >> com >> x >> y;
        if(com == 0){
            update(x, y);
        } else {
            cout << query(x, y + 1, 0, 0, n) << endl;
        }
    }
    //for(int i = 0; i < 2 * n - 1; i++){
    //    cout << dat[i] << endl;
    //}
    
}



Measured memory_bytes: 4120
#include <bits/stdc++.h>
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 INF 2e9
#define ll long long

string s;
ll dp[100001][13];

int main(){

    cin>>s;
    ll n = s.length();
    ll i, j, k;
    ll ans = 0;


    dp[0][0] = 1;

    //上の桁から見ていく
    for(i=0; i<n; i++){
        int c;
        if(s[i] == '?'){
            c = -1;
        }
        else{
            c = s[i] - '0';
        }

        for(j=0; j<10; j++){
            if(c != -1 && c != j){
                continue;
            }
            for(k=0; k<13; k++){
                dp[i+1][(k*10+j)%13] += dp[i][k];
            }
        }
        for(j=0; j<13; j++){
            dp[i+1][j] %= 1000000007;
        }
    }

    ans = dp[n][5];

    cout<<ans<<endl;


    return 0;
    
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef long long int ll;
typedef long double ld;
using namespace std;
const int M=1e9+7;
#include<iostream> 
#include<climits> 
using namespace std; 
int main() {
    ios;
  ll h,n;cin>>h>>n;
  ll s=0;
  for(ll i=0;i<n;++i)
  {
      ll x;cin>>x;
      s+=x;
  }
  if(s>=h)
  cout<<"Yes";
  else
  cout<<"No";
}

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

typedef long long ll;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)
#define MOD 100000007LL

ll f[2][100010];
int idx[] = {1,0,0,0,0,0,0,0,1,0};

void mkF(){
  memset(f,0,sizeof(f));

  REP(i,1,100001){
    f[0][i]++;
    rep(j,5){
      if(i - j - 1 < 0) continue;
      f[0][i] += f[0][i - j - 1];
      f[0][i] %= MOD;
    }

    f[1][i]++;
    rep(j,3){
      if(i - j - 1 < 0) continue;
      f[1][i] += f[1][i - j - 1];
      f[1][i] %= MOD;
    }
  }
}

int main(){
  string s;

  mkF();

  while(cin>>s, s != "#"){
    int i = 0;
    int n = s.length();
    ll res = 1;

    while(i < n){
      int tmp = i;
      while(i + 1 < n && s[i] == s[i + 1]) i++;
      res *= f[ idx[s[i] - '0'] ][ i - tmp + 1 ];
      res %= MOD;
      i++;
    }

    cout<<res<<endl;
  }
}

Measured memory_bytes: 2704
#include <iostream>
#include <iterator>
#include <array>
#include <set>
#include <algorithm>
#include <string>
#include <limits>
#include <cmath>

using namespace std;

int main()
{
  // skip the first line
  //cin.ignore(numeric_limits<streamsize>::max(), '\n');

  int m, f, r;
  while (cin >> m >> f >> r, (m != -1 or f != -1 or r != -1)) {
    if (m == -1 or f == -1) {
      cout << "F" << endl;
      continue;
    }
    m = max(m, 0);
    f = max(f, 0);
    r = max(r, 0);
    if (m + f >= 80)
      cout << "A";
    else if (m+f >= 65 and m+f <80)
      cout << "B";
    else if (m+f >= 50 and m+f <65)
      cout << "C";
    else if (m+f >= 30 and m+f <50)
      cout << ((r >= 50) ? "C" : "D");
    else
      cout << "F";
    cout << endl;
  }
}



Measured memory_bytes: 3064
import heapq

n = input()
v = input()
v = v.split()
c = input()
c = c.split()

VSubC = []

for index in range(int(n)):
  heapq.heappush(VSubC, -(int(v[index]) - int(c[index])))

answer = 0
while(len(VSubC) > 0):
  item = heapq.heappop(VSubC)
  if (item < 0):
    answer -= item
  else:
    break

print(answer)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

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

        int N = Integer.parseInt(sc.next());
        int[] L = new int[N];
        int max;
        int tmp = 0;

        for (int i = 0; i < N; i++) {
            L[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(L);

        max = L[L.length - 1];
        for (int i = 0; i < N-1; i++) {
           tmp += L[i];
        }

        if (max < tmp) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 21844
using System;
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            UInt64 a = UInt64.Parse(Console.ReadLine());

            UInt64 b = (UInt64)Math.Pow(10, 18);

            Double c = 100;

            UInt64 i = 1;

            while(c <= b)
            {
                c = Math.Floor(c* 1.01);

                if (c >= a)
                {
                    //出力
                    Console.WriteLine(i);
                    break;
                }

                i++;
            }
        }
    }

Measured memory_bytes: 27928
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
string s;
ll fun() {
	ll ans = 0, cnt = 1;
	for(int i = 1; i < s.length(); i++) {
		if(s[i] == s[i-1]) cnt++;
		else ans += cnt/2, cnt = 1;
	}
	ans += cnt/2;
	return ans;
}
bool check() {
	char c = s[0];
	for(int i = 0; i < s.length(); i++) {
		if(s[i] != c) return 0;
	}
	return 1;
}
int main() {
	cin >> s;
	int k, cnt = 0;
	cin >> k;
	if(check()) {cout << s.length()*k*1LL/2; return 0;}
	ll ans = fun();
	while(s.front() == s.back()) {
		s += s.front();
		s.erase(s.begin());
	}
	ans += fun()*(k-1);
	cout << ans << endl;
}

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

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

    int cnt = 0;
    int sum = 0;
    for (int i = 0; i <= A; i++) {
        sum = 500 * i;
        if (sum > X) {
            break;
        }
        for (int j = 0; j <= B; j++) {
            sum = (500 * i + 100 * j);
            if (sum > X) {
                break;
            }

            if ((X - sum) / 50 <= C) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3604