akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <algorithm>
#define SIZE 100005

   struct wierzcholek {
       int in,dist;
       std::vector <int> pol;
       bool vis;
   };

   wierzcholek graph[SIZE];
   void dfs(int s) {
        graph[s].vis = true;

        for(int el : graph[s].pol) {
                graph[el].dist = std::max(graph[el].dist, graph[s].dist+1);
                graph[el].in--;
                if(!graph[el].in) dfs(el);
        }
   }

   int main(void) {
        int n,m;
        scanf("%d %d",&n,&m);

        while(m--) {
            int x,y;
            scanf("%d %d",&x,&y);
            graph[x].pol.push_back(y);
            graph[y].in++;
        }

        for(int i=1; i<=n; i++) {
                if(graph[i].vis || graph[i].in) continue;

                dfs(i);
        }
        int ans=0;
        for(int i=1; i<=n; i++) ans = std::max(ans, graph[i].dist);

        printf("%d",ans);
        return 0;
   }




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

int main(){
    string in;
    char ch[2] = {'o', 'x'};
    while( cin >> in ){
        bool found = false;
        for( int i=0; i<2; i++ ){
            // 縦
            for( int x=0; x<3; x++ ){
                if( in[x] == ch[i] && in[x] == in[x+3] && in[x] == in[x+6] ){
                    cout << ch[i] << endl;
                    found = true;
                }
            }
            // 横
            for( int y=0; y<3; y++ ){
                if( in[y*3] == ch[i] && in[y*3+1] == ch[i] && in[y*3+2] == ch[i] ){
                    cout << ch[i] << endl;
                    found = true;
                }
            }
            // 斜
            if( ch[i] == in[0] && ch[i] == in[4] && ch[i] == in[8] ){
                cout << ch[i] << endl;
                found = true;
            }
            if( ch[i] == in[2] && ch[i] == in[4] && ch[i] == in[6] ){
                cout << ch[i] << endl;
                found = true;
            }
        }
        if( !found ){
            cout << 'd' << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class DKnapsack1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int W = in.nextInt();
            long[] dp = new long[W + 1];
            for (int i = 1; i <= N; i++) {
                int wi = in.nextInt();
                long vi = in.nextInt();
                for (int j = W - wi; j >= 0; j--) {
                    dp[j + wi] = Math.max(dp[j + wi], dp[j] + vi);
                }
            }
            long ans = 0;
            for (int i = 0; i <= W; i++) {
                ans = Math.max(dp[i], ans);
            }
            out.print(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 23124
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for(int i=0;i<n;i++){
			String s = sc.next();
			double a = Double.valueOf(s.substring(0, 2));
			double b = Double.valueOf(s.substring(3, 5));
			double x = a*30 + b/2;
			double y = b*6;
			double z = Math.abs(x-y);
			if(z>180) z = 360-z;
			if(z<30) System.out.println("alert");
			else if(z>=90 && z<=180) System.out.println("safe");
			else System.out.println("warning");	
		}
	}	
}

Measured memory_bytes: 21128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nh = Input.ar;
        var ab = Input.twodim(nh[0]);
        ab = ab.OrderByDescending(v => v[1]).ToArray();
        var max = ab.Max(ar => ar[0]);
        var res = 0;
        for(var i = 0; i < nh[0]; i++)
        {
            if (nh[1] == 0||max > ab[i][1])
                break;
            nh[1] = Max(nh[1] - ab[i][1], 0);
            res++;
        }
        WriteLine((nh[1] + max - 1) / max + res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 28232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define END(a) {cout << (a) << "\n"; return 0;}
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

struct edge {
    int from, to; ll cost;
    edge(int s, int t, ll w = 0) : from(s), to(t), cost(w) {}
};

int main() {
    init();

    int n, m; ll l; cin >> n >> m >> l;
    vector<vector<edge>> g(n);
    vector<VL> dis(n, VL(n, LLINF));
    FOR(i, 0, n)dis[i][i] = 0;
    FOR(i, 0, m) {
        int a, b; ll c; cin >> a >> b >> c;
        --a, --b;
        g[a].push_back(edge(a, b, c));
        g[b].push_back(edge(b, a, c));
        dis[a][b] = c;
        dis[b][a] = c;
    }

    FOR(k, 0, n)FOR(i, 0, n)FOR(j, 0, n) {
        chmin(dis[i][j], dis[i][k] + dis[k][j]);
    }
    
    g.clear(); g.resize(n);
    FOR(i, 0, n)FOR(j, 0, n) {
        if (i == j)continue;
        if (dis[i][j] <= l) {
            g[i].push_back(edge(i, j, 1));
            g[j].push_back(edge(j, i, 1)); 
            dis[i][j] = 1;
            dis[j][i] = 1;
        }
        else {
            dis[i][j] = LLINF;
            dis[j][i] = LLINF;
        }
    }

    FOR(k, 0, n)FOR(i, 0, n)FOR(j, 0, n) {
        chmin(dis[i][j], dis[i][k] + dis[k][j]);
    }

    int q; cin >> q;
    while (q--) {
        int s, t; cin >> s >> t;
        --s, --t;
        cout << (dis[s][t] == LLINF ? -1 : dis[s][t] - 1) << "\n";
    }
}

Measured memory_bytes: 5720
from collections import deque
import sys
input = sys.stdin.readline


def main():
    N, M, P = map(int, input().split())
    edge = [[] for _ in range(N)]
    redge = [[] for _ in range(N)]
    for _ in range(M):
        A, B, C = map(int, input().split())
        A -= 1
        B -= 1
        C -= P
        C = -C
        edge[A].append((B,C))
        redge[B].append(A)

    # 0 => N-1の間にある閉路を検出したいので
    # 0とN-1からたどりつけない場所は前処理で取り除く
    
    visited1, visited2 = {0}, {N-1}
    
    stack = [0]
    while stack:
        v = stack.pop()
        for dest, _ in edge[v]:
            if dest in visited1:
                continue
            visited1.add(dest)
            stack.append(dest)
    
    stack = [N-1]
    while stack:
        v = stack.pop()
        for dest in redge[v]:
            if dest in visited2:
                continue
            visited2.add(dest)
            stack.append(dest)
    
    OK = visited1 & visited2
    
    new_edge = [[] for _ in range(N)]
    for s in range(N):
        for t, c in edge[s]:
            if t in OK:
                new_edge[s].append((t,c))

    flag = True
    d = [float('inf')] * N
    d[0] = 0
    #ベルマンフォード法、N回実行してまだ更新されている場合は負の閉路が存在する
    for _ in range(N):
        flag = False
        for v, e in enumerate(new_edge):
            for t, c in e:
                if d[v] != float('inf') and d[v] + c < d[t]:
                    d[t] = d[v] + c
                    flag = True
        if not flag:
            print(max(0,-d[N-1]))
            exit()
    else:
        print(-1)
        exit()


if __name__ == "__main__":
    main()

Measured memory_bytes: 54748
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define REP(i,a,b) for(int i = a; i < b; i++)

int main(int argc, char *argv[]) {
    int n;
    scanf("%d", &n);
    char s[n][30];
    REP(i, 0, n) {
        scanf("%s", s[i]);
    }
    int count = 0, ew[30];
    REP(i, 0, 30) {
        ew[i] = 0;
    }
    REP(i, 0, n) {
        ew[(int)s[i][0] - 71]++;
    }
    REP(i, 0, 30) {
        if (ew[i] > 0) {
            count++;
        }
    }
    printf(count == 4 ? "Four\n" : "Three\n");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <time.h>
#include<stdlib.h>
#include<string.h>

int main(void){
	int l1, l2;
	char a[11], b[11], c[11];

	scanf("%s %s %s", a, b, c);

	l1 = strlen(a) - 1;
	l2 = strlen(b) - 1;

	if (a[l1] == b[0] && b[l2] == c[0]) {
		printf("YES");
	}
	else {
		printf("NO");
	}
}

Measured memory_bytes: 1720
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
#define SQR(n) (n*n)
#define CHR getchar()
#define NL printf("\n")
#define PI 2.0*acos(0.0)
#define ll              long long int
#define ull             unsigned long long int
#define sc              scanf
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define pf              printf
#define MOD             1000000007
#define mx              123456789
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ff first
#define D double
#define sz size()
#define ss second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
using namespace std;
int countFreq(string &pat, string &txt)
{
    int M = pat.length();
    int N = txt.length();
    int res = 0;
    for (int i = 0; i <= N - M; i++)
    {
        int j;
        for (j = 0; j < M; j++)
            if (txt[i+j] != pat[j])
                break;
        if (j == M)
        {
           res++;
           j = 0;
        }
    }
    return res;
}
int main()
{
   string s, s1;
   ll n;
   cin>>n;
   cin>>s;
   s1="ABC";
   cout << countFreq(s1,s)<<endl;
   return 0;
}


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

int main()
{
    ////////////////////////////////////////////////
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	cout.tie(NULL);
 	
    ////////////////////////////////////////////////
    
    ll t{},n{};
    string p;
    cin>>t>>n;
    std::vector<string> v(t) ;
    for(int i=0;i<t;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0;i<t;i++){
        cout<<v[i];
    }
    cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll N,S;
    cin>>N>>S;
    ll X[N];
    ll P[N];
    for(ll i=0; i<N; i++){
        cin>>X[i]>>P[i];
    }

    bool check1 = true;
    bool check2 = true;
    for(int i=0; i<N; i++){
        if(X[i]>S)
            check1 = false;
    }
    for(int i=0; i<N; i++){
        if(X[i]<S)
            check2 = false;
    }
    if(check1||check2){
        cout<<max(abs(S-X[0]),abs(S-X[N-1]))<<endl;
    }
    else{

    ll left = 0;
    ll right = N-1;
    ll pos=-1;
    ll newpos=-1;
    ll ans = 0;

    bool check = false;
    while(!check){
        if(P[left]>=P[right]){
            P[left]+=P[right];
            newpos = X[right];
            if(pos>=0)
                ans+=abs(pos-newpos);
            pos = X[right];
            right--;
        }
        else{
            P[right]+=P[left];
            newpos = X[left];
            if(pos>=0)
                ans+=abs(pos-newpos);
            pos = X[left];
            left++;
        }
        if(X[left]>S||X[right]<S)
            check = true;
    }
    if(X[left]>S){
        ans+=abs(pos-X[right]);
        ans+=abs(S-X[right]);
    }

    else{
        ans+=abs(pos-X[left]);
        ans+=abs(S-X[left]);
    }
    cout<<ans<<endl;

    }

    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
public class Program {
    static void Main (string[] args) {
        var n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        int[] t = a.ToArray();
        Array.Sort(t);
        var m = (int)((n+1) / 2) - 1;
        for (int i = 0; i < n; ++i) {
            if (a[i] <= t[m]) {
                Console.WriteLine(t[m+1]);
            } else {
                Console.WriteLine(t[m]);
            }
        }
    }
}

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



int main(){
	string s;
	cin >> s;
	if (s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I') {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
		return 0;
	}
}

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

typedef long long int ll;

int main(){
    int n , l; cin >> n >> l;
    int arr[n+5];
    int sum = 0;
    for(int i = 1; i <= n; i++){
        arr[i] = l+i-1;
        sum+=arr[i];
    }
    int ans = sum - arr[1];
    int pre = abs(arr[1]);
    for(int i = 2; i <= n; i++){
        if(abs(arr[i]) < pre){
            ans = sum - arr[i];
            pre = abs(arr[i]);
        }
    }
    cout << ans << '\n';
}

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

int main(){
    int ac=0,wa=0,tle=0,re=0;
    int n;
    
    cin>>n;
    rep(i,n){
        string s;
        cin >>s;
        if(s=="AC")ac++;
        else if(s=="WA")wa++;
        else if(s=="TLE")tle++;
        else if (s=="RE")re++;
    }
    
    cout <<"AC x "<<ac<<endl;
    cout <<"WA x "<<wa<<endl;
    cout <<"TLE x "<<tle<<endl;
    cout <<"RE x "<<re<<endl;
}



Measured memory_bytes: 3644
import string
import collections

n = int(input())
d = dict(zip(list(string.ascii_lowercase), [50]*26))
# print(d)

for _ in range(n):
    c = collections.Counter(input())
    for a in list(string.ascii_lowercase):
        d[a] = min(d[a], c[a])

ans = ''
for a in list(string.ascii_lowercase):
    ans += a * d[a]

print(ans)


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

string ss, t;
bool can(int pos)
{
	for(int cnt=0; cnt<t.size(); cnt++)
	{
		if(ss[pos+cnt]!='?'&&ss[pos+cnt]!=t[cnt]) return false;
	}
	
	return true;
}

void mainp()
{
	cin>>ss>>t;
	string ans;
	bool fl=0;
	string s;
	for(int i=0; i<ss.size()-t.size()+1; i++)
	{
		s=ss;
		if(can(i))
		{
			for(int cnt=0; cnt<t.size(); cnt++) s[i+cnt]=t[cnt];
			for(int j=0; j<ss.size(); j++) if(s[j]=='?') s[j]='a';
			
			if(fl==0) {ans=s; fl=1;}
			else ans=min(ans, s);
		}
	}
	
	if(fl) cout<<ans<<endl;
	else cout<<"UNRESTORABLE"<<endl;
}

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

	mainp();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
	const int N=10;
	int height[N];
	for(int i=0;i<10;i++){
		scanf("%d",&height[i]);
	}
	sort(height,height+N);
	reverse(height,height+N);
	for(int j=0;j<3;j++){
		printf("%d\n",height[j]);
	}
	return 0;
}

Measured memory_bytes: 1044
//
// Binary Indexed Tree
//
// verified:
//   AOJ Course DSL_2_A Range Query - Range Minimum Query (RMQ)
//     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
//

/*
    RMQ(n, inf): サイズ n に初期化、無限大の値を inf とする
    init(n): サイズ n に初期化
    set(a, v): a 番目の値を v にセットする
    build(): set した値を元にセグメントツリー全体を構築する、O(n)
    
    update(a, v): a 番目の値を v に更新する, O(log n)
    get(a, b): 区間 [a, b) の (最小値, 最小値をとる index) を返す, O(log n)
*/


#include <iostream>
#include <vector>
using namespace std;


template<class Monoid> struct RMQ {
    const Monoid INF;
    int SIZE_R;
    vector<pair<Monoid,int> > dat;
    
    RMQ(int n, const Monoid &inf): INF(inf) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, pair<Monoid,int>(INF, -1));
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = make_pair(v, a); }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k) {
            dat[k] = min(dat[k*2], dat[k*2+1]);
        }
    }
    
    /* update, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = make_pair(v, a);
        while (k >>= 1) dat[k] = min(dat[k*2], dat[k*2+1]);
    }
    
    /* get {min-value, min-index}, a and b are 0-indexed */
    pair<Monoid,int> get(int a, int b) {
        pair<Monoid,int> vleft = make_pair(INF, -1), vright = make_pair(INF, -1);
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = min(vleft, dat[left++]);
            if (right & 1) vright = min(dat[--right], vright);
        }
        return min(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R].first; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            Monoid val = (*this)[i];
            if (val < INF) cout << val;
            else cout << "INF";
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};



