akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

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

    ll H,W; cin >> H >> W;
    ll ans = INF;

    FOR(i,1,H+1){
        vector<ll> tate, yoko;
        tate.push_back(i * W);
        tate.push_back((H - i)/2 * W);
        tate.push_back((H - i - floor((H-i)/2)) * W);

        yoko.push_back(i * W);
        yoko.push_back((H - i) * floor(W / 2));
        yoko.push_back((H - i) * (W - floor(W/2)));

        sort(tate.begin(), tate.end());
        sort(yoko.begin(), yoko.end());

        //cout << tate[2] << " " << tate[0] << " !! " << yoko[2] << " " << yoko[0] << endl;

        ll res = llmin(tate[2] - tate[0], yoko[2] - yoko[0]);
        if(ans > res) ans = res;
    }

    FOR(i,1,W+1){
        vector<ll> tate, yoko;
        tate.push_back(i * H);
        tate.push_back((W - i)/2 * H);
        tate.push_back((W - i - (W-i)/2) * H);

        yoko.push_back(i * H);
        yoko.push_back((W - i) * floor(H / 2));
        yoko.push_back((W - i) * (H - floor(H/2)));

        sort(tate.begin(), tate.end());
        sort(yoko.begin(), yoko.end());

        //cout << tate[2] << " " << tate[0] << " !! " << yoko[2] << " " << yoko[0] << endl;

        ll res = llmin(tate[2] - tate[0], yoko[2] - yoko[0]);
        if(ans > res) ans = res;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
const int mod = (int)1e9+7;



int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,l;
	cin >>n >>l;
	vector<string> s(n);
	rep(i,n) cin >>s[i];
	sort(all(s));
	rep(i,n) cout << s[i];
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll n,a,max=0,result=0;
cin>>n;
for(ll i=0;i<n;i++){
    cin>>a;
    if(max>a)result+=(max-a);
    else max=a;
}

cout<<result;


return 0;
}






ll gcd(ll a, ll b){

   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }

}

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

#define ll long long int

int main()
{
  
  ll h,n;
  cin>>h>>n;
  ll sum=0;
  while(n--){
  ll temp;
    cin>>temp;
    sum+=temp;
  }
  
  if(sum>=h)
    cout<<"Yes";
  
  else
    cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, x, t;
  cin >> n >> x >> t;
  cout << (n+x-1)/x*t << newl;
  return 0;
}

Measured memory_bytes: 3600
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t1,t2;
    cin >> t1 >> t2;
    ll a1,b1,a2,b2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;
    if(t1*a1+t2*a2==t1*b1+t2*b2){
        cout << "infinity" << endl;
        return 0;
    }
    a1-=b1;
    a2-=b2;
    if((a1>0&&a2>0)||(a1<0&&a2<0)){
        cout << 0 << endl;
        return 0;
    }
    a1*=t1;
    a2*=t2;
    if(a1<0LL){
        a1 *= -1LL;
        a2 *= -1LL;
    } 
    // a1>0 a2<0
    if(a1+a2>0LL){
        cout << 0 << endl;
        return 0;
    }else if(a1+a2==0LL){
        cout << "infinity" << endl;
        return 0;
    }
    ll ans = 1;
    ll t = abs(a1+a2);
    ans += (a1/t)*2;
    //cout << t << " " << ans << endl;
    if(a1%t==0) ans--;
    cout << ans << endl;
    return 0;
}

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

int n, t;
pair<int, int> ta[100];

int main(){
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> ta[i].first >> ta[i].second;
	}
	sort(ta, ta + n);
	for (int i = 0; i < n; i++) {
		if (ta[i].second <= t) {
			cout << ta[i].first << endl;
			return 0;
		}
	}
	cout << "TLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

#define par(x) ((x)>>(1))
#define lc(x) ((x)<<(1))
#define rc(x) ((x)<<(1)|1)

const int MAX = 2000010;
int heap[MAX];
int len;
char cmd[10];

void shiftUp(int p) {
    int parent = par(p);
    if (parent>=1 && heap[parent]<heap[p]) {
        swap(heap[parent], heap[p]);
        shiftUp(parent);
    }
}

void shiftDown(int p) {
    int l = lc(p);
    int r = rc(p);
    int largest = p;
    if (l <= len && heap[l] > heap[p]) {
        largest = l;
    }
    if (r <= len && heap[r] > heap[largest]) {
        largest = r;
    }
    if (largest != p) {
        swap(heap[largest], heap[p]);
        shiftDown(largest);
    }
}

