akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll n,k;cin>>n>>k;
    ll m=2*(ll)(sqrt(n));
    vvi dp(k,vi(m)),sum(k,vi(m));
    vi v(m);
    rep(i,sqrt(n)){
        v[i]=i+1;
        v[i+m/2]=n/((m/2)-i);
    }
    rep(i,m){
        if(i==0)dp[0][i]=v[i];
        else dp[0][i]=v[i]-v[i-1];
        if(i==0)sum[0][i]=dp[0][i];
        else sum[0][i]=(sum[0][i-1]+dp[0][i])%mod;
    }
    REP(i,1,k){
        rep(j,m){
            if(j==0)dp[i][j]=(sum[i-1][m-j-1]*v[j])%mod;
            else dp[i][j]=(sum[i-1][m-j-1]*(v[j]-v[j-1]))%mod;
            if(j==0)sum[i][j]=dp[i][j];
            else sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
        }
    }
  /*cout<<m<<endl;
  rep(i,m)cout<<v[i]<<' ';
  cout<<endl;
  rep(i,k){
    rep(j,m)cout<<dp[i][j]<<' ';
    cout<<endl;
  }*/
    cout<<sum[k-1][m-1]<<endl;
}

Measured memory_bytes: 99728
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	int K,T;
	int[] a;

	public void solve() {
		K = nextInt();
		T = nextInt();
		a = new int[T];
		for(int i = 0;i < T;i++){
			a[i] = nextInt();
		}

		PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
		for(int i = 0;i < T;i++){
			pq.add(-a[i]);
		}

		while(pq.size() > 1){
			int max1 = -pq.poll();
			int max2 = -pq.poll();
			pq.add(-(max1 - max2));
		}

		out.println(Math.max(0,(-pq.poll()) - 1));
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  vector<int> v(3, 0);
  cin >> v[0] >> v[1] >> v[2];
  sort(all(v));
  cout << abs(v[1] - v[0]) + abs(v[2] - v[1]) << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

const ll mod = 1000000007LL;
ll dp[10][110];
int memo[1<<10];
int H,W,K;

bool validate(int bit) {
  if( memo[bit] != -1 ) return memo[bit];
  rep(i,W-2) {
    if( ( (bit>>i) & 1 ) && ( (bit>>(i+1)) & 1 ) ) {
      return memo[bit] = false;
    }
  }
  return memo[bit] = true;
}

int main() {
  memset(memo,-1,sizeof memo);
  cin >> H >> W >> K;
  dp[0][0] = 1;
  rep(y,H) {
    rep(x,W) {
      if( dp[x][y] == 0 ) continue;
      rep(state,(1<<(W-1))) {
	if( !validate(state) ) continue;
	if( (state>>x) & 1 ) {
	  ( dp[x+1][y+1] += dp[x][y] ) %= mod;
	} else if( x-1 >= 0 && (state>>(x-1)) & 1 ) {
	  ( dp[x-1][y+1] += dp[x][y] ) %= mod;
	} else {
	  ( dp[x][y+1] += dp[x][y] ) %= mod;
	}
      }
    }
  }
  cout << dp[K-1][H] << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
n = int(input())
#d, t, s = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

mod = 10 ** 9 + 7

sumlist= sum(a)
x = []
for i in range(n):
    x.append(sumlist - a[i])
    sumlist -= a[i]

ans = 0
for i in range(n):
    ans += (a[i] * x[i])
    ans %= mod

print(ans)





Measured memory_bytes: 49504
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, m;
    cin >> n >> m;
    vector<PL> p(n);
    REP(i,n){
        p[i].first = in();
        p[i].second = in();
    }
    sort(ALL(p));
    ll ans = 0;
    REP(i,n){
        ll x = min(p[i].second, m);
        m -= x;
        ans += x * p[i].first;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

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

  vector<ll> divn = divisor(n);
  ll ans = 0;
  FOR(i, 1, divn.size()) {
    ll res = n;
    while (res % divn[i] == 0) res /= divn[i];
    if ((res - 1) % divn[i] == 0) ans++;
  }
  vector<ll> divn2 = divisor(n - 1);
  ans += divn2.size() - 1;
  cout << ans << endl;




  
  return 0;
}

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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  int distance[4];
  distance[0] = 0 + x - r;
  distance[1] = W - x - r;
  distance[2] = 0 + y - r;
  distance[3] = H - y - r;
  for (auto d : distance) {
    if (d < 0) {
      cout << "No" << endl;
      return 0;
        }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3096
#include <cstdio>
using namespace std;
int n;
long long x;
inline int left(int p){
	return (p-2+n)%n+1;
}
int a[2018];
int best[2018][2018];
unsigned long long ans=-1;
int min(int g,int h){
	return g<h?g:h;
}
int main(){
	scanf("%d%lld",&n,&x);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),best[0][i]=a[i];
	for(int _=1;_<n;_++){//预处理出若干轮之内最小值 
		for(int i=1;i<=n;i++){
			best[_][i]=min(best[_-1][i],best[_-1][left(i)]);
		}
	}
	unsigned long long tmp;
	for(int _=0;_<n;_++){
		tmp=_*x;
		for(int i=1;i<=n;i++){
			tmp+=best[_][i];
		}
		if(ans>tmp)ans=tmp;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 16000
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


diff_row = [-1,0,0,1]
diff_col = [0,-1,1,0]

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

def rangeCheck(row,col):
    global H,W
    return row >= 0 and row <= H-1 and col >= 0 and col <= W-1

loc = [None]*(N+1)

base_map = [input() for _ in range(H)]
for row in range(H):
    for col in range(W):
        if base_map[row][col] in ["." ,"X"]:
            continue
        if base_map[row][col] == "S":
            loc[0] = (row,col)
        else:
            loc[int(base_map[row][col])] = (row,col)

ans = 0
for i in range(N):
    start_row,start_col = loc[i]
    goal_row,goal_col = loc[i+1]
    table = [[BIG_NUM]*W for _ in range(H)]

    table[start_row][start_col] = 0
    Q = deque()
    Q.append((start_row,start_col))

    while len(Q) > 0:
        tmp_row,tmp_col = Q.popleft()

        if tmp_row == goal_row and tmp_col == goal_col:
            ans += table[goal_row][goal_col] #重みは全て1なので、最短経路は最初にgoalに到達するはず
            break

        for k in range(4):
            adj_row = tmp_row+diff_row[k]
            adj_col = tmp_col+diff_col[k]
            if rangeCheck(adj_row, adj_col) == False or base_map[adj_row][adj_col] == "X"  \
                    or table[adj_row][adj_col] <= table[tmp_row][tmp_col]+1:
                continue
            table[adj_row][adj_col] = table[tmp_row][tmp_col]+1
            Q.append((adj_row,adj_col))

print("%d"%(ans))




Measured memory_bytes: 43076
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    int ans=30;
    for(int i=0; i<n; i++){
        int j=0;
        for(j=0; j<ans; j++){
            if(a[i]%2!=0){
                break;
            }
            a[i]/=2;
        }
        ans=min(j, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define F first
#define S second

using namespace std;

typedef long long ll;

ll n, ans;
pair<ll, ll> a[100005], b[100005];
ll cp[100005];
vector<pair<ll, pair<ll, ll> > > ve;

ll fnd(ll p)
{
    if(cp[p] == p) return p;
    return cp[p] = fnd(cp[p]);
}

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld", &a[i].F, &b[i].F);
        cp[i] = i;
        a[i].S = b[i].S = i;
    }
    sort(a, a + n);
    sort(b, b + n);
    for(ll i = 0; i < n - 1; i++)
    {
        ve.push_back(make_pair(a[i + 1].F - a[i].F, make_pair(a[i].S, a[i + 1].S)));
        ve.push_back(make_pair(b[i + 1].F - b[i].F, make_pair(b[i].S, b[i + 1].S)));
    }
    sort(ve.begin(), ve.end());
    for(ll i = 0; i < ve.size(); i++)
    {
        if(fnd(ve[i].S.F) != fnd(ve[i].S.S))
        {
            cp[fnd(ve[i].S.F)] = fnd(ve[i].S.S);
            ans += ve[i].F;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 12400
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            var c = new long[n];
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                c[a[i] - 1]++;
            }
            for (int i = 0; i < n; i++)
            {
                ans += c[i]* (c[i] -1 ) / 2;
            }
            for (int i = 0; i < n; i++)
            {
                if (c[a[i] - 1] >= 2)
                    WriteLine(ans - c[a[i] - 1] + 1);
                else
                    WriteLine(ans);
            }
            














          
            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 41836
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
ll int b[100001];
ll int tmp;
vector<ll int> v, s, t;
int res;
bool update;

int main(){
    scanf("%d", &N);

    REP(i, N){
        scanf("%lld", &tmp);
        v.push_back(tmp);
    }
    REP(i, N){
        scanf("%lld", &tmp);
        s.push_back(tmp);
    }
    REP(i, N){
        scanf("%lld", &tmp);
        t.push_back(tmp);
    }

    sort(v.begin(), v.end(), greater<ll int>());
    sort(s.begin(), s.end(), greater<ll int>());
    sort(t.begin(), t.end(), greater<ll int>());

    b[0] = 0;

    res=0;
    REP(i, N){
        update = false;
        for(int j=res;j<N;++j){
            if(t[j] <= s[i]){
                b[i+1] = b[i] + j;
                res = j;
                update = true;
                break;
            }
        }
        if(!update){
            res = N;
            b[i+1] = b[i] + N;
        }
    }

    ll int ans = 0;
    res=0;
    REP(i, N){
        update = false;
        for(int j=res;j<N;++j){
            if(s[j] <= v[i]){
                ans += b[j];
                res = j;
                update = true;
                break;
            } 
        }
        if(!update){
            res = N;
            ans += b[N];
        }
    }

    printf("%lld", ans);

	return 0;
}


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

public class Main {

	public static void main(String[] args)
			throws java.io.IOException{
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()){
			int a =scan.nextInt();
			int b =scan.nextInt();
			System.out.println((Integer.toString(a+b)).length());
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  int s_sum = 0;
  int i;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    s_sum += s[i];
  }

  if (s_sum % 10 == 0) {
    sort(s.begin(), s.end());
    for (i = 0; i < n; i++) {
      if (s[i] % 10 != 0) {
        s_sum -= s[i];
        break;
      }
      if (i == n - 1) {
        s_sum = 0;
      }
    }
  }
  cout << s_sum << endl;
  return 0;
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==7){
		if(b==5&&c==5){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}else if(a==5){
		if((b==7&&c==5)||(b==5&&c==7)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define ll long long        
using namespace std;
 
void scan()
{
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
 
}
const int N = 1e6 + 500;
const int mod = 1e9 + 7;

int pref[N];
int main() 
{
    scan();    
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
    	int l, r;
    	cin >> l >> r;
    	pref[l]++;
    	pref[r + 1]--;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
    	pref[i] += pref[i - 1];
    	if (pref[i] == m)
    	{
    		ans++;
    	}
    }
    cout << ans;
}     
//JUDGE_ID: 295965SY
//Tis I

Measured memory_bytes: 4008
main = interact $ unlines . map (show . persimmon) . read' . lines
 where
  read' ("0":_) = []
  read' (n:wh:xs) = (read n, (w,h), (s,t), map (map read . words) ps) : read' xs'
   where
    [w,h] = map read (words wh)
    [s,t] = map read (words st)
    (ps,(st:xs')) = splitAt (read n) xs

persimmon :: (Int, (Int,Int), (Int,Int), [[Int]]) -> Int
persimmon (n,(w,h),(s,t),ps)
 | s*t == 1 || n == 1 = 1
 | otherwise = maximum (map countTree estate)
 where
  estate = [((x1,y1),(x2,y2)) | x1<-[1..w-s+1], y1<-[1..h-t+1], let (x2,y2)=(x1+s-1,y1+t-1)]
  countTree ((x1,y1),(x2,y2)) = length $ filter (\[px,py] -> x1 <= px && px <= x2 && y1 <= py && py <= y2) ps

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

using namespace std;

int main() {

    string S; int K;  cin >> K >> S;

    if(S.size() <= K) cout << S << endl;
    else{
        for(int i = 0; i < K; i++) {
            cout << S.at(i);
        }
        cout << "..." << endl;
    }



    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	string s;
	cin >> s;
	int a = INF, z = INF;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' && a == INF)a = i;
		if (s[s.size() - 1 - i] == 'Z' && z == INF)z = s.size() - 1 - i;
	}
	cout << z - a + 1;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);

void dfs(vector<vector<int>> edge, vector<int> &dist, int n, int d){
  stack<int> st;
  dist[n] = d;
  st.push(n);

  while(!st.empty()){
    int m = st.top(); st.pop();
    REP(i,edge[m].size()){
      if(dist[edge[m][i]]!=-1)continue;
      dist[edge[m][i]] = dist[m] + 1;
      st.push(edge[m][i]);
    }
  }
}

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

  vector<vector<int>> edge(N);
  REP(i,N-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  vector<int> dist1(N,-1);
  vector<int> dist2(N,-1);

  dfs(edge, dist1, 0, 1);
  dfs(edge, dist2, N-1, 1);

  // REP(i,dist1.size()){
  //   cout << i << " " << dist1[i] << endl;
  // }
  // cout << endl;
  // REP(i,dist2.size()){
  //   cout << i << " " << dist2[i] << endl;
  // }

  int cnt_b=0;;
  int cnt_w=0;
  REP(i,N){
    if(dist1[i] <= dist2[i]){
      cnt_b++;
    }else{
      cnt_w++;
    }
  }
  if(cnt_b>cnt_w){
    cout << "Fennec" << endl;
  }else{
    cout << "Snuke" << endl;
  }
}



Measured memory_bytes: 11992
#include<iostream>
#include<algorithm>

using namespace std;

int h,w,K;
char grid[11][1010];
int tmpg[11][1010];

int main()
{
    cin>>h>>w>>K;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>grid[i][j];
        }
    }
    int cnt=1<<30,tmp=0,x[11],chk,lst;
    for(int i=(1<<(h-1));i<(1<<h);i++){
        tmp=0;
        for(int j=0;j<(h-1);j++)
            tmp+=(!!(i&(1<<j)));
        for(int j=0;j<w;j++){
            lst=0;
            for(int k=0;k<h;k++){
                tmpg[k][j]=0;
                if(i&(1<<k)){
                    for(int l=lst;l<=k;l++){
                        tmpg[k][j]+=(grid[l][j]-'0');
                    }
                    if(tmpg[k][j]>K){
                        tmp=1<<30;
                        break;
                    }
                    lst=k+1;
                }
            }
            if(tmp==(1<<30))
                break;
        }
        if(tmp==(1<<30))
            continue;
//        for(int k=0;k<h;k++){
//            cout<<!!(i&(1<<k))<<" ";
//            for(int j=0;j<w;j++){
//                cout<<tmpg[k][j]<<" ";
//            }
//            cout<<endl;
//        }
        for(int k=0;k<h;k++)
            x[k]=0;
        for(int j=0;j<w;j++){
            for(int k=0;k<h;k++){
                if(i&(1<<k)){
                    x[k]+=tmpg[k][j];
                    if(x[k]>K){
                        tmp++;
                        for(int l=0;l<h;l++)
                            x[l]=tmpg[l][j];
                        break;
                    }
                }
            }
        }
        //cout<<tmp<<endl;
        //cout<<"\n----------------------\n";
        cnt=min(tmp,cnt);
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll H,W;
    cin>>H>>W;
    
    ll ans=1e12;
    
    for(int k=0;k<2;k++){
        if(k)swap(H,W);
        for(int i=1;i<H;i++){
            ll h=H-i;
            ll Sa=i*W,Sb,Sc;
            
            
            if(h>=2){
                Sb=(h/2)*W;
                Sc=(h-h/2)*W;
                ll case1=max({abs(Sa-Sb),abs(Sc-Sb),abs(Sc-Sa)});
                ans=min(ans,case1);
            }

            if(W>=2){
                Sb=h*(W/2);
                Sc=h*(W-W/2);
                ll case2=max({abs(Sa-Sb),abs(Sc-Sb),abs(Sc-Sa)});
                ans=min(ans,case2);
            }
            
        }
    }
    
    cout<<ans<<endl;
}


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

a_list = list( map( int, input().split() ) )

ans = True
for a in a_list:
  if a % 2 == 0:
    if not ( ( a % 3 == 0 ) or ( a % 5 == 0 )):
      ans = False
      break
if ans:
  print( "APPROVED" )
else:
  print( "DENIED" )

Measured memory_bytes: 3060
import java.util.*;

class Main{
    public static void main(String[] arg){
      Scanner sc = new Scanner(System.in);
      String S = sc.nextLine();
      int i = 0;
      while(i < 10){
          S = S.replace("0B","");
          S = S.replace("1B","");
          i++;
      }
      System.out.println(S.replace("B",""));
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    vector <ll> w(n);
    for (ll i =0; i < n; i++){
        cin>>w[i];
    }
    ll ans = 1e9;
    for (ll i = 1; i < n; i++){
        ll L = 0,R = 0;
        for (ll j = 0; j < i; j++)L+=w[j];
            for(ll j = i; j < n; j++)R += w[j];
        ans =  min(ans, abs(L-R));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#coding:UTF-8
nTri=0  #入力された三角形
rTri=0  #正三角形
sTri=0  #鋭角三角形
oTri=0  #鈍角三角形
while True:
    lst=map(int,raw_input().split())
    A = max(lst)
    lst.remove(A)
    C = min(lst)
    lst.remove(C)
    B = lst[0]
    if not ((A-B) < C) or not (C < (A+B)):
        break
    nTri += 1
    A2=A**2
    B2=B**2
    C2=C**2
    if A2 == (B2+C2):
        rTri += 1
    elif A2 < (B2+C2):
        sTri += 1
    else:
        oTri += 1
print str(nTri)+' '+str(rTri)+' '+str(sTri)+' '+str(oTri)

Measured memory_bytes: 4252
//Chain Disappearance Puzzle
#include<bits/stdc++.h>
using namespace std;

int n;
int b[10][5];

void print(){
  for(int i=0; i<n; i++){
    for(int j=0; j<5; j++)
      cout<<b[i][j]<<' ';
    cout<<endl;
  }
  cout<<endl;
}

int solve(){
  int ret=0;
  //print();
  for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
      int p=1;
      while(j+p<5 && b[i][j]!=0 && b[i][j]==b[i][j+p])p++;
      if(p>=3){
        ret+=b[i][j]*p;
        while(p--)b[i][j+p]=0;
      }
    }
  }

  for(int i=n-1; i>=0; i--){
    for(int j=0; j<5; j++){
      if(b[i][j]!=0){
        int p=1;
        while(i+p<n && b[i+p][j]==0){
          swap(b[i+p-1][j], b[i+p][j]);
          p++;
        }
      }
    }
  }

  if(ret==0)return ret;
  else return ret+solve();
}

int main(){
  while(true){
    cin>>n;
    if(n==0)break;
    memset(b, 0, sizeof(b));
    for(int i=0; i<n; i++)
      for(int j=0; j<5; j++)
        cin>>b[i][j];
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();


    void Solve()
    {
        int N = cin.Nextint;
        var A = cin.Scanint;
        int p = 0;
        int q = 0;
        int r = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] == -2)
            {
                p++;
            }
            if (A[i] == -1)
            {
                q++;
            }
            if (A[i] == 2)
            {
                r++;
            }
        }
        if (p % 2 == 1)
        {
            if (q > 0) q = 1;
            else p--;
        }
        else
        {
            q = 0;
        }

        Console.WriteLine(p + q + r);

        //long x = 1;
        for (int i = 0; i < N; i++)
        {
            if (A[i] == 2)
            {
                r--;
                Console.WriteLine(i + 1);
            }
            else if (A[i] == -2 && p > 0)
            {
                p--;
                //x *= -2;
                Console.WriteLine(i + 1);
            }
            else if (A[i] == -1 && q > 0)
            {
                q--;
                Console.WriteLine(i + 1);
            }
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}


Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		char [] s = sc.next().toCharArray();
		int count = 0;
		
		for(int i = 0; i < s.length; i++){
		if(s[i] != 'B'){ count = 0; }
		if(s[i] == 'B' && 0 <= i - (1 + count * 2))
		{ s[i - (1 + count * 2)] = 'N'; count += 1; }}
		
		for(int i = 0; i < s.length; i++){
		if(s[i] != 'B' && s[i] != 'N'){ System.out.print(s[i]); }}
		
	}}

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

///--->>> CONTAINERS <<<---///
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using vpi = vector<pair<ll,ll> >;
using pi = pair<ll,ll>;
using st = set<ll>;
using stk = stack<ll>;
using kiwi = queue<ll>;
using pkiwi = priority_queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;

///--->>> MACROS<<<---///
const ll mx = 1e5+123;
#define MOD 1000000007
#define REP(i,n) for (ll i=1;i<=n;++i)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

///--->>>OPTIMIZE<<<---///
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

///--->>> DEBUGGER<<<---///
#define dbg(args...) do {cerr<<#args<<" : "; diraf(args); } while(0)
void diraf ()  {        cerr << endl;}
template < typename T, typename ... hello>void diraf( T arg, const hello &... rest) {cerr<<arg<< ' ';diraf(rest...);}

int main(){
    fastio;
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    ll n, ans=0; cin>>n;
    vi V(n);
    for(ll i=0;i<n;++i){
        cin>>V[i];
    }
    for(ll i=1;i<n;++i){
        if(V[i]<V[i-1]) ans+=(abs(V[i]-V[i-1])), V[i]+=abs(V[i]-V[i-1]);;
    }
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;


signed main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    # inputs
    x = int(input().strip())

    # a,b > 0
    for a in range(0,200):
        for b in range(0,a+1):
            if a**5 - b**5 ==x:
                print(a,b)
                return

    # a >0 and b < 0
    for a in range(0,100):
        for b in range(-100,1):
            if a**5 - b**5 == x:
                print(a,b)
                return


if __name__ == '__main__':
    main()

Measured memory_bytes: 78316
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int a, b, c, N, Ans;
	int A[100];

	cin >> a;
	
	if (a < 1200) {
		cout << "ABC";
	}
	else if (a < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int a, b;

  while(scanf("%d %d", &a, &b ) != EOF){
    int c = a + b;
    int n = 1;
    while(1){ 
      c /= 10;   
      if(c  == 0) break;
      n++;
    }
    cout << n << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		String aux1 = Integer.toString(a);
		String aux2 = Integer.toString(b);
		String aux = aux1 + aux2;
		int res = Integer.parseInt(aux);
		int sqrt = (int)Math.sqrt(res);
		if(sqrt*sqrt == res)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
bool solve(){
  int inum;
  vector<int> idata;
  cin >> inum;
  if(!inum)return false;
  for(int i=0;i<inum;i++){
    int buf;
    cin >> buf;
    idata.push_back(buf);
  }
  idata.erase( max_element(idata.begin(), idata.end()));
  idata.erase( min_element(idata.begin(), idata.end()));
  int sum = accumulate( idata.begin(), idata.end(), 0 ) / idata.size();
  cout << sum << endl;
  return true;
}

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

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

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int a[N], sum[N];
int fac[N], inv[N];

void init() {
  fac[0] = fac[1] = inv[0] = inv[1] = 1;
  for (int i = 2; i < N; ++i) {
    fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[i] = 1ll * (MOD - MOD/i) * inv[MOD%i] % MOD;
  }
  for (int i = 2; i < N; ++i) inv[i] = 1ll * inv[i] * inv[i - 1] % MOD;
}

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

void solve() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  if (k == 1) {
    puts("0"); return;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = (a[i] + MOD) % MOD;
    sum[i] = (sum[i - 1] + a[i]) % MOD;
  }
  int ans = 0;
  for (int i = k; i <= n; ++i) {
    int x = sum[n] - sum[i - 1] - sum[n - i + 1];
    x = (x % MOD + MOD) % MOD;
    x = 1ll * x * C(i - 2, k - 2) % MOD;
    ans = (ans + x) % MOD;
  }
  printf("%d\n", ans);
}

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


Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    auto xor_val = [](long long n) -> long long {
        switch (n % 4) {
        case 0:
            return n;
        case 1:
            return 1;
        case 2:
            return n + 1;
        case 3:
            return 0;
        }
    };

    long long a, b;
    std::cin >> a >> b;

    std::cout << (xor_val(std::max(0LL, a - 1)) ^ xor_val(b)) << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];
	int q;
	cin >> q;
	vector<int> b(q),c(q);
	for(int i=0;i<q;i++)
		cin >> b[i] >> c[i];
	long long s=0;
	vector<int> cnt(100005,0);
	for(int i=0;i<n;i++)
	{
		s+=a[i];
		cnt[a[i]]++;
	}

	for(int i=0;i<q;i++)
	{
		s-=b[i]*cnt[b[i]];
		s+=c[i]*cnt[b[i]];
		cnt[c[i]]+=cnt[b[i]];
		cnt[b[i]]=0;
		cout << s << endl;
	}




}

Measured memory_bytes: 4464
#include<bits/stdc++.h>
inline int read(){
	int k=0,j=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') j=-1;ch=getchar();
	}
	while(ch<='9'&&ch>='0'){
		k=(k<<1)+(k<<3)+ch-'0';
		ch=getchar();
	}
	return k*j;
}
typedef long long ll;
ll qpow(ll x,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans*=x;
		x*=x;
		n>>=1;
	}
	return ans;
}
bool check(ll a,ll mid,ll k){
	if(a-qpow(mid,5)>=k)return 1;
	else return 0;
}
int main(){
	ll k=(long long)read();
	for(int i=119;i>=-118;i--){
		ll a=qpow(i,5);
		ll low=-100,high=i-1,mid,b=low;
		while(low<=high){
			mid=(low+high)>>1;
			if(check(a,mid,k)){
				low=mid+1;b=mid;
			}else high=mid-1;
		}
		if(a-qpow(b,5)==k){
			printf("%d %d\n",i,b);
			return 0;
		}
	}
}

Measured memory_bytes: 3764
#include <iostream>

#define N_MAX 2001
#define DIVISOR 1000000007

int main(void) {
    int s, S;
    int A[N_MAX];
    
    std::cin >> S;
    
    A[1] = 0;
    A[2] = 0;
    A[3] = 1;
    
    if (S != 1 && S != 2 && S != 3) {
        for(s = 4; s <= S; s++) {
            A[s] = (A[s-1] + A[s-3]) % DIVISOR;
        }
    }
    
    std::cout << A[S] << std::endl;
    
    return 0;
}

Measured memory_bytes: 3540
n = int(input())
h = list(map(int, input().split()))

count = 0
count_max = 0
tmp = 0
for x in h:
	if x <= tmp:
		count += 1
	else:
		count = 0
	if count > count_max:
		count_max = count
	tmp = x
print(count_max)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main () {
  int a;
  cin >> a;

  string s;
  cin >> s;
  
  if ( a >= 3200) {
    cout << s << endl;
  }else if( a < 3200 ) {
    cout << "red" << endl;
  }
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define mper make_pair
#define PI 3.14159
#define F first
#define S second
#define ll int
//#define forik(i, a, b) for(ll i = a; i <= b; ++i)
#define vl vector<ll>
#define pll pair<ll, ll>
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;

const ll MAXN = 1e5 + 100;
ll n, Q, ans = 1, col[MAXN];
bool used[MAXN];

int main() {

mal

cin >> n >> Q;

used[1] = 1;

for(int i = 1; i <= n; ++i)
    col[i] = 1;

for(int i = 1; i <= Q; ++i) {

    ll l, r;
    cin >> l >> r;

    if(col[l]) {

        col[l]--;

        col[r]++;
        if(used[l]) {

            if(!used[r]) {ans++; used[r] = 1;}

        }

        if(!col[l] && used[l]) {ans--; used[l] = 0;}


    }

}


cout << ans;



return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,W,H,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  DV(G,lli,N,N,-1);
  rep(i,0,N){
    cin >> K;
    rep(j,0,K){
      cin >> A >> B;
      G[i][A-1]=B;
    }
  }
  for(int bit=0;bit < (1<<N); bit++){
    Vec(P,bool,N,0);
    flag=0;
    num=0;
    rep(i,0,N)if(bit&(1<<i))P[i]=1;
    rep(i,0,N){
      if(!P[i])continue;
      rep(j,0,N)if((G[i][j]==1&&P[j]==0)||(G[i][j]==0&&P[j]==1))flag=1;
    }
    rep(i,0,N)if(P[i])num++;
    if(!flag)chmax(sum,num);
  }
  Out(sum);
}

Measured memory_bytes: 256
A, B = map(int, input().strip().split(' '))

result = 0
for i in range(A, B + 1):
  s = i % 10
  t = i // 10000 % 10
  u = i // 10 % 10
  v = i // 1000 % 10
  if s == t and u == v:
    result += 1
print(result)

Measured memory_bytes: 39280
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());降順ソート
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {
	string str[3];
	for (int i = 0; i < 3; i++) {
		cin >> str[i];
		str[i][0] = 'A' + (str[i][0] - 'a');
	}
	for (int i = 0; i < 3; ++i) {
		cout << str[i][0];
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

ll manhattan(ll x1, ll y1, ll x2, ll y2){
	return ((ll)(abs(x1-x2)+abs(y1-y2)));
}

ll digit(ll x){
	ll ans = 0ll;
	if(!x){
		return 0ll;
	}
	while(x>0){
		ans++;
		x /= 10;
	}
	return ans;
}

ll f(ll a, ll b){
	return max(digit(a),digit(b));
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << (((b-a)==(c-b))?"YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	
	while (H != 0 && W != 0) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
					cout << "#";
				}
				else cout << ".";
			}
			cout << endl;
		}
		
		cout << endl;
		cin >> H >> W;
	}

	return 0;
}


Measured memory_bytes: 3064
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs; 
} 
  
/* Driver program to test above function */
int main() 
{ string s1,s2; 
  cin>>s1>>s2; 
  int m = s1.length(); 
  int n = s2.length(); 
  char X[m],Y[n];
  for(int i=0;i<m;i++){
    X[i]=s1[i];
  } 
  for(int i=0;i<n;i++){
    Y[i]=s2[i];
  } 
  lcs(X, Y, m, n); 
  return 0; 
}

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

int main() {
    ll N , K, S; cin >> N >> K >> S;
    if (S < 1000000000){
        for (ll i = 0; i < K; i++) {
            if (i) cout << " ";
            cout << S;
        }
        for (ll i = K; i < N; i++){
            cout << " " << S + 1;
        }
        cout << endl;
    }
    else {
        for (ll i = 0; i < K; i++) {
            if (i) cout << " ";
            cout << S;
        }
        for (ll i = K; i < N; i++){
            cout << " " << 1;
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
#define ten5 100000
using namespace std;



int main()
{
    //int m,n,o=0,i,j,k;
    int sum=0,range=0;
    long long int small;
    long long int m,n,o,i,j,k=0;
    //vector <int> v;
    //float f,g,h;
    char c,d;
    //string a;
    cin>>m;
    small=m-1;
    for(i=2;i*i<=m;i++)
    {
        if(m%i==0)
        {
            small=min(small,(i-1+m/i-1));
        }
    }
    cout<<small;
    return 0;
}





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

using namespace std;
typedef long long ll;

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

int main(){
  	long long A,B;
  	long long C,D;
	cin >> A >> B >> C >> D;
  	long long ans = B-A+1 - (B/C - (A-1)/C) - (B/D - (A-1)/D);
  	cerr << ans << endl;
  	long long CD = C*D/gcd(D, C);
  	cerr << CD << endl;
  	ans += (B/CD - (A-1)/CD);
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
    int k,n;
    cin>>n>>k;
    vector<long> h(n,0);
    for(int i=0;i<n;++i)cin>>h[i];
    sort(h.begin(),h.end());
    long ret_min=1000000000;
    for(int i=0;i<n-k+1;++i){
        long temp;
        temp = h[i+k-1]-h[i];
        if(temp<ret_min)ret_min=temp;
    }
    cout << ret_min << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,k,i,j,a[105];
  const int mod=1e9+7;
  ll dp[105][100005]={};
  
  cin >> n >> k;
  for (i=1;i<=n;i++) cin >> a[i];
  
  for (j=0;j<=k;j++) dp[0][j]=1;
  
  for (i=1;i<=n;i++){
    for (j=0;j<=k;j++){
      if (j>a[i]) dp[i][j]=(mod+dp[i-1][j]-dp[i-1][j-a[i]-1])%mod;
      else dp[i][j]=dp[i-1][j];
    }
    if (i<n){
      for (j=1;j<=k;j++) dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
    }
  }
  
  cout << dp[n][k] << endl;
  
  return 0;
}

Measured memory_bytes: 82304
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e9;
int main() {
	int n, m;
	ll k;
	int ans = 0;
	cin >> n >> m >> k;
	vector<ll> a(n);
	vector<ll> b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	ll sum = 0;
	int cnt = 0;
	while (cnt<m and sum + b[cnt] <= k) {
		sum += b[cnt];
		cnt++;
	}
	int i = 0;

	for (int h = cnt;h >= 0;h--) {
		while ( i<n and sum + a[i] <= k){
				sum += a[i];
				i++;
			}ans = max(ans, i+h);
			if (h > 0) sum -= b[h - 1];
}

	cout << ans;
}



Measured memory_bytes: 6392