int main() {
    int N, Q; cin >> N >> Q;
    RMQ<int> rmq(N, 2147483647);
    for (int query = 0; query < Q; ++query) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) rmq.update(x, y);
        else cout << rmq.get(x, y+1).first << endl;
    }
}



Measured memory_bytes: 4936
#include <stdio.h>
int face[7][7][4] = {
    {{0},{0},{0},{0},{0},{0},{0}},
    {{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
    {{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
    {{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
    {{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
    {{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
    {{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int dice[7];
int dice2[7];

int main(){
    int i,j,true=0;
    int n;scanf("%d",&n);
    for(i=1;i<=6;i++) scanf("%d",&dice[i]);
    
    while(n-1){
        for(i=1;i<=6;i++) scanf("%d",&dice2[i]);
        
        for(i=1;i<=6;i++)
            for(j=1;j<=6;j++)
                if(dice[face[i][j][1]]==dice2[1]&&
                   dice[face[i][j][2]]==dice2[2]&&
                   dice[face[i][j][3]]==dice2[3]&&
                   dice[7-face[i][j][3]]==dice2[4]&&
                   dice[7-face[i][j][2]]==dice2[5]&&
                   dice[7-face[i][j][1]]==dice2[6])
                    true++;
        n--;
    }
    if(true==n-1)
        printf("Yes\n");
    else
        printf("No\n");
    
}


Measured memory_bytes: 2128
/*
*@Author  Chand Vachhani
*/

#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define vi          vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define mii         map<int,int>
#define pb          push_back
#define pf          push_front
#define mp(a,b)          make_pair((a),(b))
#define vpii        vector<pair<int,int>>
#define fo(i,l,n)   for(int i{l}; i<n; i++)
#define rf(s)       for(auto &c : s)
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define PI          3.141592653589
#define sz(x)       (int)x.size()
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007  

using namespace std;

signed main(){
    tezz
   
   int n;
   cin >> n;
   double p;
   vector<double> a;
   fo(i,0,n){
       cin >> p;
       a.pb(p);
   }
   double dp[n+1][n+1];
   memset(dp,0,sizeof(dp));
   dp[0][0]=1-a[0];
   dp[0][1]=a[0];
   fo(i,1,n){
       dp[i][0]=dp[i-1][0]*(1-a[i]);
       fo(j,1,i+2){
           dp[i][j]=dp[i-1][j-1]*a[i] + dp[i-1][j]*(1-a[i]);
       }
   }
//   fo(i,0,n+1){
//       fo(j,0,n+1){
//           cout << dp[i][j] <<" ";
//       }
//       cout << endl;
//   }
   double ans=0;
   fo(i,(n/2)+1,n+1){ans+=dp[n-1][i];}
   cout <<setprecision(15)<< ans;
    return 0;
}

Measured memory_bytes: 141056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define E(x)        return writeln(x),0
#define LL          (long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)   printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue       puts("\nGuYueNa________________________________________________________________________________")
#define y1          fafa____
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*SS=SZB,*TT=SZB;
    inline char gc(){   if (SS==TT){  TT=(SS=SZB)+fread(SZB,1,GYN,stdin); if (SS==TT) return '\n';  }   return *SS++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);puts("");}
    void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);puts("");}
    void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);puts("");}
    void writeln(ll x){write(x),puts("");}
    void Max(ll &x,ll y){x=x<y?y:x;}
    void Min(ll &x,ll y){x=x>y?y:x;}
    ll min(ll x,ll y){return x<y?x:y;}
}using namespace SHENZHEBEI;
const ll N=200005;
ll n,a[N],b,ans;
int main(){
	n=read();
	For(i,1,n) a[i]=read()-i;
	sort(a+1,a+1+n);
	b=a[(n+1)/2];
	For(i,1,n)ans+=abs(a[i]-b);
	printf("%lld\n",ans);
}

Measured memory_bytes: 3712
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for i in range(N):
    count+=min(A[i],B[i])
    if A[i]<B[i]:
        if A[i+1]<B[i]-A[i]:
            count+=A[i+1]
            A[i+1]=0
        else:
            count+=B[i]-A[i]
            A[i+1]-=B[i]-A[i]
print(count)


Measured memory_bytes: 97808
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define sc(m) scanf("%d",&m);
#define sc(k) scanf("%d",&k);
#define sc(test) scanf("%d",&test);
#define scl(m) scanf("%lld",&m);
#define scd(m) scanf("%lf",&m);
#define pf(res) printf("%d",res);
#define pfl(res) printf("%lld",res);
#define pfd(res) printf("%lf",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];

int main()
{
    int a;
    cin>>a;
    int p=a%10;
    if(p==2 ||p==4 ||p==5 ||p==7 ||p==9 )
    {
        cout<<"hon";
    }
    else if(p==0 ||p==1 ||p==6 ||p==8 )
    {
        cout<<"pon";
    }
    else cout<<"bon";

}





Measured memory_bytes: 3620
Program Catcoder1;
//uses crt;
var A:array[1..1000000] of longint;
    i,n,s:longint;
//--------------------------------
procedure QS(l,r :longint);
var i,j,x,temp :longint;
begin
i:=l;
j:=r;
x:=A[(l+r) div 2];
repeat
While A[i]<x do inc(i);
While A[j]>x do dec(j);
if i<=j then begin
             temp:=A[i];
             A[i]:=A[j];
             A[j]:=temp;
             inc(i);
             dec(j);
             end;
until i>j;
if i<r then QS(i,r);
if j>l then QS(l,j);
end;
//------------------------------------
begin
readln(n);
for i:=1 to n do begin
                 read(A[i]);
                 end;
QS(1,n);
s:=A[(n div 2)+1]-A[n div 2];
Writeln(s);
end.


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define endl        "\n"
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vi ,greater< int >>
#define INF         1e18

using namespace std;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


signed main()
{
    showoff;
    int n;
    cin >> n;
    /*int fa = 0;
    for(int i=2;i*i <= n;++i)
    if(n%i == 0)fa = i;
    if(fa == 0){cout << "NO\n";return 0;}
    cout << "YES\n";
    */
    if(n == 7 || n == 5 || n == 3)cout << "YES";
    else cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main () {
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
  
  	int left = A + B;
  	int right = C + D;
  
  	if (left > right) {
    	cout << "Left" << endl;
    } 
  	else if (left == right) {
    	cout << "Balanced" << endl;
    }
  	else {
    	cout << "Right" << endl;
    }
  
}

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

bool linearSearch(vector<int> S, int t){
    for(int i=0; i<S.size(); ++i){
        if(S[i] == t){
            return true;
        }
    }

    return false;
}

int main(){
    int N; cin >> N;
    vector<int> S(N);
    for(int i=0; i<N; ++i){
        cin >> S[i];
    }

    int q; cin >> q;
    vector<int> T(q);
    for(int i=0; i<q; ++i){
        cin >> T[i];
    }

    int count = 0;

    for(int i=0; i<q; ++i){
        if(linearSearch(S, T[i])) count++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

template <typename T> 
const T& clamp(const T &t, const T &low, const T &high) { 
    if(t < low) {
        return low;
    } else if(high < t) {
        return high;
    } else {
        return t;
    }
}

template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define llong long long
const llong inf=0x3f3f3f3f3f3f3f3f;
int n;
char op[22];
int a;
llong dp[100100][3];
int main()
{
    scanf("%d",&n);
    scanf("%d",&a);
    dp[1][0]=a;
    dp[1][1]=dp[1][2]=-inf;
    for(int i=2;i<=n;++i)
    {
        scanf("%s%d",op,&a);
        if(op[0]=='-')a=-a;
//        cout<<"i: "<<i<<" op: "<<op[0]<<" a: "<<a<<endl;
        dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
        dp[i][1]=max(dp[i-1][1],dp[i-1][2]);
        dp[i][2]=dp[i-1][2]+a;
//        cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;cout<<endl;
        dp[i][0]+=a;
        dp[i][1]-=a;
        if(op[0]=='-')
        {
            dp[i][2]=max(dp[i][2],dp[i][1]);
            dp[i][1]=max(dp[i][1],dp[i][0]);
        }
//        cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;cout<<endl;
    }
    printf("%lld\n",max(dp[n][0],max(dp[n][1],dp[n][2])));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

ll n,m,q;

ll a[60],b[60],c[60],d[60];

ll ans;

void calscore(vector<ll> v){
    ll score=0;
    rep(i,q){
        if(v[b[i]]-v[a[i]]==c[i]) score+=d[i];
    }
    ans=max(score,ans);
}

void dfs(vector<ll> v){
    if(v.size()==n+1){
        calscore(v);
    }
    else{
        for(ll i=v.back();i<=m;i++){
            v.pb(i);
            dfs(v);
            v.pop_back();
        }
    }
}


void solve(){
    cin >> n>>m>>q;
    ans=0;
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs({1});
    kaku(ans);
}


int main(){
    solve();
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(t)            int t; cin>>t; while(t--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
void jaiswal_sahil()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
}

const int N = 1e5 + 5;
int dp[N][3];
int n;
int maxPoint(int i, int a[N][3], int p){

    if(i == n)
        return 0;

    if(dp[i][p] != -1)
        return dp[i][p];
    
    int q1 = -inf, q2 = -inf, q3 = -inf;
    if(p==1){
        q2 = a[i][1] + maxPoint(i+1, a, 2);
        q3 = a[i][2] + maxPoint(i+1, a, 3);
    }else if(p==2){
        q1 = a[i][0] + maxPoint(i+1, a, 1);
        q3 = a[i][2] + maxPoint(i+1, a, 3);
    }else if(p==3){
        q1 = a[i][0] + maxPoint(i+1, a, 1);
        q2 = a[i][1] + maxPoint(i+1, a, 2);
    }

    return dp[i][p] = max({q1, q2, q3});
}
 
int32_t main()
{
    jaiswal_sahil();
    
    cin>>n;

    int a[N][3];
    for(int i=0; i<n; i++){
        int x, y, z; cin>>x>>y>>z;
        a[i][0] = x, a[i][1] = y, a[i][2] = z;
    }

    memset(dp, -1, sizeof(dp));
    int x = a[0][0] + maxPoint(1, a, 1);
    int y = a[0][1] +  maxPoint(1, a, 2);
    int z = a[0][2] +  maxPoint(1, a, 3);
    int ans = max({x, y, z});

    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, 0, n)
        cin >> v[i];
    vector<bool> dp(k + 1, false);
    rep(i, 0, k + 1)
        if (!dp[i])
            rep(j, 0, n)
                if (i + v[j] < k + 1)
                    dp[i + v[j]] = true;
    cout << (dp[k] == true?"First":"Second");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   string s;
   cin>>s;
   string s1;
   for(int i=s.length()-1;i>=0;i--)
   {
       s1=s1+s[i];
   }
   int count=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=s1[i])
            count++;
    }
    cout<<count/2<<endl;

    return 0;
}


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

int main()
{
	string s; cin >> s;
	vector<string> v;
	v.push_back(s);
	if(s[s.size()-1] == 's') v.push_back("es");
	else v.push_back("s");
	for(auto a : v) cout << a;

    return 0;
}


Measured memory_bytes: 3644
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
typedef long long ll;
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;
 
int main() {
	// 入力
    int a,b;
    cin >> a >> b;
 

    //出力
    if (a+b==15) cout << "+" << endl;
    else if (a*b==15) cout << "*" << endl;
    else cout << "x" << endl;
}
 


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,k,p[1000],l,r=0;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",&p[i]);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(p[i]>p[j]){
                l=p[i];
                p[i]=p[j];
                p[j]=l;
            }
        }
    }
    for(int i=0;i<k;i++)r+=p[i];
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 1668
import collections

N = int(input())
l = list(map(int,input().split()))

c = collections.Counter(l)
ans = 0
flag = True
if N%2==0:
    for i in range(1,N+1,2):
        if c[i] != 2:
            flag = False
else:
    for i in range(0,N+1,2):
        if i == 0 and c[i] != 1:
            flag = False 
        if i != 0 and c[i] != 2: 
            flag = False

if flag:
    ans = 2**int(N/2)
print(ans % (10**9+7))

Measured memory_bytes: 14820
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 100005;
const int maxm = 100;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
struct Node{
	int v,id;
}a[maxn];
bool cmp(Node a,Node b){
	return a.v<b.v;
}
int main(){
	int n;
	scanf("%d",&n);
	FOR(i,0,n){
		scanf("%d",&a[i].v);
		a[i].id=i;
	}
	sort(a,a+n,cmp);
	FOR(i,0,n)printf("%d ",a[i].id+1);
	printf("\n");
}


Measured memory_bytes: 4548
n,a,b=[int(j) for j in input().split()]
s=a-b
h=[]
for i in range(n):
    p=int(input())
    h.append(p)
h.sort()
import bisect
import math
def f(m):
    n=bisect.bisect_right(h,m*b)
    l=h[n:]
    c=0
    for i in range(len(l)):
        if l[i]-m*b/s>0:
            c+=math.ceil((l[i]-m*b)/s)
    if c<=m:
        return True
    else:
        return False
        


left=0
right=10**15
while right-left>1:
    mid=(left+right)//2
    if f(mid):
        right=mid   #ここがleftならansもleft。
    else:
        left=mid
print(right)


Measured memory_bytes: 7972
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  long num=0;
  long M=0;
  long x=0;
  long a[100000];
  long b[2];
  long n;
  int i,j;
    for(i=0;i<1;i++){
    scanf("%ld",b+i);
  }
  for(i=0;i<1;i++){
    scanf("%ld",a+i);
  }

  printf("%ld",b[0]+a[0]/2);
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int L[N];
    scanf("%d",&L[0]);
    int max = L[0];
    int sum = L[0];
    for(int i = 1; i < N; i++){
        scanf("%d",&L[i]);
        if(max < L[i]) max = L[i];
        sum += L[i];
    }
    sum = sum - max;
    
    if(max < sum) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

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

	ll n, h, d;
	cin >> n >> h >> d;

	ll raise_sum = 1;
	ll raise_prod = 1;
	for (int i = 2; i <= n; ++i) {
		raise_prod = raise_prod * i % MOD;
		raise_sum = (raise_sum + raise_prod) % MOD;
	}

	// Initially n! sets order
	// Selecting k at a level gives k! to setting next order

	vector<ll> pref_sums = {raise_prod};
	for (int k = 1; k <= h; ++k) {
		ll below = (pref_sums[k-1] - (k > d ? pref_sums[k-(d+1)] : 0)) % MOD;
		if (below < 0) below += MOD;

		ll row_sum = below * raise_sum % MOD;
		ll row_add = (row_sum + pref_sums.back()) % MOD;
		pref_sums.push_back(row_add);

		if (k == h) {
			cout << below << '\n';
		}
	}

}


Measured memory_bytes: 10220
#include<map>
#include<cstdio>
using namespace std;
map<int,int>pg;
int n,m,tot=0;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&m);
        if(pg[m]==0)pg[m]=1,++tot;
        else pg[m]=0,--tot;
    }
    printf("%d\n",tot);
}

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

C = []
S = []
F = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N):
    minutes = 0
    for j in range(i, N-1):
        # print(i, j)
        if j == i:
            minutes += C[j] + S[j]
        else:
            if minutes >= S[j]:
                minutes += C[j] + (S[j] - minutes) % F[j]
            elif minutes < S[j]:
                minutes = S[j] + C[j]
    print(minutes)

Measured memory_bytes: 41836
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

int parent[1000000];

void initialize(int n) 
{
	for (int i = 0; i < n; i++) 
		parent[i] = i;
}

int find(int x) 
{
	if (parent[x] == x)return x;
	else return parent[x] =find(parent[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	parent[x] = y;
}

int same(int x, int y) {
	if(find(x) == find(y))
		return 1;
	else
		return 0;
}

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

	initialize(n);

	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com) {
			if (same(x, y))cout << 1 << endl;
			else cout << 0 << endl;
		}
		else {
			unite(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<vector>
#include<climits>
#include<algorithm>
#include<functional>
#include<queue>

using namespace std;

class cake_perm{
    public:
    int p, q, r;
    long val;
    cake_perm() {}
    cake_perm(int pp, int qq, int rr, long vv):p(pp), q(qq), r(rr), val(vv){}
};

bool operator<(const cake_perm &cp1, const cake_perm &cp2){
    return cp1.val < cp2.val;
}


int main(){
    int x, y, z, k;
    cin>>x>>y>>z>>k;
    long a[x], b[y], c[z];
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    sort(a, a + x, greater<long>());
    sort(b, b + y, greater<long>());
    sort(c, c + z, greater<long>());

    priority_queue <cake_perm, vector<cake_perm>, less<cake_perm> > pq;

    for (int i = 0; i < x; i++){
        for (int j = 0; j < x; j++){
            pq.push(cake_perm(i, j, 0, a[i] + b[j] + c[0]));
        }
    }

    for (int i = 0; i < k; i++){
        cake_perm cp = pq.top();
        pq.pop();
        if (cp.r < z - 1){
            pq.push(cake_perm(cp.p, cp.q, cp.r + 1, a[cp.p]+b[cp.q]+c[cp.r + 1]));
        }
        cout << cp.val << endl;
    }
}

Measured memory_bytes: 26984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<ll> X(N), Y(N), Z(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> X.at(i) >> Y.at(i) >> Z.at(i);
  }

  ll ans = 0;
  for (ll k = 0; k < 8; k++)
  {
    ll pmx = ((k & (1LL << 0)) ? -1 : 1);
    ll pmy = ((k & (1LL << 1)) ? -1 : 1);
    ll pmz = ((k & (1LL << 2)) ? -1 : 1);

    vector<pair<ll, ll>> A(N);
    for (ll i = 0; i < N; i++)
    {
      A.at(i).first = pmx * X.at(i) + pmy * Y.at(i) + pmz * Z.at(i);
      A.at(i).second = i;
    }
    sort(A.begin(), A.end(), greater<pair<ll, ll>>());

    ll tmpx = 0, tmpy = 0, tmpz = 0;
    for (ll i = 0; i < M; i++)
    {
      tmpx += X.at(A.at(i).second);
      tmpy += Y.at(A.at(i).second);
      tmpz += Z.at(A.at(i).second);
    }
    ll tmp = abs(tmpx) + abs(tmpy) + abs(tmpz);
    chmax(ans, tmp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int 
#define ll long long 
#define f(i, n) for(int i=0; i<n; i++)

using namespace std;


void test(){
	
	int n;
	cin>>n;
	string s = "";
	vector<int> res(4);
	while(n--){
		cin>>s;
		if(s == "AC"){
			res[0]++;
		}else if(s == "WA"){
			res[1]++;
			
		}else if(s == "TLE"){
			res[2]++;
		}else{
			res[3]++;
		}
	}
	
	cout<<"AC x "<<res[0]<<endl
	<<"WA x "<<res[1]<<endl
	<<"TLE x "<<res[2]<<endl
	<<"RE x "<<res[3]<<endl;
}
int main(){
	
	test();
	return 0;

}







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

int main() {
  int H, W;
  cin >> H >> W;
  char A;
  
  for( int i = 0; i < H + 2; ++i ){
    for( int j = 0; j < W + 2; ++j ){
      if( i == 0 ){
        cout << '#';
      }else if( i == H + 1 ){
        cout << '#';
      }else if( j == 0 ){
        cout << '#';
      }else if( j == W + 1 ){
        cout << '#';
      }else{
        cin >> A;
        cout << A;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3552