void insert(int x) {
    heap[++len] = x;
    shiftUp(len);
}

int pop() {
    int x = heap[1];
    swap(heap[1], heap[len]);
    len--;
    if (len > 0) {
        shiftDown(1);
    }
    return x;
}

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    len = 0;
    while (~scanf("%s", cmd)) {
        if (strcmp(cmd, "insert") == 0) {
            int num = 0;
            scanf("%d", &num);
            insert(num);
        } else if (strcmp(cmd, "extract") == 0) {
            printf("%d\n", pop());
        } else if (strcmp(cmd, "end") == 0) {
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 7076
import java.util.*

data class Edge(val to: Int, val dist: Int)

fun main(args : Array<String>) {
  val n = readLine()!!.toInt()
  val edges = Array(n) { mutableListOf<Edge>() }
  for (i in 1 until n) {
    var (u, v, w) = readLine()!!.split(' ').map(String::toInt)
    u--
    v--
    val dist = w % 2
    edges[u].add(Edge(v, dist))
    edges[v].add(Edge(u, dist))
  }
  val dist = IntArray(n) { -1 }
  val queue = ArrayDeque<Int>()
  dist[0] = 0
  queue.add(0)
  while (queue.isNotEmpty()) {
    val cur = queue.remove()
    for (e in edges[cur]) {
      if (dist[e.to] != -1) continue
      dist[e.to] = dist[cur] xor e.dist
      queue.add(e.to)
    }
  }
  dist.forEach(::println)
}


Measured memory_bytes: 83248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int one = stdin.nextInt();
		int five = stdin.nextInt() * 5;
		int ten = stdin.nextInt() * 10;
		int fifty = stdin.nextInt() * 50;
		int onehundred = stdin.nextInt() * 100;
		int fivehundred = stdin.nextInt() * 500;

		if((one + five + ten + fifty + onehundred + fivehundred) >= 1000) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}




	}
}

Measured memory_bytes: 26288
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    d, g = f()
    ps = [ f() for i in range(d)]

    ans = 1e9
    for all_solve in range(1<<d):
        score = 0
        max_unused = 0
        cnt_p = 0
        for j in range(d):
            if all_solve&(1<<j):
                score += ps[j][0] * 100 *(j+1) + ps[j][1]
                cnt_p += ps[j][0]
            else:
                max_unused = j
        if score>g:
            ans = min(ans, cnt_p)
            continue
        
        max_unused_score = 100*(max_unused+1)
        if (g - score+ max_unused_score -1 )//max_unused_score > ps[max_unused][0]:
            continue
        else:
            cnt_p += (g - score+ max_unused_score -1 )//max_unused_score
        
        ans = min(ans,cnt_p)
    
    print(ans)


