akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    string s;
    cin >> s;

    for(int i = 0;i < s.size();i++){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define TC ll test;cin>>test;while(test--)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005

int main(){

ll n;
cin>>n;
ll h[n+1];
ll dp[n+1];
fr(i,0,n){
	cin>>h[i];
	
}
dp[0]=0;
dp[1]=abs(h[1]-h[0]);
fr(i,2,n){
	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
}
cout<<dp[n-1];






}



Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x = II()
    if x < 1200:
        print("ABC")
    else:
        print("ARC")
    return

#B
def B():
    s = S()
    a = inf
    z = 0
    for num,si in enumerate(s):
        if si == "A":
            a = min(a, num)
        if si == "Z":
            z = max(z, num)
    print(z-a+1)
    return

#C
def C():
    x = II()
    print(x // 11 * 2 + (x % 11) // 7 + (x % 11 != 0))
    return

#D
def D():
    n = II()
    x = LI()
    print(len(set(x)) - (n - len(set(x))) % 2)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 65240
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        if self.parents[x]>self.parents[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x<0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
n,m,k=map(int,input().split())
uf=UnionFind(n)
s=set()
cnt=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  uf.unite(a-1,b-1)
  cnt[a-1]+=1
  cnt[b-1]+=1
for _ in range(k):
  c,d=map(int,input().split())
  if uf.same(c-1,d-1):
    cnt[c-1]+=1
    cnt[d-1]+=1
ans=[]
for i in range(n):
  ans.append(uf.size(i)-cnt[i]-1)
print(*ans)

Measured memory_bytes: 100440
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    int a;
    cin >> a;
    int ans;
    ans = 1000 - (a % 1000);
    if (ans != 1000)
        cout << ans << endl;
    else
        cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 3632
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = []
    for _ in range(N):
        A.append(I())
    A = sorted(A)
    ans = sum(A)
    if ans % 10 != 0:
        print(ans)
        return
    non_10 = [x for x in A if x % 10 > 0]
    if len(non_10) == 0:
        print(0)
        return
    else:
        print(ans - non_10[0])
        return


main()



Measured memory_bytes: 5564
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 47112
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
  static void Main()
  {
    
    int N = int.Parse(Console.ReadLine());
    long count = 0;
    Dictionary<string, int> dic = new Dictionary<string, int>();
    for (int i = 0; i < N; i++)
    {
      string str = SortString(Console.ReadLine());
      if (dic.ContainsKey(str))
      {
        count += dic[str];
        dic[str]++;
      }
      else
      {
        dic[str] = 1;
      }
    }
    Console.WriteLine(count);
  }
  
  static string SortString(string str){
    string[] buf = new string[str.Length];
    for (int i = 0; i < str.Length; i++)
    {
      buf[i] = str.Substring(i, 1);
    }
    Array.Sort(buf);
    return string.Join("", buf);
  }
}

Measured memory_bytes: 28728
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int e,n=1000000;
	while (1) {
		cin >> e;
		int mi = INF;
		if (e == 0) break;
		for (int i = 0; i*i*i <= e; i++) {
			for (int j = 0; j*j <= (e-i*i*i); j++) {
				if (j*j + i*i*i > e) break;
				int x = e - (j*j + i*i*i);
				if (mi > (i + j + x)) {
					mi = i + j + x;
				}
			}
		}
		cout << mi << endl;
	}
}



Measured memory_bytes: 3072
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var W = input[0];
            var H = input[1];
            var x = input[2];
            var y = input[3];

            Console.WriteLine(W * H / 2.0 + " " + (W / 2.0 == x && H / 2.0 == y ? 1 : 0));
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int main()
{string s;
 cin>>s;
 if(s.size()!=6){
      cout<<"No"<<endl;
 }
 else{
 for(int i=0;i<6;i++){
 s[i]=tolower(s[i]);}
if(s[2]==s[3]&&s[4]==s[5]){
    cout<<"Yes"<<endl;
}
else{  cout<<"No"<<endl;}
 }

    return 0;
}


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

int N, K, Q;
int A[100001];
int P[100000001];

void question(int i) { //A[i]が正解
  // for(int j=1; j<=N; j++) P[j]--;
  P[i]++;
}

int main(){
  cin>>N>>K>>Q;
  for(int i=1; i<=Q; i++) {
    cin>>A[i]; //i番目にA[i]が正解
    P[i]=0;
  }
  for(int i=1; i<=Q; i++) question(A[i]); //Q回繰り返す。A[i]だけが正解
  for(int i=1; i<=N; i++) cout<<((Q-P[i]>=K) ? "No" : "Yes")<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    V<bool> dp(k + 1, false);
    for (int i = 0; i <= k; i++) {
        if (dp[i]) continue;
        for (auto &ta: a) {
            if (i + ta > k) continue;
            dp[i + ta] = true;
        }
    }
    
    if (dp[k]) cout << "First\n";
    else cout << "Second\n";
    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

string s;
int sum, ans;

int main() {
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'R') {
			sum ++;
			ans = max(sum, ans);
		} else {
			ans = max(sum, ans);
			sum = 0;
		}
	}
	printf ("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D_
{
    class Program
    {
        static void Main(string[] args)
        {
            var nmk = Console.ReadLine().Split(' ');
            var ninzuu = int.Parse(nmk[0]);
            var tomo = int.Parse(nmk[1]);
            var block = int.Parse(nmk[2]);
            var buffer = new int[ninzuu + 1];
            var uni = new UnionFind(ninzuu + 1);

            for(int i = 0; i < tomo; i++)
            {
                var line = Console.ReadLine().Split(' ');
                var x = int.Parse(line[0]);
                var y = int.Parse(line[1]);
                uni.Union(x, y);
                buffer[x]++;
                buffer[y]++;
            }
            for(int i = 0; i < block; i++)
            {
                var line = Console.ReadLine().Split(' ');
                var x = int.Parse(line[0]);
                var y = int.Parse(line[1]);
                if (uni.isSame(x, y))
                {
                    buffer[x]++;
                    buffer[y]++;
                }
            }
            for (int i = 1; i < ninzuu + 1; i++)
            {
                Console.Write(uni.Size(i) - buffer[i] - 1 + " ");
            }
            Console.ReadKey();
        }
    }

    class UnionFind
    {
        public int[] Parents { get; set; }

        public UnionFind(int size)
        {
            Parents = new int[size];
            for(int i = 0; i < size; i++)
            {
                this.Parents[i] = -1;
            }
        }

        public int Find(int x)
        {
            if (this.Parents[x] < 0) return x;

            this.Parents[x] = Find(this.Parents[x]);
            return this.Parents[x];
        }

        public int Size(int x)
        {
            return -this.Parents[this.Find(x)];
        }

        public bool isSame(int x,int y)
        {
            return this.Find(x) == this.Find(y);
        }

        public void Union(int x,int y)
        {
            x = this.Find(x);
            y = this.Find(y);
            if (x == y) return;
            if(Size(x) > Size(y))
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            this.Parents[y] += this.Parents[x];
            this.Parents[x] = y;
        }
    }
}


Measured memory_bytes: 16292
# region
import sys

DEBUG = True if (len(sys.argv) > 1 and sys.argv[1] == "DEBUG") else False


def dp(value):
    if DEBUG:
        print(value)
    return


def input_text(split=" "):
    # 入力
    result = []
    while True:
        try:
            row = list(
                map(lambda x: int(x) if x.isdecimal() else x, input().split(split))
            )
            result.append(row)
        except EOFError:
            break
    return result


# endregion
it = input_text()

x = it[0][0]
a = 100
y = 0

while True:
    y += 1
    risoku = int(a * 0.01)
    a += risoku
    if a >= x:
        print(y)
        sys.exit()


Measured memory_bytes: 64020
let () =
  Scanf.scanf "%d" @@ fun n ->
  let g = Array.init n (fun _ -> []) in
  for _ = 2 to n do
    Scanf.scanf " %d %d %d" @@ fun u v w ->
    let u, v = u-1, v-1 in
    g.(u) <- (v, w mod 2) :: g.(u);
    g.(v) <- (u, w mod 2) :: g.(v);
  done;
  let cs = Array.make n (-1) in
  let rec dfs u c p =
    cs.(u) <- c;
    g.(u) |> List.iter (fun (v, w) -> if p <> v then dfs v ((c + w) mod 2) u)
  in
  dfs 0 0 (-1);
  Array.iter (Printf.printf "%d\n") cs;


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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N; cin >> N;
    int twoN = 2*N;
    pair<int, int> red[N];
    pair<int, int> blue[N];
    pair<int, int> red_and_blue[twoN];
    bool used[twoN];
    rep(i, twoN) used[i] = false;
    rep(i, N){
        int x, y; cin >> x >> y;
        red[i] = make_pair(x, y);
        red_and_blue[i] = red[i];
    }
    rep(i, N){
        int x, y; cin >> x >> y;
        blue[i] = make_pair(x, y);
        red_and_blue[i+N] = blue[i]; 
    }
    int idx_red = 0;
    int idx_blue = 0;
    int ans = 0;
    sort(red, red+N); sort(blue, blue+N); sort(red_and_blue, red_and_blue+twoN);

    rep(i, twoN){
        if(idx_red < N && red_and_blue[i] == red[idx_red]) idx_red++;
        else{
            idx_blue++;
            int target = red_and_blue[i].second;
            int optimal_y = -1;
            int optimal_idx = -1;
            for(int j = 0; j < N && red[j].first < i; j++){
                if(!used[j] && red[j].second < target && red[j].second > optimal_y){
                    optimal_y = red[j].second;
                    optimal_idx = j;
                }
            }
            if(optimal_idx != -1){
                used[optimal_idx] = true;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

H, W = map(int, input().split())

grid = [["#"]*(W+2) for _ in range(H+2)]

for i in range(1, H+1):
    for j, c in enumerate(input()):
        grid[i][j+1] = c

for i in grid:
    print("".join(i))


Measured memory_bytes: 3060
N=int(input())
A=[int(i) for i in input().split()]
CS=[A[0]]
for i in range(1,N-1):
  CS.append(CS[-1]+A[i])
SUM=sum(A)
ans=10**20
for s in CS:
  ans=min(ans,abs(SUM-s-s))
print(ans)

Measured memory_bytes: 24812
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

from functools import lru_cache

def main(): 
    N, L = LI()
    # abs_min = INF

    li = []
    for i in range(1, N+1):
        li.append((abs(L+i-1), L+i-1))

    li.sort()
    li.pop(0)

    sum_ = 0
    for i in li:
        sum_ += i[1]

    print(sum_)


main()

Measured memory_bytes: 3828
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
char a[40],b[40],c[40];
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
	int len = strlen(a);
	int len1 = strlen(b);
	int len2 = strlen(c);
	if(a[len - 1] == b[0] && b[len1 - 1] == c[0])
		printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

    int a,b,c;
    cin>>a>>b>>c;
    if(a<b){
    if(a<c && c<b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }
    else{
         if(b<c && c<a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }
    return 0;
}

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

#define se second
#define fi first



int main()
{

	int n;
	scanf("%d", &n);
	int W[n][3];
	int ans = 0;
	
	for(int i = 0; i < n; i++)
		scanf("%d%d%d", &W[i][0], &W[i][1], &W[i][2]);

	for(int i = 1; i < n; i++)
	{
		W[i][0]+= max ( W[i-1][1], W[i-1][2] );
		W[i][1]+= max ( W[i-1][0], W[i-1][2] );
		W[i][2]+= max ( W[i-1][1], W[i-1][0] );
		
	}
	sort(W[n-1], W[n-1]+3);
	cout<<W[n-1][2];
}

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

void chmax(string &a, string b)
{
    if (a == "-")
        a = b;
    else if (a.size() < b.size())
        a = b;
    else if (a.size() == b.size())
        if (a < b)
            a = b;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; ++i)
        cin >> A[i];

    int match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    string dp[10100];

    for (int i = 0; i < 10100; ++i)
        dp[i] = "-";
    dp[0] = "";
    for (int i = 0; i < N; ++i)
    {
        if (dp[i] == "-")
            continue;
        for (auto a : A)
            chmax(dp[i + match[a - 1]], dp[i] + (char)('0' + a));
    }
    cout << dp[N] << endl;
}

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

int main() {
  int n, m, R;
  cin>>n>>m>>R;
  int r[R];
  for (int i=0; i<R; i++) {
    cin>>r[i];
    --r[i];
  }
  int d[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (i != j) {
        d[i][j] = 1e9;
      } else {
        d[i][j] = 0;
      }
    }
  }
  for (int i=0; i<m; i++) {
    int a, b, c;
    cin>>a>>b>>c;
    --a;
    --b;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if (d[i][k] < 1e9 && d[k][j] < 1e9) {
          d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
        }
      }
    }
  }
  sort(r, r + R);
  int ans = 1e9;
  do {
    int tmp = 0;
    for (int i=0; i<R-1; i++) {
      tmp += d[r[i]][r[i+1]];
    }
    ans = min(tmp, ans);
  } while (next_permutation(r, r + R));
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n;
	cin >> n;
	map<lli, lli> s;
	rep(i,n){
		lli A;
		cin >> A;
		s[A] = i+1;
	}
	for(const auto& x : s){
		cout << x.second << " ";
	}
	return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<iosfwd>
#include<sstream>
#include<math.h>
#define N 100
using namespace std;
int main(){
    int n;
    cin >>n;
    vector<int> v(n,0);
    vector<int> c(n,0);
    // vector<int> dp(n,0);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    int sum=0;
    for(int i=0; i<n; i++){
        if(v[i]>c[i]){
            sum+= v[i]-c[i];
        }
    }
    cout <<sum << endl;

}

Measured memory_bytes: 888
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(){
  int n,a,b;
  int i,j,k;
  int cntA = 0,cntB = 0,cnt = 0;
  string s;
  
  cin >> n >> a >> b;
  cin >> s;

  for(i = 0;i < n;i++){
    if(s[i] == 'a'){
      if(cnt < a + b){
	cout << "Yes" << endl;
	cnt++;
      }
      else{
	cout << "No" << endl;
      }
    }
    else if(s[i] == 'b'){
      if(cnt < a + b && cntB < b){
	cout << "Yes" << endl;
	cnt++;
	cntB++;
      }
      else{
	cout << "No" << endl;
      }
    }
    else{
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
 
constexpr int INF = 1e9;
constexpr ld pi = acos(-1);
 
int main() {
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    if(sx >= gx && sy >= gy) {
        swap(sx, gx);
        swap(sy, gy);
    }
    int lx = min(sx, gx);
    int ly = min(sy, gy);
    int rx = max(sx, gx);
    int ry = max(sy, gy);
    int N;
    cin >> N;
    vector<pii> v(N);
    ld res = abs(sx - gx) + abs(gy - sy);
    res *= 100;
    int dummy;
    bool f = false;
    for(int i = 0; i < N; ++i) {
        cin >> v[i].first >> v[i].second;
        if(sx == gx && sx == v[i].first && ly <= v[i].second && v[i].second <= ry || sy == gy && lx <= v[i].first && v[i].first <= rx && v[i].second == sy) {
            f = true;
        }
        if(sx <= gx && sy <= gy) {
            dummy = INF;
            continue;
        } else if(sx <= gx && sy >= gy) {
            v[i].second = -v[i].second;
            dummy = 1;
        } else if(sx >= gx && sy <= gy) {
            v[i].first = -v[i].first;
            dummy = INF;
        } else {
            v[i].first = -v[i].first;
            v[i].second = -v[i].second;
            dummy = 1;
        }
    }
    if(f) {
        res += 20.0 * (pi / 2 - 1);
        cout << fixed << setprecision(12) << res << endl;
        return 0;
    }
    sort(v.begin(), v.end());
    vector<int> LIS(N, dummy);
    for(auto& p : v) {
        if(lx <= abs(p.first) && abs(p.first) <= rx && ly <= abs(p.second) && abs(p.second) <= ry) {
            *lower_bound(LIS.begin(), LIS.end(), p.second) = p.second;
        }
    }
    int cnt = find(LIS.begin(), LIS.end(), dummy) - LIS.begin();
    if(cnt == ry - ly + 1 || cnt == rx - lx + 1) {
        cnt--;
        res += 20.0 * (pi / 2 - 1);
    }
    //cout << "cnt: " << cnt << endl;
    res -= 20.0 * cnt * (1.0 - pi / 4.0);
    cout << fixed << setprecision(12) << res << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin >> N >> K;
    int A[N];
    rep(i,N){
        cin>>A[i];
    }
    int cm=0,cn=0;
    rep(i,N){
        rep(j,N){
            if(A[i]>A[j]) cm++;
        }
    }
    rep(i,N){
        for(int j=i+1;j<N;j++){
            if(A[i]>A[j]) cn++;
        }
    }
    int ans=((cn*K)%MOD+((((K*(K-1))/2)%MOD)*cm)%MOD)%MOD;
    cout << ans << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string L;
  cin >> L;
  ll x=1;//すでにa+bがL以下であることが確定している分
  ll y=2;//まだ確定していない(つまりa+bの上からn桁がLと一致している)

  for(int i=1;i<L.size();i++){
    if(L[i]=='0'){
      x*=3;
      x%=mod;
    }
    else{
      x=x*3+y;
      x%=mod;
      y*=2;
      y%=mod;
    }
  }
  cout << (x+y)%mod << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b[101],cnt=0;
	cin>>a;
	for (int i=0;i<a;i++)
		cin>>b[i];
	for (int i=0;i<a;i++)
	{
		for (int n=i+1;n<a;n++)
		{
			for (int m=n+1;m<a;m++)
			{
				long long ways[3]={b[i],b[n],b[m]};
				sort(ways,ways+3);
				if (b[i]!=b[n]&&b[n]!=b[m]&&b[i]!=b[m]&&ways[0]+ways[1]>ways[2])
					cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include<cmath>
#include<cstdio>
#include<vector>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int V_MAX=100;

bool augment(int u,bool *vis,int match[2][V_MAX],const vector<int> *G){
	if(u==-1) return true;

	rep(i,G[u].size()){
		int v=G[u][i];
		if(!vis[v]){
			vis[v]=true;
			if(augment(match[1][v],vis,match,G)){
				match[0][u]=v;
				match[1][v]=u;
				return true;
			}
		}
	}
	return false;
}

int bipartite_matching(int L,int R,const vector<int> *G){
	static int match[2][V_MAX];
	rep(u,L) match[0][u]=-1;
	rep(v,R) match[1][v]=-1;

	int res=0;
	static bool vis[V_MAX];
	rep(u,L){
		rep(v,R) vis[v]=false;
		if(augment(u,vis,match,G)) res++;
	}
	return res;
}

int main(){
	for(int m,n;scanf("%d%d",&m,&n),m;){
		int sx[100],sy[100],v[100],gx[100],gy[100];
		rep(i,m) scanf("%d%d%d",sx+i,sy+i,v+i);
		rep(i,n) scanf("%d%d",gx+i,gy+i);

		static double d[100][100];
		rep(i,m) rep(j,n) d[i][j]=hypot(sx[i]-gx[j],sy[i]-gy[j]);

		double lo=0,hi=1e9;
		rep(_,70){
			double mi=(lo+hi)/2;

			vector<int> G[100];
			rep(i,m) rep(j,n) if(d[i][j]<v[i]*mi) G[i].push_back(j);

			if(bipartite_matching(m,n,G)==n) hi=mi; else lo=mi;
		}
		printf("%.9f\n",(lo+hi)/2);
	}

	return 0;
}

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

int main(){
  int P[1000][3];
  for(int i=0;i<1000;i++){
    for(int j=0;j<3;j++){
      P[i][j]=0;
    }
  }
  int a,b,c;
  int N;
  int tmp;
  int cn=0,cnt=0;
  bool flag=false;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a >> b >> c;
    for(int j=0;j<2;j++){
      if(a>b){
        tmp = a;
        a = b;
        b = tmp;
      }
      if(b>c){
        tmp = b;
        b = c;
        c = tmp;
      }
    }
    //cout << a << " " <<  b << " " << c << endl;
    for(int j=0;j<N;j++){
      if(P[j][0]==a&&P[j][1]==b&&P[j][2]==c){
        cnt++;
        flag=true;
        break;
      }
      else{
        flag=false;
      }
    }
    if(!flag){
      P[cn][0]=a;
      P[cn][1]=b;
      P[cn][2]=c;
      cn++;
    }



  }

  cout << cnt << endl;
}



Measured memory_bytes: 3092
(let ((a (read)) (b (read)) (c (read)) (n 0))
     (declare (optimize (speed 3) (safety 0)))
     (declare (fixnum a b c n))
     (setq n (- (+ a b 1) c))
     (format t "~a" 
        (if (> n 0) (+ b c) (+ b c n)))
     )


Measured memory_bytes: 11872
#include <iostream>
#include <string>

namespace ABC178
{

  class A
  {
  public:
    A() = default;
    ~A() = default;


    void Run()
    {
      int x = {};
      std::cin >> x;

      std::cout << (x>0 ? "0" : "1") << std::endl;
    }
  };

}
int main()
{

  ABC178::A prob;
  prob.Run();

  return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e5 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, a[N];
ll dp[444][444], p[444];
bool u[444][444];

ll rec(int l, int r) {
	if(l == r) return 0;
	if(u[l][r]) return dp[l][r];
	u[l][r] = 1;
	dp[l][r] = INF;
	for(int i = l; i < r; i++)
		dp[l][r] = min(dp[l][r], rec(l, i) + rec(i + 1, r) + p[i] - p[l - 1] + p[r] - p[i]);
	return dp[l][r];
} 

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));

	scanf("%lld", &n);

	for(ll i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		p[i] = p[i - 1] + a[i];
	}

	cout << rec(1, n);
                    
    return 0;                                        
}

Measured memory_bytes: 1920
import java.util.*;

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

    char[] s = S.toCharArray();

    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
		System.out.println("Bad");
    }else{
        System.out.println("Good");
    }
	}
}

Measured memory_bytes: 22868
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    if(a*b<=0){printf("Zero\n");return 0;}
    if(a>0){printf("Positive\n");return 0;}
    if((b-a+1)%2){printf("Negative\n");}else{printf("Positive\n");}
    return 0;
}

Measured memory_bytes: 128
# 上位ノードほど @rank が大きい数字となる
class Node
  attr_accessor :parent, :rank

  # 親は自分自身、ランクは 0 として初期化する
  def initialize(n)
    @parent = n
    @rank = 0
  end
end

class UnionFind
  # 0 から n - 1 までのノードを初期化する
  def initialize(n)
    @nodes = (0...n).map { |i| Node.new(i) }
  end

  # 再帰で最も上位の親を探して更新し、その値を返す
  def root(x)
    return x if @nodes[x].parent == x
    return @nodes[x].parent = root(@nodes[x].parent)
  end

  # a と b を仲間にする
  def unite(a, b)
    a_root = root(a)
    b_root = root(b)
    # a 及び b の親が同じ場合は何もしない
    return if a_root == b_root

    # a親ランク < b親ランク の場合は、b親をa親の親とする
    # なお、ランクをいじる必要はなし
    if @nodes[a_root].rank < @nodes[b_root].rank
      @nodes[a_root].parent = b_root
    # その他の場合は、a親をb親の親とする
    else
      @nodes[b_root].parent = a_root
    # a親、及びb親のランクが同じ場合は、a親のランクを +1 する
      @nodes[a_root].rank += 1 if @nodes[a_root].rank == @nodes[b_root].rank
    end
  end

  # a と b の最も上位の親が同じかどうかを返す
  def same?(a, b)
    root(a) == root(b)
  end

  # 各ノードの親を全て出力する確認用
  def parents
    @nodes.map(&:parent)
  end
  
  # 各ノードの最も上位の親を全て出力する確認用
  def roots
    @nodes.size.times.map { |i| root(i) }
  end
end

n, m = gets.split.map(&:to_i)
edges = []
m.times { edges << gets.split.map(&:to_i).map(&:pred) }

tree = UnionFind.new(n)

edges.each { |x, y| tree.unite(x, y) }

puts tree.roots.uniq.size


Measured memory_bytes: 19888
n = int(input())

a = []
m = 101
c = 0
for i in range(n):
    tmp = int(input())
    if tmp%10 != 0:
        c += 1
        m = min(tmp,m)
    a.append(tmp)

if sum(a)%10 != 0:
    print(sum(a))
elif sum(a)%10 == 0 and c == 1:
    print(m)
elif sum(a)%10 == 0 and c == 0:
    print(0)
else:
    print(sum(a)-m)








Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = 0
for i in reversed(range(N)):
    if A[i+1] >= B[i]:
        cnt += B[i]
        continue
    else:
        cnt += A[i+1]
        B[i] -= A[i+1]
        if A[i] >= B[i]:
            cnt += B[i]
            A[i] -= B[i]
        else:
            cnt += A[i]
            A[i] -= A[i]
print(cnt)


Measured memory_bytes: 82020
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 105
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
int n;
struct point{
  string ten;
  int gt,vt;
};
point a[oo];
void nhap(){
  cin>>n;
  for(int i=1;i<=n;++i){
    cin>>a[i].ten>>a[i].gt;
    a[i].vt=i;
  }
}
bool cmp(point i,point j){
  if(i.ten!=j.ten) return i.ten<j.ten;
  return i.gt>j.gt;
}
void xuly(){
  sort(a+1,a+1+n,cmp);
  for(int i=1;i<=n;++i) cout<<a[i].vt<<'\n';
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  nhap();
  xuly();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

template <int mod = mod>
struct modint {
    lint v;
    modint() : v(0) {}
    modint(signed v) : v(v) {}
    modint(lint t) {
        v = t % mod;
        if (v < 0)
            v += mod;
    }

    modint pow(lint k) {
        modint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static modint add_identity() { return modint(0); }
    static modint mul_identity() { return modint(1); }
    modint inv() { return pow(mod - 2); }

    modint &operator+=(modint a) {
        v += a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    modint &operator-=(modint a) {
        v += mod - a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    modint &operator*=(modint a) {
        v = v * a.v % mod;
        return *this;
    }
    modint &operator/=(modint a) { return (*this) *= a.inv(); }

    modint operator+(modint a) const { return modint(v) += a; };
    modint operator-(modint a) const { return modint(v) -= a; };
    modint operator*(modint a) const { return modint(v) *= a; };
    modint operator/(modint a) const { return modint(v) /= a; };

    modint operator-() const { return v ? modint(mod - v) : modint(v); }

    bool operator==(const modint a) const { return v == a.v; }
    bool operator!=(const modint a) const { return v != a.v; }
    bool operator<(const modint a) const { return v < a.v; }
};
using mint = modint<mod>;
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, m;
    cin >> n >> m;
    vector<vector<vector<mint>>> dp(m + 1, vector<vector<mint>>(n + 1, vector<mint>(n + 1, 0)));
    dp[0][1][1] = 1; // step, visited, scc
    for (lint i = 0; i < m; ++i) {
        for (lint j = 1; j <= n; ++j) {
            for (lint k = 1; k <= j; ++k) {
                if (j != n) {
                    dp[i + 1][j + 1][k] += dp[i][j][k].v * (n - j);
                }
                dp[i + 1][j][j] += dp[i][j][k].v * (k);
                dp[i + 1][j][k] += dp[i][j][k].v * (j - k);
            }
        }
    }
    cout << dp[m][n][n] << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
const int N = 100005;

vector<int> g[N], a(N, -1);
bool flag = true;

int dfs(int u, int fa) {
  for (auto v : g[u]) {
    if (v != fa) {
      if (a[v] == -1) {
        a[v] = (a[u] ^ 1);
        dfs(v, u);
      } else {
        flag &= (a[v] ^ a[u]);
      }
    }
  }
}

int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  a[1] = 0;
  dfs(1, 0);
  if (!flag) {
    cout << (ll)n * (n - 1) / 2 - m << endl;
  } else {
    int cx = 0;
    for (int i = 1; i <= n; i++) {
      cx += a[i];
    }
    cout << (ll)cx * (n - cx) - m << endl;
  }
  return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main(){
    int n;
    cin >> n;
    P a[2*n], b[2*n];
    rep(i, n){
        cin >> a[i].first >> b[i].first;
        a[i].second = i;
        b[i].second = i;
    }
    rep(i, n) {
        cin >> a[n+i].first >> b[n+i].first;
        a[n+i].second = n + i;
        b[n+i].second = n + i;
    }
    sort(a, a + 2 * n);
    sort(b, b + 2 * n, greater<P>());
    // rep(i, 2 * n){
    //     cout << a[i].first << " " << a[i].second << endl;;
    // }
    // cout << endl;
    // rep(i, 2 * n){
    //     cout << b[i].first << " " << b[i].second << endl;;
    // }
    int ans = 0;
    int made[2*n];
    rep(i, 2 * n) made[i] = 0;
    rep(i, 2 * n){
        if (a[i].second >= n){
            bool flag = false;
            bool flag2 = false;
            for (int j = 0; j < 2 * n && !flag2; j++){
                if (b[j].second == a[i].second){
                    flag = true;
                }
                if (flag && b[j].second < n && made[b[j].second] == 0){
                    // cout << a[i].second << " " << b[j].second << endl;
                    for (int k = 0; k < i; k++){
                        // cout << a[k].second << endl;
                        if (a[k].second == b[j].second){
                            ans++;
                            made[a[i].second] = 1;
                            made[b[j].second] = 1;
                            flag2 = true;
                            break;
                        }
                    }
                }
            }
        }
        // rep(i, 2 * n) cout << made[i] << " ";
        // cout << endl;
    }
    // rep(i, 2 * n) cout << made[i] << " ";
    // cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes" if n else "No")
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

a,b = f()
if a % 2 != 0 and b % 2 != 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3572
#!/usr/bin/env python3
# N = int(input())
# S = input()
A, B = map(int, input().split())
# A = list(map(int, input().split()))

if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B // 2)
else:
    print(0)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdint.h>
#include <string.h>

int calc(int a)
{
    return a + a*a + a*a*a;
}

int main()
{
    int n;
    char buf[30];

    fgets(buf, sizeof(buf), stdin);

    n = atoi(buf);

    printf("%d\n", calc(n));
}

Measured memory_bytes: 1628