akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int[] num = sc.nextIntArray(3);
		Arrays.sort(num);
		String canDevide = "No";
		if (num[2] != num[1] && num[2] == num[1] + num[0]) {
			canDevide = "Yes";
		}
		System.out.println(canDevide);
	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22612
import Data.List

main = interact $ unlines . map (show' . recurring_decimals . map read . words) . takeWhile (/= "0 0") . lines
 where show' = unwords . map show

recurring_decimals [a0,l] = [j, ai, i-j]
 where
  ((j,aj),(i,ai)) = (head as', last as')
  as' = head . filter (\xs -> length xs >= 2 && (snd.head) xs == (snd.last) xs) . subsequences $ as
  as = take 21 . iterate (\(i,a) -> (i+1, amax a - amin a)) $ (0,a0)
  amax = read . take l . reverse . sort . (replicate l '0' ++) . show
  amin = read . sort . show

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

cities = []
points = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    cities.append(s)
    points.append([p, i])
    
dictionary = {city: [] for city in set(cities)}
for i in range(len(cities)):
    dictionary[cities[i]].append([points[i], i])
    
for key in sorted(list(dictionary.keys())):
    values = sorted(dictionary[key], key=lambda x: x[0],reverse=True)
    for v, i in values:
        print(1+i)

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

int main() {
  string s;
  cin >> s;
  int start, end;
  for (int i=0; i<s.size(); i++) {
    if (s[i]=='A') {
      start = i;
      break;
    }
  }
  for (int i=s.size()-1; i>0; i--) {
    if (s[i]=='Z') {
      end = i+1;
      break;
    }
  }
  cout << end - start << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define T 50
#define P 10

#define INT(X) \
  ( *( (const int *)(X) ) )

using namespace std;

static int t;
static int p;
static int r;

static int d[ T ];
static int ac[ T ];
static int wa[ T ][ P ];
static int pen[ T ];

static int
compare (
  const void * a,
  const void * b
  )
{
  int v;

  v = ac[ INT( b ) ] - ac[ INT( a ) ];
  if ( v ) return ( v );

  v = pen[ INT( a ) ] - pen[ INT( b ) ];
  if ( v ) return ( v );

  return ( INT( a ) - INT( b ) );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    scanf ( " %d %d %d", &t, &p, &r );
    if ( !( t | p | r ) ) break ;

    memset ( ac, 0, sizeof ( ac ) );
    memset ( wa, 0, sizeof ( wa ) );
    memset ( pen, 0, sizeof ( pen ) );

    while ( r-- )
    {
      int tid, pid, time;
      char msg[ 16 ];

      scanf ( " %d %d %d %s", &tid, &pid, &time, msg );
      if ( *msg == 'W' )
      {
        wa[ tid - 1 ][ pid - 1 ] += 1;
      }
      else
      {
        ac[ tid - 1 ] += 1;
        pen[ tid - 1 ] += wa[ tid - 1 ][ pid - 1 ] * 1200 + time;
      }
    }
    for ( i = 0; i < t; ++i )
    {
      d[ i ] = i;
    }
    qsort ( d, t, sizeof ( int ), compare );

    for ( i = 0; i < t; ++i )
    {
      printf ( "%d %d %d\n", d[ i ] + 1, ac[ d[ i ] ], pen[ d[ i ] ] );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;

const int MAX_N = 50;
double x[MAX_N];
double y[MAX_N];

double _dist(double x1, double y1, double x2, double y2) {
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double dist(int p1, int p2) {
    return _dist(x[p1],y[p1],x[p2],y[p2]);
}

int main() {
    int N;
    cin >> N;
    rep(i,N) cin >> x[i] >> y[i];
    double l = 0;
    double r = INF;
    queue<tuple<double,double,int,int>> que;
    double c = (l+r)/2;
    rep(_i,100) {
        rep(p1,N) {
            repi(p2,p1+1,N) {
                double d = dist(p1,p2);
                if(2*c<d) continue;
                double h = sqrt(c*c - (d/2)*(d/2));
                double mx = (x[p1]+x[p2])/2;
                double my = (y[p1]+y[p2])/2;
                double c1x = mx + (y[p2]-y[p1])/d*h;
                double c1y = my + (x[p1]-x[p2])/d*h;
                double c2x = mx + (y[p1]-y[p2])/d*h;
                double c2y = my + (x[p2]-x[p1])/d*h;
                que.emplace(c1x,c1y,p1,p2);
                que.emplace(c2x,c2y,p1,p2);
            }
        }
        bool lstok = false;
        while(!que.empty()) {
            double cx,cy;
            int p1,p2;
            tie(cx,cy,p1,p2) = que.front();
            que.pop();
            bool allok = true;
            rep(i,N) {
                if(i == p1 || i == p2) continue;
                double d = _dist(cx,cy,x[i],y[i]);
                if(c < d) allok = false;
            }
            if(allok) {
                lstok = true;
            }
        }
        if(lstok) r = c;
        else l = c;
        c = (l+r)/2;
    }
    printf("%.8lf\n", c);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (){
	char contest [10];
	
	scanf("%s", &contest);
	
	if(contest[1]=='B'){
		contest [1] = 'R';
	}else if (contest[1]=='R'){
		contest [1]= 'B';
	}
	printf("%s", contest);
	return 0;
}

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

int main(){
  int D;
  cin >> D;

  switch(D){
    case 25:
      cout << "Christmas" << endl;
      break;
    case 24:
      cout << "Christmas Eve" << endl;
      break;
    case 23:
      cout << "Christmas Eve Eve" << endl;
      break;
    case 22:
      cout << "Christmas Eve Eve Eve" << endl;
      break;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c=0,ans=1010;
  cin >> a >> b;
  for(int i=0;i<1010;i++){
    if((int)(i*0.08)==a) c++;
    if((int)(i*0.10)==b) c++;
    if(c==2){
      ans=min(ans,i);
      c=0;
    }else{
      c=0;
    }
  }
  if(ans==1010){
    ans=-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
设f[i][j]表示当前有i个白球，一共放完了j种球
显然有j <= i
* 放白球 从f[i-1][j]转移
* 放没有出现过的球 (n - j + 1) * f[i][j - 1] * C(k - 2, n * k - i - (j - 1) * (k - 1) - 1)
*/
#include <bits/stdc++.h>
using namespace std;

const int N = 2020;
const int mod = 1e9 + 7;

int inv[N * N], fac[N * N];
int f[N][N];
int n, k;

int power(int a, int b) {
	a %= mod; int ans = 1;
	while(b) {
		if(b & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod; b >>= 1;
	}
	return ans;
}

int C(int n, int m) {
	return 1ll * fac[m] * inv[n] % mod * inv[m - n] % mod;
}

int main() {
	scanf("%d%d", &n, &k);
	if(k == 1) return printf("%d\n", 1), 0;
	fac[0] = 1;
	for(int i = 1; i < N * N; ++i) 
		fac[i] = 1ll * fac[i - 1] * i % mod;
	for(int i = 0; i < N * N; ++i) 
		inv[i] = power(fac[i], mod - 2);
	for(int i = 0; i <= n; ++i) f[i][0] = 1;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= i; ++j) {
			f[i][j] = f[i - 1][j];
			(f[i][j] += 1ll * (n - j + 1) * f[i][j - 1] % mod * C(k - 2, n * k - i - (j - 1) * (k - 1) - 1) % mod) %= mod;
			(f[i][j] += mod) %= mod;
		}
	}
	printf("%lld\n", (f[n][n] % mod + mod) % mod);
	return 0;
}

Measured memory_bytes: 47232
def npr(n,r):
    if n == r:return 1
    ans1 = 1
    ans2 = 1
    for i in range(1,r+1):
        #print((n-r+i),i)
        ans1 *= i
        ans2 *= (n-r+i)
    return ans2//ans1

N = int(input())
dics = {}
sl = []
for _ in range(N):
    s = input()
    sl.append(''.join(sorted(s)))
for c in sl:dics[c] = dics.get(c,0)+1
g = 0
for k in dics.keys():
    if dics[k] >=2:
        g += npr(dics[k],2)
print(g)

Measured memory_bytes: 19472
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder

object BMain{
    fun solve(){
        val k = nextInt()
        var seven = 7
        for(i in 1..k+10){
            if(seven % k == 0){
                println(i)
                return
            }

            seven *= 10
            seven += 7
            seven %= k
        }

        println(-1)
    }





    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun NextDouble() = next().toDouble()
}

fun main(){
    BMain.solve()
}



Measured memory_bytes: 33852
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

typedef pair<ll, ll>P;
typedef pair<double, P>DP;

int main(){
    ll N;
    cin >> N;

    vector<DP>v;
    for(ll i = 0; i < N; i++){
        ll x, y;
        cin >> x >> y;
        v.push_back(DP(atan2(y, x), P(x, y)));
    }
    sort(v.begin(), v.end());
    double ans = 0;
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            ll x = 0, y = 0;
            for(ll k = i; ;k = (k + 1) % N){
                x += v[k].second.first;
                y += v[k].second.second;
                if(k == j)break;
            }
            ans = max(ans, hypot(x, y));
        }
    }
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int s;
    bool tf = true;
    cin >> s;
    int count = 1;
    while (tf) {
        if (s == 1) {
            cout << 4 << endl;
            return 0;
        }
        else if (s == 2) {
            cout << 4 << endl;
            return 0;
        }
        else if (s == 4) {
            tf = false;
            goto last;
        }
        if (s % 2 == 0) {
            s /= 2;
        }
        else if (s % 2 == 1) {
            s = 3 * s + 1;
        }
        count++;
    }
    last:
    cout << count + 3 << endl;
}

Measured memory_bytes: 256
n=int(input())
s=input()
def check(s1,s2):
  ans=[s1,s2]
  for i in range(1,n-1):
    if (ans[i]=='S' and s[i]=='o') or (ans[i]=='W' and s[i]=='x'):
      ans.append(ans[i-1])
    elif ans[i]=='S' and s[i]=='x' and ans[i-1]=='S':
      ans.append('W')
    elif ans[i]=='S' and s[i]=='x' and ans[i-1]=='W':
      ans.append('S')
    elif ans[i]=='W' and s[i]=='o' and ans[i-1]=='S':
      ans.append('W')
    elif ans[i]=='W' and s[i]=='o' and ans[i-1]=='W':
      ans.append('S')
  if ans[-1]=='S':
    if s[-1]=='o' and ans[0]==ans[-2]:
      if ans[0]=='S' and s[0]=='o' and ans[1]==ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='S' and s[0]=='x' and ans[1]!=ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='W' and s[0]=='o' and ans[1]!=ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='W' and s[0]=='x' and ans[1]==ans[-1]:
        print(''.join(ans))
        exit()
    if s[-1]=='x' and ans[0]!=ans[-2]:
      if ans[0]=='S' and s[0]=='o' and ans[1]==ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='S' and s[0]=='x' and ans[1]!=ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='W' and s[0]=='o' and ans[1]!=ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='W' and s[0]=='x' and ans[1]==ans[-1]:
        print(''.join(ans))
        exit()
  else:
    if s[-1]=='o' and ans[0]!=ans[-2]:
      if ans[0]=='S' and s[0]=='o' and ans[1]==ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='S' and s[0]=='x' and ans[1]!=ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='W' and s[0]=='o' and ans[1]!=ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='W' and s[0]=='x' and ans[1]==ans[-1]:
        print(''.join(ans))
        exit()
    if s[-1]=='x' and ans[0]==ans[-2]:
      if ans[0]=='S' and s[0]=='o' and ans[1]==ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='S' and s[0]=='x' and ans[1]!=ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='W' and s[0]=='o' and ans[1]!=ans[-1]:
        print(''.join(ans))
        exit()
      if ans[0]=='W' and s[0]=='x' and ans[1]==ans[-1]:
        print(''.join(ans))
        exit()
  return
check('S','S')
check('S','W')
check('W','S')
check('W','W')
print(-1)

Measured memory_bytes: 4568
x = int (input ())
if 1800 <= x:
  print (1)
elif 1600 <= x:
  print (2)
elif 1400 <= x:
  print (3)
elif 1200 <= x:
  print (4)
elif 1000 <= x:
  print (5)
elif 800 <= x:
  print (6)
elif 600 <= x:
  print (7)
else:
  print (8)

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

const long long int mod = 10*10*10*10*10*10*10*10*10 + 7;

long long int stair(int x) {
  if (x == 0) {
    return 1;
  }
  else if (x == 1) {
    return 1;
  }
  else if (x == 2) {
    return 2;
  }
  else {
    long long int x1 = 1;
    long long int x2 = 0;
    long long int count = 0;
    for (int i = 0; i < x; i++) {
      count = x1 + x2;
      count %= mod;
      x2 = x1;
      x1 = count;
    }
    return count;
  }
}
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M + 2);
  s.at(0) = -1;
  s.at(M + 1) = N + 1;
  for (int i = 1; i < M + 1; i++) {
    cin >> s.at(i);
  }
  long long int count = 1;
  int sa = 0;
  for (int i = 1; i < M + 2; i++) {
    sa = s.at(i) - s.at(i - 1);
    if (sa == 1) {
      cout << 0 << endl;
      break;
    }
    else {
      count *= stair(sa - 2);
      count %= mod;
      if (i == M +1) {
        printf("%lld", count);
      }
    }
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll a, b;
    cin >> a >> b;
    set<ll> s;
    ll k ;cin >> k;
    k--;
    for(ll i = a; i <= min(b, a+k); i++){
        s.insert(i);
    }
    for(ll j = max(a, b-k); j <= b; j++) s.insert(j);
        itr(it, s) cout << *it << endl;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int D,T,S,x;
	scanf("%d %d %d",&D,&T,&S);
	x = T*S;
	if(x>=D) {
		printf("Yes\n");
	}
    else{
			printf("No\n");
		}
	return 0;
}

Measured memory_bytes: 1636
S = input()
length = len(S)

tap = True
for i in range(length):
    if (i + 1) % 2 == 1 and S[i] == "L":
        tap = False
    elif (i + 1) % 2 == 0 and S[i] == "R":
        tap = False

print("Yes" if tap else "No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if ((a + b) % 2 == 0) {
            System.out.println((a + b) / 2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef pair<int,int> pii;
 
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
 
using namespace IO;
 
typedef pair<ll,ll> frac;
 
ll N,S=0;
vector<frac> T;
bool mp(frac A,frac B)
{
    return (A.first*B.second<A.second*B.first);
}
ll gcd(ll x,ll y) { return (!y)?x:gcd(y,x%y); }
signed main()
{
 
    read(N);
    for(int i=1;i<=N;i++)
    {   
        ll x,y;
        read(x),read(y);
        S+=x;
        T.push_back(make_pair(std::max(x,y),y));
    }
    sort(T.begin(),T.end(),greater<frac>());
    ll pos=0;
    ll point=-1;
    int ca=0;
    for(auto it=T.begin();it!=T.end();it++)
    {
        if((pos+it->first) >S) break;
        pos+=it->first;
        point=it-T.begin();
        ca++;
    }
    if(ca==N){cout<<"0 1"<<endl;return 0;}
    frac ans(0,1);
    for(int i=0;i<T.size();++i)
    {
        if(i>point)
        {
            if(pos+T[i].second>=S) 
            {
                frac res(pos+T[i].second-S,T[i].second);
                ans=(mp(ans,res))?res:ans;
            }
        }
        else
        {
            if(pos-T[i].first+T[point+1].first+T[i].second>=S)
            {
                frac res(pos-T[i].first+T[point+1].first+T[i].second-S,T[i].second);
                ans=(mp(ans,res))?res:ans;
            }
        } 
    }
    ans.first+=ans.second*(N-ca-1);ans.second*=N;
    ll _f=gcd(ans.first,ans.second);
    cout<<ans.first/_f<<" "<<ans.second/_f<<endl;
    return 0;
}

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

stack<int> s;
int n,a[1000000];

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

  int ans = 0;
  for(int i=0;i<n;i++){
    while(s.size() && s.top()>a[i])s.pop();
    if(s.empty() || s.top()<a[i]){
      s.push(a[i]);
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define mp make_pair
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

vector<pair<double,int> > other;
int main(void){
  rep(i,3){
    vector<pair<double,int> > timer;
    rep(i,8){
      int n;double t;
      cin>>n>>t;
      timer.pb(mp(t,n));
    }
    sort(all(timer));
    rep(i,2)
      printf("%d %.2f\n",timer[i].second,timer[i].first);
    loop(i,2,timer.size()){
      other.push_back(timer[i]);
    }
    timer.clear();
  }
  sort(all(other));
    rep(i,2)
      printf("%d %.2f\n",other[i].second,other[i].first);

}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1, 0);
    for (int i = 0; i <m; i++) {
        int t;
        cin >> t;
        a[t] = 1;
    }

    vector<int> dp(n+2);
    int mod = 1000000007;
    dp[n + 1] = 0;
    dp[n] = 1;
    for (int i = n-1; i >= 0; i--) {
        if(a[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
    }

    cout << dp[0] << endl;
}

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

int main() {
  int N, c, count;
  cin >> N;
  c = 0;
  count = 1;
  vector<int> A(N), C(N);

  for (int i = 0; i < N; i++){
    cin >> C.at(i);
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (A.at(i) < C.at(j)){
        A.at(i) = C.at(j);
        c = j;
      }
    }
    C.at(c) = 0;
  }
  for (int i = 0; i < N; i++){
    if (N-i-1 > 0 && A.at(N-i-1) < A.at(N-i-2)){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import scala.io.Source

object Main{
  def main(args: Array[String]){
    var list = List[String]()
    for(in <- Source.stdin.getLines.toList){
      list = in :: list
    }

    for(i <- 1 to list.length){
      val arr = list(list.length - i).split(Array(' '))

      if(!(arr(0).toInt == 0 && arr(1).toInt == 0)){
        for(i <- 0 until arr(0).toInt){
          for(j <- 0 until arr(1).toInt){
            i match{
              case 0 => print("#")
              case x if(x == arr(0).toInt-1) => print("#")
              case _ => j match{
                case 0 => print("#")
                case y if(y == arr(1).toInt-1) => print("#")
                case _ => print(".")
              }
            }
          }
          println
        }
        println
      }
    }
  }
}

Measured memory_bytes: 58812
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	bool operator<(const struct Info &arg) const{
			return cost > arg.cost;
	};
	int to,cost;
};


int main(){

	int V,E,start;
	scanf("%d %d %d",&V,&E,&start);

	int *min_cost = new int[V];
	for(int i = 0; i < V; i++)min_cost[i] = BIG_NUM;

	vector<Info> Edges[V];

	min_cost[start] = 0;

	int from,to,cost;
	for(int i = 0; i < E; i++){
		scanf("%d %d %d",&from,&to,&cost);
		Edges[from].push_back(Info(to,cost));
	}

	priority_queue<Info> Q;

	for(int i = 0; i < Edges[start].size(); i++){
		if(min_cost[Edges[start][i].to] > Edges[start][i].cost){
			min_cost[Edges[start][i].to] = Edges[start][i].cost;
			Q.push(Info(Edges[start][i].to, Edges[start][i].cost));
		}
	}

	int min_index;

	while(!Q.empty()){
		if(Q.top().cost > min_cost[Q.top().to]){
			Q.pop();
		}else{
			min_index = Q.top().to;
			Q.pop();
		}

		for(int i = 0; i < Edges[min_index].size(); i++){
			if(min_cost[Edges[min_index][i].to] > min_cost[min_index] + Edges[min_index][i].cost){
				min_cost[Edges[min_index][i].to] = min_cost[min_index] + Edges[min_index][i].cost;
				Q.push(Info(Edges[min_index][i].to,min_cost[Edges[min_index][i].to]));
			}
		}
	}

	for(int i = 0; i < V; i++){
		if(min_cost[i] == BIG_NUM)printf("INF\n");
		else{
			printf("%d\n",min_cost[i]);
		}
	}


	return 0;
}


Measured memory_bytes: 12464
#include<iostream>
#include<set>
using namespace std;
#define ll long long

int main(){
  ll N, M;
  cin >> N >> M;
  multiset<ll> A;
  ll a;
  for(ll i=0; i<N; ++i){
    cin >> a;
    A.insert(a);
  }

  for(ll i=0; i<M; ++i){
    auto max = --A.end();
    A.insert((*max)/2);
    A.erase(max);
  }

  ll ans=0;
  for(auto itr=A.begin(); itr!=A.end(); ++itr) ans+=(*itr);

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 4992
package main
import (
  "container/list"
  "fmt"
  "os"
)
func main() {
  var n int
  var b []int
  fmt.Scan(&n)
  b = make([]int,n)
  for i:=0;i<n;i++ {
    fmt.Scan(&b[i])
    if b[i] > i+1 {
      fmt.Println(-1)
      os.Exit(0)
    }
  }
  stack := list.New()
  for ;len(b)>0; {
    for i:=len(b)-1;i>=0;i-- {
      if b[i] == i+1 {
        stack.PushFront(i+1)
        b = trim(b,i)
        break
      }
    }
  }
  for i:=0;i<n;i++ {
    fmt.Println(stack.Remove(stack.Front()))
  }
}
func trim(b []int,k int) []int {
  var c []int = make([]int,len(b)-1)
  var t int = 0
  for i:=0;i<len(c);i++ {
    if i == k { t = 1 }
    c[i] = b[i+t]
  }
  return c
}

Measured memory_bytes: 640
#include<cstdio>
#define N 301
using namespace std;
unsigned long long mod = 998244353LL, T1[N][N*N], T2[N][N*N/2];
     
int main()
{
  unsigned long long n,sum = 0,a[300], ans = 1, i,j;
  scanf("%llu",&n);
      
  for(i = 0; i < n ; ++i) {
    scanf("%llu",&a[i]);
    sum += a[i];
    ans = ans * 3 % mod;
  }
     
  T1[0][0] = 1;
  T2[0][0] = 1;
  for(i = 1 ; i <= n ; ++i) {
    for(j = 0; j <= sum ; ++j) {
      T1[i][j] = T1[i - 1][j] * 2 % mod;
      T2[i][j] = T2[i - 1][j];
          
      if(j >= a[i-1]) {
        T1[i][j] = (T1[i][j] + T1[i-1][j-a[i-1]]) % mod;
        T2[i][j] = (T2[i][j] + T2[i-1][j-a[i-1]]) % mod;
      }
    }
  }
     
  for(j = (sum+1)/2 ; j <= sum ; ++j)
    ans = (ans + mod - T1[n][j] * 3 % mod) % mod;
     
  if (sum%2 == 0)
    ans = (ans + T2[n][sum/2] * 3) % mod;
     
  printf("%llu",ans);
      
  return 0;
}


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

int main() {
  int A, B; cin >> A >> B;
  int coin;
  for( int i = 0; i < 2; i++ ) {
    if( A >= B ) {
      coin = coin + A;
      A--;
    }
    else {
      coin = coin + B;
      B--;
    }
  }
  cout << coin << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A[3];
  for(int i=0;i<3;i++){
    cin>>A[i];
  }
  sort(A,A+3);
  int ans=0;
  for(int i=0;i<2;i++){
    ans=ans+abs(A[i]-A[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,k;
  cin >> n >> k;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  sort(ALL(a));
  int32 l=-1,r=n;
  while(r - l > 1){
    int32 mid = (l + r) / 2;
    vector<bool> dp(k,false);
    dp[0] = true;
    REP(i,n){
      if(mid == i)continue;
      FORR(j,k-1-a[i],0){
        if(dp[j])
          dp[j+a[i]] = true;
      }
    }
    bool need = false;
    FOR(i,max<int32>(0,k-a[mid]),k)if(dp[i])need = true;
    if(need){
      r = mid;
    }else{
      l = mid;
    }
  }
  ANS(r);
  return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, L;
    cin >> N >> L;

    ll t = 0;
    ll m = INT_MAX;
    for(int i = 0; i < N; i++ ){
        t += (L+i);
        m = min(m, abs(L+i));
    }
    if( t < 0 ){
       m = -m;
    }
    cout << t - m << endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code
int calc(int a, int b) {
	int ans = 0;
	for (; a != 0 ;a /= 10) {
		ans += a % 10;
	}
	for (; b != 0 ;b /= 10) {
		ans += b % 10;
	}
	return ans;
}

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	int a,b;
	int ans = INT32_MAX;
	for (a = 1; a < n; a++) {
		b = n-a;
		ans = min(ans,calc(a,b));
	}
	cout << ans << endl;
	return 0;
}



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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m, s;
  cin >> n >> m >> s;
  vector<vector<T>> eds(n);
  rep(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    eds[u].emplace_back(v, a, b);
    eds[v].emplace_back(u, a, b);
  }

  vll cs(n), ds(n);
  rep(i, n) cin >> cs[i] >> ds[i];

  s = min(2501LL, s);

  vvll dist(n, vll(2505, INF));
  dist[0][s] = 0;
  priority_queue<T, vT, greater<T>> pq;
  pq.emplace(0, 0, s);
  while (!pq.empty()) {
    ll dis, v, c;
    tie(dis, v, c) = pq.top();
    pq.pop();
    if (dis > dist[v][c]) continue;
    for (T t : eds[v]) {
      ll u, a, b;
      tie(u, a, b) = t;
      if (c < a) continue;
      ll ndis = dist[v][c] + b;
      if (ndis < dist[u][c - a]) {
        dist[u][c - a] = ndis;
        pq.emplace(ndis, u, c - a);
      }
    }  // t
    ll nc = min(2501LL, c + cs[v]);
    ll ndis = dist[v][c] + ds[v];
    if (ndis < dist[v][nc]) {
      dist[v][nc] = ndis;
      pq.emplace(ndis, v, nc);
    }
  }  // while

  rep(i,n){
    if (i == 0) continue;
    ll ans = LONG_LONG_MAX;
    rep(j, 2502) chmin(ans, dist[i][j]);
    cout << ans << endl;
  }

  return 0;
}


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

int main(){
    long long X,Y;
    cin >> X >> Y;
    long long A,B;
    A=max(X,Y);
    B=min(X,Y);
    if( A-B<=1 ){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import collections

n, m = [int(s) for s in input().split()]

likes = []
for i in range(n):
    like = [int(s) for s in input().split()]
    likes.append(list(set(like[1:])))
# print(likes)

d = set(likes[0])
for like in likes:
    d = d.intersection(set(like))
print(len(d))
# anslist = [True for i in range(1, m+1)]

# for like in likes:
    
    # al = [False for i in range(1, m+1)]
    # for l in like:
    #     al[l] = True
    # for a in al:
    #     if a == False:
    #         anslist[a] = False
# print(anslist)


Measured memory_bytes: 3316
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1].to!long;
    auto A = N.iota.map!(_ => readln.split.map!(to!int).array).array;

    int[] B = [0, M.to!int];
    foreach (a; A) B ~= a;
    B = B.sort().uniq.array;
    auto X = B.length.to!int;
    int[int] comp;
    foreach (i; 0..X) comp[B[i]] = i;

    auto imos = new int[](X + 1);
    foreach (a; A) {
        imos[comp[a[0]]] += 1;
        imos[comp[a[1]]+1] -= 1;
    }
    foreach (i; 0..X) imos[i+1] += imos[i];

    auto st = new SegmentTree!(int, max, 0)(X+1);
    foreach (i; 0..X+1) st.assign(i, imos[i]);

    auto maxL = new int[](X+1);
    auto maxR = new int[](X+1);
    maxL[0] = imos[0];
    foreach (i; 0..X) maxL[i+1] = max(maxL[i], imos[i+1]);
    maxR[X] = imos[X];
    foreach_reverse (i; 0..X) maxR[i] = max(maxR[i+1], imos[i]);

    long ans = 1L << 59;

    foreach (i; 0..N) {
        auto l = comp[A[i][0]];
        auto r = comp[A[i][1]];
        auto left = maxL[l-1];
        auto mid = st.query(l, r) - 1;
        auto right = maxR[r+1];
        auto v = max(left, mid, right);
        long tmp = v * M;
        if (v % 2 == 0) {
            tmp += A[i][1];
        } else {
            tmp += M - A[i][0];
        }
        //writeln([i, A[i][0], A[i][1], left, mid, right, tmp]);
        ans = min(ans, tmp);
    }

    ans.writeln;
}

class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    void add(int pos, T val) {
        pos += offset;
        table[pos] += val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}



Measured memory_bytes: 58728
package main

import (
	"fmt"
	// "strings"
)

func main() {
	var S string
	fmt.Scanf("%s", &S)

	ans := 0
	for index := 0; index < len(S)/2; index++ {
		if S[index:index+1] != S[len(S)-index-1:len(S)-index] {
			// fmt.Println(S[index:index+1], S[len(S)-index-1:len(S)-index], index)
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
 
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<=c&&c<=b)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 3e5 + 5 ;
int n ;
int num[maxn] ;
int sum[maxn] ;
bool judge(int k , int x)
{
	int now = upper_bound(num + 1 , num + n + 1 , x) - num ;
	ll s = sum[now - 1] + 1ll * (n - now + 1) * x ;
	if(s >= 1ll * k * x)
	  return 1 ;
	else
	  return 0 ;
}
int main()
{
	scanf("%d" , &n) ;
	memset(num , 0 , sizeof(num)) ;
	for(int i = 1 ; i <= n ; i ++)
	{
		int x ;
		scanf("%d" , &x) ;
		num[x] ++ ;
	}
	sort(num + 1 , num + n + 1) ;
	sum[0] = 0 ;
	for(int i = 1 ; i <= n ; i ++)
	  sum[i] = sum[i - 1] + num[i] ;
	for(int k = 1 ; k <= n ; k ++)
	{
		int ans = 0 ;
		int l = 0 , r = n / k ;
		int mid ;
		while(l <= r)
		{
			mid = (l + r) / 2 ;
			if(judge(k , mid))
			{
				ans = mid ;
				l = mid + 1 ;
			}
			else
			  r = mid - 1 ;
		}
		printf("%d\n" , ans) ;
	}
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n,j;
  cin>>n;
  string string1,string2;
  cin>>string1>>string2;
 for(j=0;j<n;j++)
 {
     cout<<string1[j]<<string2[j];
 }


    return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map( &:to_i )

G = Array.new( N ) do |i|
	Array.new( N, 0 )
end

M.times do
	u, v = gets.split.map( &:to_i )
	u -= 1
	v -= 1

	G[u][v] = G[v][u] = 1
end

res = 0

Array.new( N - 1 ) do |i|
	i + 1
end .permutation( N - 1 ) do | ord |
	u = 0
	ord.each do |v|
		if G[u][v] == 0 then
			break
		end
		u = v
	end
	res += 1 if u == ord.last
end

puts res


Measured memory_bytes: 2044
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n;
ll a[100005] = {},b[100005] = {};
ll as = 0,bs = 0;

int main(){
    cin >> n;
    rep(i,0,n){
        cin >>a[i];
        as += a[i];
    }
    rep(i,0,n){
        cin >>b[i];
        bs += b[i];
	}

    if(bs < as){
        No;
        ret 0;
    }
    
    ll cnt1 = 0, cnt2 = 0;
	rep(i,0,n){
        if(a[i] > b[i]){
            cnt1 += a[i]-b[i];
        }else if(a[i] < b[i]){
            cnt2 += (b[i]-a[i]+1)/2;
        }
	}  
	auto cnt = max(cnt1, cnt2);
	if(cnt <= bs-as)Yes;
	else No;
	
	return  0;
}


Measured memory_bytes: 384
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        C: chars,
    }
    println!("{}", if "aiueo".contains(C[0]) {"vowel"}else{"consonant"});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define F first
#define S second
typedef pair<int, int> P;

int main(){
    int n, p, map[20][20], matatabi[20][20][20][20];
    P g;    
    cin >> n;
    while(n--){
        int temp, temp2, temp3, temp4;
        cin >> temp >> temp2;
        g = MP(temp, temp2);
        for(int i = 0; i < 20; i++){
             for(int j = 0; j < 20; j++){
                 map[i][j] = 0;
                 for(int k = 0; k < 20; k++){
                     for(int l = 0; l < 20; l++){
                         matatabi[i][j][k][l] = 0;
                     }
                 }
             }
         }
         map[0][0] = 1;
         cin >> p;
         for(int i = 0; i < p; i++){
            cin >> temp >> temp2 >> temp3 >> temp4;
            matatabi[temp][temp2][temp3][temp4] = 1;
            matatabi[temp3][temp4][temp][temp2] = 1;
         }
         for(int i = 0; i <= g.F; i++){
             for(int j = 0; j <= g.S; j++){
                 if(!matatabi[i][j][i + 1][j] && i + 1 <= g.F){
                    map[i + 1][j] += map[i][j];
                 }
                 if(!matatabi[i][j][i][j + 1] && j + 1 <= g.S){
                    map[i][j + 1] += map[i][j];
                 }
            }
         }
         if(map[g.F][g.S]){
             cout << map[g.F][g.S] << endl;
         }
         else{
             cout << "Miserable Hokusai!" << endl;
         }
    }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,K; cin >> A >> B >> K;
    if (A>=K) A-=K;
    else {
        K-=A,A=0;
        if (B>=K) B-=K;
        else B=0;
    }
    cout << A << ' ' << B << endl;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long int llint;

int N;

int main() {
	cin >> N;
	vector<pair<llint, llint> > task(N);

	for (int i = 0; i < N; i++) {
		cin >> task[i].second >> task[i].first;
	}
	sort(task.begin(), task.end());

	llint now = 0;
	bool ans = true;
	for (int i = 0; i < N; i++) {
		now += task[i].second;
		if(now > task[i].first){
			ans = false;
			break;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3328