solve()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		for (int i = st.length() - 1; 0 <= i; i--) {
			System.out.print(st.charAt(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
from typing import List


class RollingHash:
    __slots__ = ["source", "length", "base", "mod", "hash", "power"]

    def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7):
        self.source = source
        self.length = len(source)
        self.base = base
        self.mod = mod
        self.hash = self._get_hash_from_zero()
        self.power = self._get_base_pow()

    def _get_hash_from_zero(self) -> List[int]:
        """Compute hash of interval [0, right)."""
        hash_from_zero = [0] * (self.length + 1)
        cur = 0
        for i, c in enumerate(self.source, 1):
            cur = (cur * self.base + ord(c)) % self.mod
            hash_from_zero[i] = cur
        return hash_from_zero

    def _get_base_pow(self) -> List[int]:
        """Compute mod of power of base."""
        power = [1] * (self.length + 1)
        cur = 1
        for i in range(1, self.length + 1):
            cur *= self.base % self.mod
            power[i] = cur
        return power

    def get_hash(self, left: int, right: int):
        """Compute hash of interval [left, right)."""
        return (
            self.hash[right] - self.hash[left] * self.power[right - left]
        ) % self.mod


def abc141_e():
    # https://atcoder.jp/contests/abc141/tasks/abc141_e
    N = int(input())
    S = input().rstrip()
    rh = RollingHash(S)
    ok, ng = 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        flg = False
        memo = set()
        for i in range(N - 2 * mid + 1):
            memo.add(rh.get_hash(i, i + mid))
            if rh.get_hash(i + mid, i + 2 * mid) in memo:
                flg = True
                break
        if flg:
            ok = mid  # next mid will be longer
        else:
            ng = mid  # next mid will be shorter
    print(ok)  # max length of substrings appeared twice or more


if __name__ == "__main__":
    abc141_e()


Measured memory_bytes: 27456
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cstring>
#include <bits/stdc++.h>
#include <search.h>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include<stack>
#include <utility>
using namespace std;
int main()
{
string s;
int n;
cin>>n>>s;
for(int i=0;i<s.length();++i){
    if(s[i]+n<=90) s[i]=s[i]+n;
    else {
            int temp=n;
            temp=n-('Z'-s[i])-1;
            //cout<<n<<endl;
            s[i]='A'+temp;
    }

}
cout<<s;
return 0;
}


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

class Forest {
public:
  int N;
  vector<int> parent;
  vector<int> rank;
  Forest(int N) {
    this->N = N;
    for (int i = 0; i < N; i++) {
      this->parent.push_back(i);
      this->rank.push_back(0);
    }
  }
  
  void unite(int x, int y) {
    if (rank[x] > rank[y]) parent[y] = x;
    else {
      parent[x] = y;
      if (rank[x] == rank[y]) rank[y]++;
    }
  }

  int compress(int x) {
    if (parent[x] != x) parent[x] = compress(parent[x]);
    return parent[x];
  }

  void link(int x, int y) {
    int rootx = compress(x);
    int rooty = compress(y);
    unite(rootx, rooty);
  }

  bool is_same(int x, int y) {
    return compress(x) == compress(y);
  }
};


int main() {
  int n, m;
  cin >> n >> m;
  Forest f = Forest(n);
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    f.link(a, b);
  }
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    if (!f.is_same(0, i)) {
      f.link(0, i);
      cnt++;
    }
  }
  cout << cnt << endl;
  
  return 0;
}

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

int a[180];
int ans[1000001];
int ansb[1000001];
const int INF=1<<28;

int main()
{
	for(int i=1;i<=180;i++)
	{
		a[i-1]=i*(i+1)*(i+2);
		a[i-1]/=6;
	}
	ans[0]=0;
	ansb[0]=0;
	for(int i=1;i<=1000000;i++)
	{
		ans[i]=10;
		ansb[i]=INF;
		for(int j=0;j<180&&i-a[j]>=0;j++)
		{
			ans[i]=min(ans[i],ans[i-a[j]]+1);
			if(j%4==0)ansb[i]=min(ansb[i],ansb[i-a[j]]+1);
		}
	}
	int n;
	while(cin>>n,n)
	{
		cout<<ans[n]<<" "<<ansb[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 10828
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
vv vec;
bitset<100005> vis;
int p[100005];
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int n,m,a,b;
	cin>>n>>m;
	memset(p,-1,sizeof p);
	vec.resize(n);
	while(m--){
		cin>>a>>b;
		a--,b--;
		vec[a].pb(b),vec[b].pb(a);
	}
	queue<int> q;
	q.push(0);
	vis[0]=1;
	while(!q.empty()){
		int f=q.front();
		q.pop();
		for(auto it:vec[f])
			if(!vis[it]){
				p[it]=f,vis[it]=1;
				q.push(it);
			}
	}
	for (int i = 0; i < n; ++i)
		if(!vis[i]){cout<<"No\n";return 0;}
	cout<<"Yes\n";
	for (int i = 1; i < n; ++i)
		cout<<p[i]+1<<"\n";
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 10332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, k;
  cin >> N >> k;
  ll ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans += ans / (k - 1) + 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#pragma O3
using namespace std;
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin>>s;
	long long cnt=0,ans=0,l=s.length();
	for(long long i=0;i<l-1;i++){
    	if(s[i]=='A') cnt++;
	    else if(s[i]=='B'){
			if(cnt){
        		if(s[i+1]=='C'){
	        		ans+=cnt;
	        		i++;
    	    	}
				else cnt=0;
	    	}
	    }
		else cnt=0;
	}
	cout<<ans;
}

Measured memory_bytes: 720
object Main extends App {

  case class State[S, A](run: S => (S, A)) {
    def map[B](f: A => B) = State((s: S) => {
      val (s1, a) = run(s)
      (s1, f(a))
    })

    def flatMap[B](f: A => State[S, B]) = State((s: S) => {
      val (s1, a) = run(s)
      f(a).run(s1)
    })
  }

  object State {
    def unit[S, A](a: A): State[S, A] = State(s => (s, a))
  }

  implicit class ListOps[S, A](stlist: List[State[S, A]]) {
    def sequence: State[S, List[A]] =
      stlist.foldRight(State.unit[S, List[A]](List[A]()))((h: State[S, A], acc: State[S, List[A]]) => h.flatMap(a => acc.map(list => a :: list)))
  }

  def toState(s: String): State[List[Int], Unit] = State((stack: List[Int]) => stack match {
    case (h1 :: h2 :: t) => s match {
      case "*" => ((h2 * h1) :: t, ())
      case "+" => ((h2 + h1) :: t, ())
      case "-" => ((h2 - h1) :: t, ())
      case "/" => ((h2 / h1) :: t, ())
      case i   => (i.toInt :: stack, ())
    }
    case _ => (s.toInt :: stack, ())
  })

  val ans = readLine.split(" ")
    .toList
    .map(toState)
    .sequence
    .run(List[Int]())
    ._1.head
  println(ans)
}


Measured memory_bytes: 44108
#include<iostream>
#include<string>
#define NO {cout << "No" << endl; return 0;}
using namespace std;

int main(){
  int a,b;
  string s;
  cin >> a >> b >> s;
  
  if(s.length()!=a+b+1)NO

  for(int i=0;i<s.length();i++){
    if(i==a) {if(s[i]!='-') NO}
    else if(s[i]<48 or 57<s[i]) NO
  }
  cout << "Yes" << endl;

  return 0;
}

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

int main(){
  long long N;
  long long K;
  cin >> N >> K;
  long long c[100000]={};
  long long a,b;
  for (long long i=0;i<N;i++){
    cin >> a >> b;
    c[a-1]+=b;
  }
  long long sum=c[0];
  long long ans=0;
  while(sum<K){
    ans++;
    sum+=c[ans];
  }
  cout << ans+1 << endl;
}


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

#define rep(i,n) for(int i = 1; i <= (n); i++)
#define asort(x) sort(x.begin(),x.end())

int main() {
    ll a,b,v,w,t,a_res,b_res;
    cin>>a>>v>>b>>w>>t;
    if(a>b) {
        v = -v;
        w = -w;
    }
    a_res = a + v * t;
    b_res = b + w * t;
    if((a < b && a_res >= b_res) || (a > b && a_res <= b_res)) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

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;
}

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    vector<int> a(3);
    //vector<int> data(i, 0);
    a[0] = A;
    a[1] = B;
    a[2] = C;
    sort(a.begin(), a.end());
    if (a[0] == a[1] && a[1] != a[2]) {
        cout << "Yes" << endl;
        return 0;
    }

    if (a[1] == a[2] && a[0] != a[1]) {
        cout << "Yes" << endl;
        return 0;
    }

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

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Mon Jan 28 13:05:39 2019
//
package main

import (
	"fmt"
	"sort"
)

// min ...
func min(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] < m {
			m = args[i]
		}
	}
	return m
}

func main() {
	arr := []int{0, 0, 0}
	fmt.Scan(&arr[0], &arr[1], &arr[2])
	sort.Ints(arr)

	diff1 := arr[2] - arr[1]
	diff2 := arr[2] - arr[0]
	if diff1%2 == 0 && diff2%2 == 0 {
		fmt.Println((diff1 + diff2) / 2)
	} else if diff1%2 == 0 || diff2%2 == 0 {
		fmt.Println((diff1+diff2+1)/2 + 1)
	} else {
		fmt.Println((diff1-1+diff2-1)/2 + 1)
	}
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL ) x = x->left;
  return x;
}
Node treeMaximum(Node x){
  while( x->right != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);
  if ( y->left != NIL ) x = y->left;
  else x = y->right;

  if ( x != NIL ) x->parent = y->parent;

  if ( y->parent == NIL ){
    root = x;
  } else {
    if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
  }

  if ( y != z ){
    z->key = y->key;
  }

  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( strcmp(com, "findMin") == 0 ){
	Node minn = treeMinimum(t);
	printf("%d\n", minn->key);
      } else if ( strcmp(com, "findMax") == 0 ){
	Node maxn = treeMaximum(t);
	printf("%d\n", maxn->key);
      } else {
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( strcmp(com, "delete") == 0 ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20500
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int n;
    cin >> n;

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

    int64_t c = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            int b = 0;
            for (int k = 0; k < n; k++) {
                if (k == i || k == j) continue;
                int d = a[i][j] - (a[i][k] + a[j][k]);

                if (d > 0) {
                    cout << -1 << endl;
                    return 0;

                } else if (d == 0) {
                    b = 1;
                }
            }
            if (!b) c += a[i][j];
        }
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 640
use std::cmp;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


fn main() {
    let nk :Vec<usize>  = read_vec();
    let n = nk[0];
    let k = nk[1];

    let v : Vec<i32> = read_vec();

    let result = solve(n, k, &v);
    println!("{}", result);
}

fn solve(n : usize, k: usize, v:&[i32]) -> i32 {
    let s = cmp::min(n, k);
    let mut max : i32 = 0;
    for a in 0..s+1 {
        for b in 0..(s - a)+1 {
            let mut w :Vec<i32> = Vec::with_capacity(s);
            w.extend_from_slice(&v[0..a]);
            w.extend_from_slice(&v[n-b..n]);
            w.sort();
            let rest = k - (a + b);
            let limit = cmp::min(rest, a+b);
            let mut pos = 0;
            for i in 0.. limit {
                if w[i] >= 0 {
                    break;
                }
                pos += 1;
            }
            let total : i32 = w[pos..].iter().sum();
            //println!("{},{},{} -> {}", a, b, pos, total);
            if total > max {
                max = total;
            }
        }
    }
    return max;
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cassert>
#include <algorithm>
using namespace std;

const int MAXN = 20005;

int N;
int p[MAXN];
int a[MAXN], b[MAXN];
int delta[MAXN];

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    scanf("%d", p + i);
  
  int pos = 0;
  for (int i = 1; i <= N; i++)
    if (p[i] == 1)
      pos = i;
      
  for (int i = 1; i <= N; i++)
    delta[p[i] - 1] = i - pos;
  
  for (int i = N; i; i--)
    delta[i] -= delta[i - 1];
  
  int c = *max_element(delta + 1, delta + N + 1) + 1;
  
  for (int i = 1; i <= N; i++) {
    a[i] = c;
    b[i] = c - delta[i];
  }
  
  for (int i = 1; i <= N; i++)
    a[i] += a[i - 1];
  for (int i = N; i; i--)
    b[i] += b[i + 1];
  
  for (int i = 1; i <= N; i++)
    printf("%d ", a[i]);
  puts("");
  for (int i = 1; i <= N; i++)
    printf("%d ", b[i]);
  puts("");
  
  for (int i = 1; i < N; i++)
    assert(a[p[i]] + b[p[i]] < a[p[i + 1]] + b[p[i + 1]]);
  
  return 0;
}    

Measured memory_bytes: 896
n = input()
k = int(input())
l = len(n)
dp0 = [[0 for _ in range(k+1)] for i in range(l+1)]
dp1 = [[0 for _ in range(k+1)] for i in range(l+1)]
dp0[0][0] = 1
for i in range(l):
  t = int(n[i])
  for j in range(k+1):
    if j == 0:
      dp0[i+1][j] = 0 if t != 0 else dp0[i][j]
      dp1[i+1][j] = dp1[i][j]
      if t != 0:
        dp1[i+1][j] += dp0[i][j]
    else:
      if t != 0:
        dp0[i+1][j] =  dp0[i][j-1]
      else:
        dp0[i+1][j] = dp0[i][j]
      dp1[i+1][j] = dp1[i][j] + dp1[i][j-1]*9
      if t != 0:
        dp1[i+1][j] += dp0[i][j]
      dp1[i+1][j] += dp0[i][j-1]*max(t-1, 0)
print(dp0[l][k] + dp1[l][k])

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    int n;
    while(true) {
        cin >> n;
        if(n == 0) break;
        double ndis=0.0,avg=0.0,sum=0.0;
        int s[n];
        for(int i = 0; i < n; ++i) {
            cin >> s[i];
            sum += s[i];
        }
        avg = sum/n;
        for(int i = 0; i < n; ++i) {
            ndis += pow(s[i]-avg, 2);
        }
        printf("%lf\n", sqrt(ndis/n));
    }
    return 0;
}


Measured memory_bytes: 3212
H1, M1, H2, M2, K = map(int, input().split())

getUpTime = H1 * 60 + M1
goToBed = H2 * 60 + M2

DisposableTime = goToBed - getUpTime
if K > DisposableTime:
    print(0)
else:
    print(DisposableTime - K)

Measured memory_bytes: 9112
import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val n = Array.ofDim[Int](N + 1)
    rep(N, 1) { i =>
      i to N foreach { j =>
        if (j % i == 0) n(j) += 1
      }
    }

    var ans = 0
    rep(N, 1) { i =>
      if (i % 2 == 1 && n(i) == 8) ans += 1
    }

    out.println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 25416
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

ll n;
typedef struct rest {
    ll number;
    string name;
    ll score;
} rest;
vector<rest> v;
bool comparison(const rest& p1, const rest& p2) {
    if (p1.name < p2.name) return true;
    if (p1.name == p2.name) {
        if (p1.score > p2.score) return true;
    }
    return false;
}
int main(void) {
    ll i, score=0;
    string s;
    rest r;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> r.name >> r.score;
        r.number = i;
        v.push_back(r);
    }
    sort(v.begin(), v.end(), comparison);
    for (i = 0; i < n; i++) {
        cout << v[i].number << endl;
    }    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if ( a <= 5 ) cout << 0 << endl;
  else if ( a <= 12) cout << b / 2 << endl;
  else cout << b << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        A[a].append(b)
        A[b].append(a)

    q = deque()
    for a in A[1]:
        q.append(a)

    while len(q) > 0:
        a = q.popleft()
        if N in A[a]:
            return 'POSSIBLE'

    return 'IMPOSSIBLE'





if __name__ == '__main__':
    print(main())


Measured memory_bytes: 38784
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s, t;
    cin >> s >> t;
    bool res = false;
    if (s.length() == t.length()) {
        s += s;
        if (s.find(t) != string::npos) {
            res = true;
        }
    }
    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

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

struct d{
  char s[20];
  int p;
  int cc;
};

int main(){
   int n;
  	char buf[17];
   scanf("%d", &n);
   struct d ss[n];
	for(int i=0;i<=n;i++){
      		scanf("%s %d", ss[i].s, &ss[i].p);
      		ss[i].cc=i+1;
    }
  	for(int i=0;i<n-1;i++){
      for(int j=n-1;j>i;j--){
        if(strcmp(ss[j].s,ss[j-1].s)<0){
         	//printf("dd\n");
          	struct d t = ss[j];
          	ss[j] = ss[j-1];
          	ss[j-1] = t;
        } else if(strcmp(ss[j].s,ss[j-1].s)==0){
          if(ss[j].p > ss[j-1].p){
          	struct d t = ss[j];
          	ss[j] = ss[j-1];
          	ss[j-1] = t;
          }
        }
      }
    }
	for(int i=0;i<n;i++)
  		printf("%d\n", ss[i].cc);
	return 0;
 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<LL,LL>
#define fi first
#define se second
using namespace std;
il LL read() {
	LL res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 3e5+5; int n,p[N],stk[N],top;
	il bool solve(int l,int r) {
		int mx = 0,x = top = 0; rep(i,l,r) if ((i-l)&1) {if (p[i] < x) return 1; x = p[i];}
			else {if (p[i] < mx) {while(top && stk[top] < p[i]) --top; stk[++top] = p[i];} else mx = p[i]; if (top > 1) return 1;} return 0;
	}
	void main() {
		int l = 1,r = 0; n = read(); rep(i,1,n) if (((p[i] = read())-i)&1) {puts("No"); return;}
		rep(i,1,n) if ((r = max(r,p[i])) == i) {if (solve(l,r)) {puts("No"); return;} l = i+1;} puts("Yes");
	}
}
int main() {
	qiqi::main(); return 0;
}

Measured memory_bytes: 4812
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
#1,2,3,...,Nまでの順列の合計
#実はN(N+1)//2で表せる
def sigma(n):
    return n*(n+1)//2

print(sigma(n-1))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  if (b >= a) cout << a;
  else cout << a-1;
    return 0;
}

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

using namespace std;
#define int long long
using ld = long double;

signed main() {
    int n;
    cin >> n;
    int arr[n+1];
    int i, j;
    for(i=1;i<=n;i++)
        cin >> arr[i];
    int dp[n+1][n+1][2];
    for(i=0;i<=n;i++)
        for(j=0;j<=n;j++)
            dp[i][j][0] = dp[i][j][1] = 0;
    for(i=1;i<=n;i++)
    {
        dp[i][i][0] = arr[i], dp[i][i][1] = -arr[i];
    }
    for(i=1;i<n;i++)
        dp[i][i+1][0] = max(arr[i] - arr[i+1], arr[i+1] - arr[i]), dp[i][i+1][1] = min(arr[i]-arr[i+1], arr[i+1]-arr[i]);
    for(int len = 2;len < n;len++)
    {
        for(i=1;i<=(n-len);i++)
        {
            int j = i + len;
            dp[i][j][0] = max(dp[i][j-1][1] + arr[j], dp[i+1][j][1] + arr[i]);
            dp[i][j][1] = min(dp[i][j-1][0] - arr[j], dp[i+1][j][0] - arr[i]);
        }
    }
    cout << dp[1][n][0] << '\n';
}

Measured memory_bytes: 144420
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<ArrayList<Integer>> g = new ArrayList<ArrayList<Integer>>();
		for(int i=0; i<n; i++) {
			g.add(new ArrayList<Integer>());
		}
		for(int i=0; i<n-1; i++) {
			int a = sc.nextInt(); a--;
			int b = sc.nextInt(); b--;
			g.get(a).add(b);
			g.get(b).add(a);
		}

		int d[][] = new int[2][n];
		bfs(g, d[0], 0);
		bfs(g, d[1], n-1);

		int fcnt=0;
		int scnt=0;
		for(int i=0; i<n; i++) {
			if(d[0][i]<=d[1][i]) {
				fcnt++;
			}else {
				scnt++;
			}
		}
		if(fcnt>scnt) {
			System.out.println("Fennec");
		}else {
			System.out.println("Snuke");
		}
		sc.close();
	}

	private void bfs(ArrayList<ArrayList<Integer>> g, int d[], int root) {
		boolean used[] = new boolean[g.size()];
		d[root]=0;
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.add(root);
		used[root]=true;
		while(!q.isEmpty()) {
			int s = q.poll();
			for(int t : g.get(s)) {
				if(used[t]) continue;
				used[t]=true;
				d[t] = d[s]+1;
				q.add(t);
			}
		}
	}
}



Measured memory_bytes: 101948
#include "bits/stdc++.h"
#define all(v) (v).begin(), (v).end()
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define int long long
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}
const int N = 1e6;
int fac[N], inv[N];

int cal(int n, int m)
{
	if (n < 0 || m < 0 || m > n)
		return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
signed main()
{
	
	int f=1;
	int n;cin>>n;
	rep(i,1,n){
		int x;cin>>x;
		if(x%2==0 && x%3!=0 && x%5!=0)f=0;
	}
	if(f)
		puts("APPROVED");
	else
		puts("DENIED");

	getchar();
	getchar();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[103][100003],n,k,a[103],mod=1000000007;
int main(){
	cin>>n>>k;
	dp[0][k]=1;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(int j=k;j>=max(k-a[i],0);j--)
		{
			cnt=(dp[i-1][j]+cnt)%mod;
			dp[i][j]=cnt;
		}
		for(int j=max(k-a[i],0)-1;j>=0;j--){
			cnt=((cnt+dp[i-1][j]-dp[i-1][j+a[i]+1])%mod+mod)%mod;
			dp[i][j]=cnt;
		}
	}
	cout<<dp[n][0];
}

Measured memory_bytes: 39296
unittest
{
//	assert( [ "4 1" ].parse.expand.solve == "2 3" );
//	assert( [ "7 3" ].parse.expand.solve == "1 6\n2 5\n3 4" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], nm[ 1 ] );
}

auto solve( long n, long m )
{
	// nが偶数だと1つ余るので捨てる
	n -= ( n % 2 == 0 );
	
	// 2つの番号間の距離が n/2未満 かつ ユニーク になるように選べば、同じ対戦が起きなくなる
	auto anss = new long[ 2 ][ m ];
	auto h = ( m + 1 ) / 2 * 2;
	foreach( i, ref ans; anss[ 0 .. ( $ + 1 ) / 2 ] )
	{
		auto a = i;
		auto b = h - 1 - i;
		ans = [ 1 + a, 1 + b ];
	}
	foreach( i, ref ans; anss[ ( $ + 1 ) / 2 .. $ ] )
	{
		auto a = h + i;
		auto b = n - 1 - i;
		ans = [ 1 + a, 1 + b ];
	}
	return anss.map!( ( x ) => x.to!( string[] ).join( " " ) ).join( "\n" );
}


Measured memory_bytes: 6308
ans_list = []

while True:
    n,r = map(int,input().split())
    if (n,r) == (0,0):
        break
    pc = [list(map(int,input().split())) for _ in range(r)]
    mt = list(range(1,n+1)[::-1])

    def cal(p,c):
        global mt
        mt = mt[p-1:p-1+c] + mt[:p-1] + mt[p-1+c:]
    
    for p,c in pc:
        cal(p,c)
    
    ans = mt[0]
    ans_list.append(ans)

for ans in ans_list:
    print(ans)


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

int main() {
	int x[10000];
	int y[10000];
	int i;
	for ( i = 0; i < 10000; i++) {
		cin >> x[i]  >> y[i] ;
		if (x[i] == 0 && y[i] == 0) break;
	}

	for (int j = 0; j < i; j++) {
		if (x[j] < y[j]) cout << x[j] << " " << y[j] << endl;
		else if (x[j] > y[j]) cout << y[j] << " " << x[j] << endl;
		else if (x[j] == y[j]) cout << x[j] << " " << y[j] << endl;
	}



	
	return 0;
}


Measured memory_bytes: 3004
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

const int MOD = 1000 * 1000 * 1000 + 7;

int N;
int sqrtN;

struct query {
	int l,
		r,
		idx,
		res;
};

int v[500000];
query queries[500000];

struct cmp {
	bool operator()(query const& q1, query const& q2) {
		if (q1.l / sqrtN != q2.l / sqrtN) {
			return q1.l / sqrtN < q2.l / sqrtN;
		}
		return q1.r < q2.r;
	}
};

struct cmp2 {
	bool operator()(query const& q1, query const& q2) {
		return q1.idx < q2.idx;
	}
};

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

	int n, q;
	cin >> n >> q;

	for (int i = 0; i < n; ++i) cin >> v[i];
	for (int i = 0; i < q; ++i) {
		cin >> queries[i].l >> queries[i].r;
		--queries[i].l;
		--queries[i].r;
		queries[i].idx = i;
	}

	N = n;
	sqrtN = sqrt(n);

	sort(queries, queries + q, cmp());

	int currL = 0, currR = 0; 

	vi colores(500001);
	int dif = 0;

	for (int i = 0; i < q; i++) {
		while (currR <= queries[i].r) {
			if (colores[v[currR]] == 0) {
				++dif;
			}
			++colores[v[currR]];
			
			currR++;
		}
		while (currR > queries[i].r + 1) {// Remove elements of previous range.
			if (colores[v[currR - 1]] == 1) {
				--dif;
			}
			--colores[v[currR - 1]];
			
			currR--;// sum of [L, R] is in currSum
		}
		while (currL < queries[i].l) { // Remove extra elements of previous range.
			if (colores[v[currL]] == 1) {
				--dif;
			}
			--colores[v[currL]];
			
			currL++;
		}
		while (currL > queries[i].l) {// Add Elements of currentRange
			if (colores[v[currL - 1]] == 0) {
				++dif;
			}
			++colores[v[currL - 1]];
			
			currL--;
		}
		

		queries[i].res = dif;
	}

	sort(queries, queries + q, cmp2());

	for (int i = 0; i < q; ++i) cout << queries[i].res << '\n';


	return 0;
}

Measured memory_bytes: 15448
N,M=map(int, input().split())
p=[0]*M
S=['']*M
for i in range(M):
    p[i],S[i]=input().split()
A=[0]*N
count=[0]*N
cnt=0
for i in range(M):
    tmp=int(p[i])-1
    if S[i]=='AC':
        A[tmp]=1
    if S[i]=='WA':
        if A[tmp]==0:
            count[tmp]+=1
countA=0
for i in range(N):
    if A[i]==1:
        countA+=1
        cnt+=count[i]
print(countA, cnt)


Measured memory_bytes: 17268
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '9') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define maxn 100010
using namespace std;
typedef long long LL;
LL z[maxn],sum[maxn],ans;
LL max(LL x,LL y){
	return x>y?x:y;
}
int main(){
#ifdef xunzhen
	freopen("count.in","r",stdin);
	freopen("count.out","w",stdout);
#endif
	int n,k;
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		sum[i]=sum[i-1]+t;
		if (t>0) z[i]=z[i-1]+t;
		else z[i]=z[i-1];
	}
	for (int i=0;i<=n-k;i++){
		int j=i+k;
		LL a=max(sum[j]-sum[i],0);
		LL b=z[i]+z[n]-z[j];
		ans=max(ans,a+b);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	string t;
  	cin >> t;
  
  	rep(i, t.size()){
    	if(t[i] == '?') t[i] = 'D'; 
    }
  
  	cout << t << endl;
}

Measured memory_bytes: 3748