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

#define inf 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

template< typename T >
struct FordFulkerson {

	struct FlowEdge {
		int to;
		T cap,rev;
		FlowEdge() {}
		FlowEdge(int to,T cap,T rev):to(to),cap(cap),rev(rev) {}
	};

	vector< vector<FlowEdge> > G;
	vector<int> used;

	FordFulkerson() {}
	FordFulkerson(int n) {
		G.resize(n);
		used.resize(n);
	}

	void add_edge(int from,int to,T cap) {
		G[from].emplace_back(to,cap,(int)G[to].size());
		G[to].emplace_back(from,0,(int)G[from].size()-1);
	}

	T dfs(int v,const int t,T flow) {
		if(v==t) return flow;
		used[v]=1;
		for(auto &e:G[v]) {
				if(!used[e.to]&&e.cap>0) {
				T d=dfs(e.to,t,min(flow,e.cap));
				if(d>0) {
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}

	T max_flow(int s,int t,T lim) {
		T flow=0;
		while(true) {
			fill(ALL(used),false);
			T d=dfs(s,t,inf);
			if(d==0) return flow;
			flow+=d;
		}
		return flow;
	}

	T max_flow(int s,int t) {
		return max_flow(s,t,inf);
	}
};

int h,w;
string fld;
bool E[100][100];
P S,T;

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

	cin>>h>>w;
	FordFulkerson<ll> F(h+w+2);
	REP(i,h) {
		cin>>fld;
		REP(j,w) {
			if(fld[j]=='S') {
				F.add_edge(h+w,i+w,inf);
				F.add_edge(h+w,j,inf);
				S=P(i,j);
			}
			else if(fld[j]=='T') {
				F.add_edge(i+w,h+w+1,inf);
				F.add_edge(j,h+w+1,inf);
				T=P(i,j);
			}
			else if(fld[j]=='o') {
				E[i][j]=true;
			}
		}
	}
	REP(i,h) {
		REP(j,w) {
			if(E[i][j]) {
				F.add_edge(i+w,j,1);
				F.add_edge(j,i+w,1);
			}
		}
	}
	if(S.fi==T.fi||S.se==T.se) {
		cout<<-1<<endl;
		return 0;
	}
	cout<<F.max_flow(h+w,h+w+1)<<endl;

	return 0;
}


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

class Program
{

    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int a = int.Parse(input[1]);
        int b = int.Parse(input[2]);

        int total = 0;
        for (int i = 1; i <= n; i++)
        {
            int sum = findSumOfDigits(i);
            if (sum >= a && sum <= b)
            {
                total += i;
            }
        }

        Console.WriteLine(total);
    }

    static int findSumOfDigits(int n)
    {
        int sum = 0;
        while (n > 0)
        {
            sum += n % 10;
            n /= 10;
        }

        return sum;
    }

}

Measured memory_bytes: 11092
#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()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int solve(int A, int B, int C) {
  if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1) return 0;
  if(A == B && B == C) return -1;
  return 1 + solve((B + C) / 2, (C + A) / 2, (A + B) / 2);
}

int main(){
  int A, B, C;
  cin >> A >> B >> C;

  cout << solve(A, B, C) << endl;
  return 0;
}



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

int a, b;
constexpr int C = ~(1 << 31);
constexpr int M = (1 << 16) - 1;

int r() {
    a = 36969 * (a & M) + (a >> 16);
    b = 18000 * (b & M) + (b >> 16);
    return (C & ((a << 16) + b)) % 1000000;
}

struct point {
    int y, z;

    point(int y_, int z_) : y(y_), z(z_) {}
    bool operator<(point const& p) const {
        return y < p.y;
    }
};

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

    int m, n;
    while(cin >> m >> n >> a >> b, n + m) {
        vector<tuple<int, int, int>> ps(n + m);
        for(int i = 0; i < m; ++i) {
            int x, y, z; cin >> x >> y >> z;
            ps[i] = make_tuple(x, -y, -z);
        }
        for(int i = m; i < n + m; ++i) {
            const int x = r(), y = r(), z = r();
            ps[i] = make_tuple(x, -y, -z);
        }
        sort(begin(ps), end(ps));
        vector<point> ps2;
        for(int i = 0; i < n + m; ++i) {
            ps2.emplace_back(-get<1>(ps[i]), -get<2>(ps[i]));
        }

        int ans = 0;
        vector<set<point>> dp(n + m + 1);
        dp[0].emplace(0, 0);
        for(auto const& p : ps2) {
            auto check = [&] (int i) {
                auto it = dp[i].lower_bound(p);
                if(it == dp[i].begin()) return false;
                it = prev(it);
                return p.y > it->y && p.z > it->z;
            };
            int lb = 0, ub = n + m;
            while(ub - lb > 1) {
                const int mid = (ub + lb) >> 1;
                (check(mid) ? lb : ub) = mid;
            }
            auto it = dp[ub].lower_bound(p);
            while(it != dp[ub].end() && it->z >= p.z) {
                it = dp[ub].erase(it);
            }
            if(it == dp[ub].begin() || prev(it)->z > p.z) {
                dp[ub].insert(p);
            }
            ans = max(ans, ub);
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 27212
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N;
    cin >> N;

    map<int, int> M;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        M[a]++;
    }

    int ans = 0;
    for (auto x : M) ans += x.second % 2;

    cout << ans << endl;

}


























































Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
const int N = 200010, INF = 0x3f3f3f3f;
struct edge {
  int la,b;
} con[N << 1];
int tot,fir[N];
void add(int from,int to) {
  con[++tot] = (edge) {fir[from],to};
  fir[from] = tot;
}
int n,mxdep[N][2],hson[N],sz[N],low[N];
char s[N];
long long ans;
void dfs(int pos,int fa) {
  sz[pos] = s[pos] - '0';
  mxdep[pos][0] = 0;
  mxdep[pos][1] = - INF;
  hson[pos] = 0;
  for (int i = fir[pos] ; i ; i = con[i].la) {
    if (con[i].b == fa) continue;
    dfs(con[i].b,pos);
    sz[pos] += sz[con[i].b];
    if (mxdep[con[i].b][0] > mxdep[hson[pos]][0] || (!hson[pos]))
      hson[pos] = con[i].b;
    if (mxdep[con[i].b][0]+1 > mxdep[pos][0]) {
      mxdep[pos][1] = mxdep[pos][0];
      mxdep[pos][0] = mxdep[con[i].b][0] + 1;
    } else mxdep[pos][1] = max(mxdep[pos][1],mxdep[con[i].b][0] + 1);
    if (sz[con[i].b]) low[pos] = min(low[pos],mxdep[con[i].b][0] + 1);
  }
}
void fsd(int pos,int fa) {
  for (int i = fir[pos] ; i ; i = con[i].la) {
    if (con[i].b == fa) continue;
    int val = (con[i].b == hson[pos] ? mxdep[pos][1] : mxdep[pos][0]) + 1;
    if (val > mxdep[con[i].b][0]) {
      mxdep[con[i].b][1] = mxdep[con[i].b][0];
      mxdep[con[i].b][0] = val;
      hson[con[i].b] = pos;
    } else mxdep[con[i].b][1] = max(mxdep[con[i].b][1],val);
    if (sz[1] - sz[con[i].b] > 0)
      low[con[i].b] = min(low[con[i].b],val);
    fsd(con[i].b,pos);
  }
}
int main() {
  int x,y;
  scanf("%d",&n);
  for (int i = 1 ; i < n ; ++ i) {
    scanf("%d%d",&x,&y);
    add(x,y);
    add(y,x);
  }
  scanf("%s",s+1);
  memset(low,0x3f,sizeof low);
  dfs(1,0);
  fsd(1,0);
  for (int i = 1 ; i <= n ; ++ i) {
    int tmp = mxdep[i][1] + 1;
    if (mxdep[i][0] > mxdep[i][1] + 1)
      ++ tmp;
    if (mxdep[i][0] == mxdep[i][1]) -- tmp;
    if (s[i] - '0' == 0) tmp -= low[i];
    ans += max(tmp,0);
  }
  printf("%lld\n",ans+1);
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    vector<vector<char>> c(3, vector<char>(3));
    rep(i,3) rep(j,3) cin >> c[i][j];

    rep(i,3) cout << c[i][i];
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int S, N, A[100];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A + N);
	for(int i = 1; i < N; i++) S += A[i] - A[i - 1];
	printf("%d\n", S);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    map<char, int> win;
    win['r'] = p;
    win['s'] = r;
    win['p'] = s;
    vector<bool> ch(n, false);
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if(i - k < 0) {
            ch[i] = true;
            ans += win[t[i]];
        } else {
            if(t[i - k] == t[i]) {
                if(!ch[i - k]) {
                    ans += win[t[i]];
                    ch[i] = true;
                }
            } else {
                ans += win[t[i]];
                ch[i] = true;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
N = input()
C = [0]*(N-1)
S = [0]*(N-1)
F = [0]*(N-1)
for i in range(N-1):
  C[i], S[i], F[i] = map(int, raw_input().split())

for i in range(N):
  t = 0
  for j in range(i, N-1):
    t = max(t, S[j])
    t = (t+F[j]-1)/F[j]*F[j]+C[j]
  print t


Measured memory_bytes: 2692
#include<stdio.h>
#define MAX 100
#define INFTY 1<<21
#define WHITE 0
#define GRAY  1
#define BLACK 2

int n,M[MAX][MAX];

int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];
  int i;
  int v;
  int sum;
  
  for(i = 0; i < n;i ++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  
  d[0] = 0;

  
  while(1){
    minv = INFTY;
    u = -1;
    
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
 
    if(u == -1) break;
    color[u] = BLACK;
    for( v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0; i < n; i++)
    if(p[i] != -1) sum += M[i][p[i]];

  return sum;
}

int main(){
  int i,j;
  int e;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d",&e);
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }
  printf("%d\n",prim());
  
  return 0;
}




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

namespace atcoder
{
  class Program
  {
    static void Main(string[] args)
    {

      var line = Console.ReadLine().Split();
      var r = int.Parse(line[0]);
      int D = int.Parse(line[1]);
      int x2000 = int.Parse(line[2]);

      int nextX = x2000;
      for (int i = 1; i <= 10; i++)
      {
          nextX = r * nextX - D;
          System.Console.WriteLine(nextX);
      }

    //   Console.ReadLine();
    }
  }
}


Measured memory_bytes: 11092
s = input()
x = int(s[:2])
y = int(s[2:])
if  (x > 12 or x == 0) and (y >= 1 and y <= 12):
    print("YYMM")
elif  (y > 12 or y == 0) and (x >= 1 and x <= 12):
    print("MMYY")
elif (x >= 1 and x <= 12) and (x >= 1 and x <= 12):
    print("AMBIGUOUS")
else:
    print("NA")


Measured memory_bytes: 3060
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int m=s.nextInt();
		int[][]a=new int[m][];
		int[]p=new int[m];
		for(int i=0;i<m;++i) {
			int t=s.nextInt();
			a[i]=new int[t];
			for(int j=0;j<t;++j)
				a[i][j]=s.nextInt()-1;
		}
		Arrays.setAll(p,i->s.nextInt());

		int r=0;
		loop:
		for(int f=0;f<(1<<n);++f) {
			for(int i=0;i<m;++i) {
				int c=0;
				for(int j=0;j<a[i].length;++j) {
					if((f&(1<<a[i][j]))>0)
						++c;
				}
				if(c%2!=p[i])
					continue loop;
			}
			++r;
		}
		System.out.println(r);
	}
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

using pll = pair<ll,ll>;
ll mod = 1000000007;

void reduce(ll &x, ll &y){
    auto g = __gcd(abs(x),abs(y));
    x /= g;
    y /= g;
    if(x < 0 || (x == 0 && y < 0)){
        x *= -1;
        y *= -1;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, nz = 0;
    int i;
    cin >> n;
    vl pot2; ll p2 = 1;
    for(i=0;i<=n;i++){
        pot2.push_back(p2);
        p2 = (p2*2)%mod;
    }

    map<pll, int> cnt;
    ll x, y;
    for(i=0;i<n;i++){
        cin >> x >> y;
        if(x == 0 && y == 0){
            nz++;
            continue;
        }
        reduce(x,y);
        cnt[{x,y}]++;
    }
    ll ans = 1;
    for(auto kv : cnt){
        tie(x,y) = kv.first;
        int n1 = kv.second;
        ll x2 = y;
        ll y2 = -x;
        reduce(x2,y2);
        int n2 = 0;
        if(cnt.count({x2,y2}) != 0)
            n2 += cnt[{x2,y2}];

        ll tmp = pot2[n1];
        if(n2 > 0){
            tmp += pot2[n2] - 1;
            tmp %= mod;
            if(tmp < 0) tmp += mod;
            cnt.erase({x2,y2});
        }
        ans *= tmp;
        ans %= mod;
    }
    ans = (ans + nz - 1)%mod;
    if(ans < 0) ans += mod;
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 17184
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

typedef struct {
    size_t idx;
    char S[11];
    size_t P;
} _info;

static _info info[100];

static int compare_i(const void* a, const void* b) {
    const _info* aP = (_info*)a;
    const _info* bP = (_info*)b;

    const int cmpR = strcmp(aP->S, bP->S);

    if (cmpR < 0) {
        return -1;
    }
    else if (cmpR == 0) {
        if (aP->P > bP->P) {
            return -1;
        }
        else {
            return 1;
        }
    }
    else {
        return 1;
    }
}

int main(void) {
    size_t N;

    scanf("%zu\n", &N);
    for (size_t i = 0; i < N; i++) {
        info[i].idx = i + 1;
        scanf("%s %zu", info[i].S, &(info[i].P));
        if (i < N - 1) {
            scanf("\n");
        }
    }

    qsort(info, N, sizeof(_info), compare_i);

    for (size_t i = 0; i < N; i++) {
        printf("%zu\n", info[i].idx);
    }

    return 0;
}


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

namespace AtCoder.Abc
{
    class QuestionC
    {
        static List<long> primes;

        public static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());

            long result = long.MaxValue;
            for (long i = 1; i <= Math.Sqrt(n); i++)
            {
                if (n % i == 0)
                {
                    var temp = (n / i) + i;
                    if (result > temp)
                    {
                        result = temp;
                    }
                }
            }

            Console.WriteLine(result - 2);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

const char *left(const char *p){
  if(p == NULL) return NULL;
  assert(*p == '(');

  if(*(p+1) == '(') return p+1;
  return NULL;
}

const char *right(const char *p){
  if(p == NULL) return NULL;
  assert(*p == '(');
  int depth = 0;
  p++;

  while(!(depth == 0 && *p == ',')){
    if(*p == '(') depth++;
    if(*p == ')') depth--;
    p++;
  }

  p++;
  if(*p == '(') return p;
  return NULL;
}

void solve(const char *p1, const char *p2, bool inter){
  if(p1 == NULL && p2 == NULL) return;

  const char *l1 = left(p1);
  const char *r1 = right(p1);
  const char *l2 = left(p2);
  const char *r2 = right(p2);

  printf("(");

  if(inter){
    if(l1 == NULL || l2 == NULL){
    }else{
      solve(l1,l2,inter);
    }
  }else{
    if(l1 == NULL && l2 == NULL){
    }else{
      solve(l1,l2,inter);
    }
  }

  printf(",");

  if(inter){
    if(r1 == NULL || r2 == NULL){
    }else{
      solve(r1,r2,inter);
    }
  }else{
    if(r1 == NULL && r2 == NULL){
    }else{
      solve(r1,r2,inter);
    }
  }

  printf(")");
}

int main(){
  string str;
  while(getline(cin, str)){
    stringstream ss(str);
    char w;
    string s1,s2;
    ss >> w >> s1 >> s2;

    solve(s1.c_str(), s2.c_str(), w == 'i');
    puts("");
  }
  return 0;
}

Measured memory_bytes: 0
#define  REP(i, s, e) for (register int i = (s), end_##i = (e); i <= end_##i; i++)
#define DREP(i, s, e) for (register int i = (s), end_##i = (e); i >= end_##i; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) (a < (b) ? a = (b) : a)
#define chkmin(a, b) (a > (b) ? a = (b) : a)

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>

using namespace std;

template <typename T> T read()
{
	T ans(0), flag(1);
	char c(getchar());
	while (!isdigit(c))
	{
		if (c == '-') flag = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * flag;
}

void file(string s)
{
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int m, n, k;

int main()
{
#ifdef CraZYali
	file("A");
#endif
	int a, b;
	cin >> a >> b;
	cout << (a < 10 && b < 10 ? a * b : -1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD (ll)1000000007

int a[200001];

int main(void)
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	ll ans = 0;
	int mx = a[1];

	for (int i = 2; i <= n; i++)
	{
		mx = max(mx, a[i]);
		ans += (ll)max(mx - a[i], 0);
	}

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

Measured memory_bytes: 2508
import java.util.Scanner;

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

		if( Character.isUpperCase( a.charAt( 0 ) ) ) {
		    System.out.println( "A" );
		}
		else {
		    System.out.println( "a" );
		}
	}
}


Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H,W,K;
        H = sc.nextInt();
        W = sc.nextInt();
        K = sc.nextInt();
        char[][]mat = new char[H][W];
        for (int i = 0; i < H; i++) {
            mat[i] = sc.next().toCharArray();
        }
        int row = (int)Math.pow(2,H);
        int col = (int)Math.pow(2,W);
        int ans =0;
        for(int r = 0; r < row;r++){
            for(int c = 0;c < col;c++){
                int count = 0;
                for(int i = 0;i < H;i++){
                    for(int j = 0;j < W;j++){
                        if((r >> i & 1) == 1 && (c >> j & 1) == 1 && mat[i][j]=='#')
                            count++;
                    }
                }
                if(count == K)
                    ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35860
#include<stdio.h>

int selectionSort(int,int *);

int main(){
    int cnt,n;
    scanf("%d",&n);
    int i,h[n];
    for(i=0;i<n;i++)scanf("%d",&h[i]);
    cnt = selectionSort(n,&h[0]);
    for(i=0;i<n;i++){
        if(i!=n-1)printf("%d ",h[i]);
        else printf("%d\n",h[i]);
    }
    printf("%d\n",cnt);
    return 0;
}

int selectionSort(int n,int *A){
    int i,j,cnt=0;
    for(i=0;i<n;i++){
        int minj=i;
        for(j=i;j<n;j++){
            if(A[j]<A[minj]){
                minj=j;
            }
        }
        if(minj!=i){
        int tmp = A[minj];
        A[minj]= A[i];
        A[i]=tmp;
        cnt++;
        }
        }
    return cnt;
}




Measured memory_bytes: 2760
import math
K=int(input())
sum=0
for i in range(1,K+1):
    for j in range(1,K+1):
        if math.gcd(i, j)==1:
            sum+=K
        else:
            g=math.gcd(i, j)
            for k in range(1,K+1):
                sum += math.gcd(g,k)
print(sum)




Measured memory_bytes: 9180
def dist(x,y):
  return abs(x[0]-y[0])+abs(x[1]-y[1])

n,m = map(int,input().split())
s = []
for _ in range(n):
  a,b = map(int,input().split())
  s.append((a,b))
c = []
for _ in range(m):
  c_,d = map(int,input().split())
  c.append((c_,d))
for i in range(n):
  p = s[i]
  md = 10**10
  mi = 0
  for j in range(m):
    ch = c[j]
    d = dist(p,ch)
    if md > d:
      md = d
      mi = j
  print(mi+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
int dp[305][305],cost[305][305];//dp[i][j]:xをi、yをj沈めるのにかかる最小コスト　cost[i][j]:xがi、yがj沈んでる時の摩擦
int H,W,ans;
std::vector<string> s(300);
void init_(){
  for(int i=0;i<305;i++)for(int j=0;j<305;j++)dp[i][j]=LINF;
  dp[0][0]=0;
}
int f(int right){
  int x=right-1,y=right;
  init_();
  for(int i=0;i<H;i++){//cost[0][i]とcost[i][0]を求める
    int res=0,res2=0;
    for(int j=0;j<H-i;j++)res+=(s[H-1-j][x]==s[H-1-j-i][y]);cost[0][i]=res;
    for(int j=0;j<H-i;j++)res2+=(s[H-1-j-i][x]==s[H-1-j][y]);cost[i][0]=res2;
  }
  for(int i=0;i<H;i++){
    for(int k=1;k+i<=H;k++){//cost[k][k+i]とcost[k+i][i]を求める
      cost[k][k+i]=cost[k-1][k+i-1]-(s[H-k][x]==s[H-(k+i)][y]);
      cost[k+i][k]=cost[k+i-1][k-1]-(s[H-(k+i)][x]==s[H-k][y]);
    }
  }
  for(int i=0;i<=H;i++){
    for(int j=0;j<=H;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]+cost[i][j]);
      dp[i][j+1]=min(dp[i][j+1],dp[i][j]+cost[i][j]);
    }
  }
  return dp[H][H];
}
//main
signed main(){
  cin>>H>>W;
  for(int i=0;i<H;i++)cin>>s[i];
  for(int j=1;j<W;j++)ans+=f(j);
  cout<<ans<<endl;
}

/*
解説AC
部分ごとに計算できたらなとぼんやり思ってはいたけど実は完全に二つずつ独立でやっていいというやつ
全部が進める方向は埋める方向だけなことや2つの間の摩擦に他の状態が一切干渉しないことから成り立つ
タネを見てしまえば終わりな問題なので吸収出来るか難しい
*/

Measured memory_bytes: 1920
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

int gcd(int a, int b) {
	int r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r != 0) {
			a = b;
			b = r;
		}
		else {
			return b;
		}
	}
}

int main() {
	int x;
	cin >> x;
	for (int i = x; i > 0; i++) {
		int count = 0;
		for (int j = 1; j <= sqrt(i); j++) {
			if (i % j == 0) {
				count++;
			}
		}
		if (count == 1) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
M=10**9+7;D=[];i=1;r=0;N,K=map(int,raw_input().split())
while i*i<=N:
	if N%i==0:D.append(i);i*i<N and D.append(N/i)
	i+=1
D.sort();N=[]
for i in range(len(D)):
	N.append(pow(K,-~D[i]/2,M))
	for j in range(i):
		if D[i]%D[j]==0:N[i]=(N[i]-N[j])%M
	r=(r+(N[i]*D[i]*pow(2,M-2+D[i]%2,M)))%M
print r

Measured memory_bytes: 16112
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string L;cin >> L;
    LL dp[100010][2] = {0};
    int N = L.size();
    dp[0][0] = 1;

    rep(deg,N) rep(isless,2){
        // a,b = 0,0
        if(L[deg] == '1')dp[deg + 1][1] = (dp[deg+1][1] + dp[deg][isless]) %MOD;
        else dp[deg + 1][isless] += (dp[deg+1][isless] + dp[deg][isless]) %MOD;

        // a,b = 1,0 0,1
        if(L[deg] == '1' || isless)dp[deg + 1][isless] = (dp[deg+1][isless] + (dp[deg][isless]) * 2) %MOD;
    }

    cout << (dp[N][0] + dp[N][1]) %MOD << endl;
}


Measured memory_bytes: 2048
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int N, M;
    cin>>N>>M;
    map<int, int> C;
    long long ans = 0;
    int S = 0;
    for (int i=0; i<N; i++)
    {
        int A;
        cin>>A;
        S = (S+A)%M;
        C[((A-S)%M+M)%M]++;
        ans += C[(M-S)%M];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long N, long long A, long long B){
    cout<<min(N*A,B)<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
}


Measured memory_bytes: 384
#include <stdio.h>

int A[20], n;

int rec(int m, int i){
  int x, y;
  if(m == 0) return 1;
  if(i >= n) return 0;
  x = rec(m, i + 1) || rec(m - A[i], i + 1);
  return x;
}

int main(){
  int i, q, m;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);

  for(i = 0; i < q; i++){
    scanf("%d", &m);
    if(rec(m, 0) == 1) printf("yes\n");
    else if(rec(m, 0) == 0) printf("no\n");
  }

  return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int y = sc.nextInt();
			int m = sc.nextInt();
			int d = sc.nextInt();
			
			int num = y*10000 + m*100 + d;
			if(num<18680908){
				System.out.println("pre-meiji");
			}else if(num>=18680908 && num<19120730){
				System.out.println("meiji " + (y-1867) + " " + m + " " + d);
			}else if(num>=19120730 && num<19261225){
				System.out.println("taisho " + (y-1911) + " " + m + " " + d);
			}else if(num>=19261225 && num<19890108){
				System.out.println("showa " + (y-1925) + " " + m + " " + d);
			}else{
				System.out.println("heisei " + (y-1988) + " " + m + " " + d);
			}
		}
	
	}	
}

Measured memory_bytes: 17200
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

double cos60,sin60;

void init(){
    cos60=cos(M_PI/3);
    sin60=sin(M_PI/3);
}

void koch(double x1,double y1,double x2,double y2,int n){

    double sx=(x1*2+x2)/3,sy=(y1*2+y2)/3,tx=(x1+x2*2)/3,ty=(y1+y2*2)/3;
    double x3=(tx-sx)*cos60-(ty-sy)*sin60+sx,y3=(tx-sx)*sin60+(ty-sy)*cos60+sy;
    if(n>0){
        koch(x1,y1,sx,sy,n-1);
        printf("%.8f %.8f\n",sx,sy);
        //cout<<sx<<" "<<sy<<endl;
        koch(sx,sy,x3,y3,n-1);
        printf("%.8f %.8f\n",x3,y3);
        //cout<<x3<<" "<<y3<<endl;
        koch(x3,y3,tx,ty,n-1);
        printf("%.8f %.8f\n",tx,ty);
        //cout<<tx<<" "<<ty<<endl;
        koch(tx,ty,x2,y2,n-1);
    }
    
}

int main(void){
    int n;
    cin>>n;
    
    init();
    printf("%.8f %.8f\n",0.00000000,0.00000000);
    koch(0.0,0.0,100.0,0.0,n);
    printf("%.8f %.8f\n",100.00000000,0.00000000);
    return 0;
}



Measured memory_bytes: 3192
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        a : u32,
        b : u32,
        c : u32,
        x : u32,
    );
    let mut ans = 0;
    let a: u32 = a;
    let b: u32 = b;
    let c: u32 = c;
    let x: u32 = x;
    for i in 0..a + 1 {
        for j in 0..b+1{
            for k in 0..c+1{
                if i * 500 + j * 100 + k*50 == x{
                    ans += 1
                }
            }
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
X, N = map(int, input().split())
if N == 0:
    P = []
else:
    P = list(map(int, input().split()))

a = X
b = X

while a in P and b in P:
    a -= 1
    b += 1

if a not in P:
    print(a)
else:
    print(b)

Measured memory_bytes: 61892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());

		int sum=0;

		if(n > k) {
			sum = k * x + (n-k) * y;
		}else {
			sum = n * x;
		}


		System.out.println(sum);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0;i < (int)s.size();i++) {
		int x = s[i] - 'A';
		x = (x + n) % 26;
		s[i] = char('A' + x);
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll x;
    cin>>x;
    ll ans = (x/11)*2;
    if(x%11){
        ans++;
        if(x%11>6) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 19541921608536647, base = 61;
    unsigned long N;
    cin >> N;
    vector<unsigned long> s(N);
    {
        string S;
        cin >> S;
        transform(S.begin(), S.end(), s.begin(), [](auto i){return i - 97;});
    }
    const auto f = [&MOD, &base, &N, &s](unsigned long x) -> bool{
        unsigned long h{0}, c{MOD - 1};
        for(unsigned long i = 0; i < x; ++i){
            ((h *= base) += s[i]) %= MOD;
            (c *= base) %= MOD;
        }
        unordered_set<unsigned long> st;
        deque<unsigned long> dq{h};
        for(unsigned long i = 0; i + x < N; ++i){
            ((h *= base) += c * s[i] + s[i + x]) %= MOD;
            dq.push_back(h);
            if(dq.size() > x){
                st.insert(dq.front());
                dq.pop_front();
            }
            if(st.count(h))return true;
        }
        return false;
    };
    unsigned long L = 0, R = N / 2 + 1;
    while(L + 1 < R){
        auto M = (L + R) / 2;
        (f(M) ? L : R) = M;
    }
    cout << L << endl;
    return 0;
}

Measured memory_bytes: 608
#include<iostream>
using namespace std;
int main(){
    int x;
    int y;
    cin >>x >>y;
    while (1) {
        if (x>y){
            cout << y << " "<<  x <<endl;
            
        }else{
            cout << x << " " <<  y <<endl;
        }
        cin >>x >>y;
        if (x==0 && y==0) break;
    } 
    return 0;
}


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

const int N = 300000;
int p[N];

int main(){
  for(int i=2;i<=N;i++)p[i] = 1;
  for(int i=2;i<=N;i++){
    if(p[i]){
      for(int j=2*i;j<=N;j+=i)p[j] = 0;
    }
    p[i] += p[i-1];
  }

  int n;
  while(cin >> n,n)cout << p[2*n] - p[n] << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	vector<int> c(n);
	for (int i = 0; i < n; i++) cin >> c[i];
	
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] >= 0) {
			res += v[i] - c[i];
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    vector<int>data(n);
    for(int i=0;i<n;i++)cin >>data[i];
    long long sum=0;
    sort(data.begin(),data.end());
    for(int i=0;i<n;i++) sum += data[i];
    cout<< data[0] << " "<< data[n-1] <<" "<< sum <<endl;
}


Measured memory_bytes: 3164
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val seq1 = for(i<-1 to 9) yield List(i,i,i)
  val seq2 = for(i<-1 to 7) yield List(i,i+1,i+2)

  def check(m:List[Int], count:Int,u:Int,v:Int):Boolean =
    if(m.length != count) false
    else if(count==2) {
      val List(x,y) = m
      if(x==y) true else false
    } else
      (u to 8).exists( i=> check(m diff seq1(i),count-3,i+1,v)) || (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i))

  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toList
    val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14,0,0) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

Measured memory_bytes: 66468
#%%
import numpy as np

n, m, Q = map(int ,input().split())
l, r, p, q = [0] * m, [0] * m, [0] * Q, [0] * Q
count = [[0] * n for _ in range(n)]
for i in range(m):
    l[i], r[i] = map(lambda x: int(x) - 1, input().split())
    count[l[i]][r[i]] += 1
for i in range(Q):
    p[i], q[i] = map(lambda x: int(x) - 1, input().split())

#print(np.array(count))

for i in range(0, n):
    for j in range(1, n):
        count[i][j] += count[i][j-1]
    for j in range(0, n):
        if i != 0:
            count[i][j] += count[i-1][j]

#print(np.array(count))

for i in range(Q):
    if 0 <= p[i]-1:
        tmp = count[n-1][q[i]] - count[p[i]-1][q[i]]
    else:
        tmp = count[n-1][q[i]]
    print(tmp)

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

int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<vector<int> > graph(n, vector<int>(0));

	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		a = a - 1;
		b = b - 1;
		graph.at(a).push_back(b);
		graph.at(b).push_back(a);
	}

	int last[n];
	for (int i = 0; i < n; i++) last[i] = -1;
	last[0] = 0;

	queue<int> q;
	q.push(0);


	while (!q.empty() && last[n-1] == -1) {
		int cur = q.front();
		q.pop();
		for (auto &i : graph.at(cur)) {
			if (last[i] == -1) {
				last[i] = cur;
				q.push(i);

			}
		}
	}





	int dist = 1;
	int cur = n-1;
	while (cur != 0) {
		cur = last[cur];
		dist++;
	}


	dist = dist / 2;
	int breakpoint = n-1;
	for (int i = 1; i < dist; i++) {
		breakpoint = last[breakpoint];
	}

	int start = last[breakpoint];

	queue<int> qu;
	qu.push(start);
	int found[n];
	for (int i = 0; i < n; i++) {
		found[i] = 0;
	}
	found[start] = 1;



	while (!qu.empty()) {
		int curr = qu.front();
		qu.pop();
		for (auto &i : graph.at(curr)) {
			if (found[i] == 0 && i != breakpoint) {
				found[i] = 1;
				qu.push(i);
			}
		}

	}

	int count = 0;
	for (int i = 0; i < n; i++) if (found[i] == 1) count++;

	if (count > n / 2) {
		cout << "Fennec" << endl;
	} else {
		cout << "Snuke" << endl;
	}



	return 0;

}


Measured memory_bytes: 6656
#include<stdio.h>
int main(void){
    int H,W,i=1,j=1;
    while(1){
        scanf("%d%d",&H,&W);
        if(H==0&&W==0)break;
        while(H>=i){
            while(W>=j){
                if((i+j)%2==0)printf("#");
                else{
                    printf(".");
                }
                j++;
            }
            printf("\n");
            j=1;
            i++;
        }
        i=1;
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

int main() {

  ll x;
  cin >> x;
  ll n = 100;
  ll cnt = 0;

  while(true) {
    if(n>=x) {
      break;
    }

    n *= 1.01;
    ++cnt;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvi g;
vi d;

int main(){
	cin>>n>>m;
	g=vvi(n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	d=vi(n,inf);
	d[0]=0;
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int v=q.front();
		q.pop();
		for(auto u:g[v]) if(d[u]==inf){
			d[u]=d[v]+1;
			q.push(u);
		}
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<n;i++) for(auto v:g[i]) if(d[i]==d[v]+1){
		cout<<v+1<<endl;
		break;
	}
}

Measured memory_bytes: 10240
#include <stdio.h>
int t[100],k[100],s[100];
void Answer(int j);
int main(void){
	int a,b,c,i,j;
	char str[100];

	for(j=0; ;j++){
		fgets(str,sizeof(str),stdin);
		sscanf(str,"%d %d %d",&a,&b,&c);
		if(a==-1 && b ==-1) break;
		t[j]=a; k[j]=b; s[j]=c;
	}
	Answer(j);
	return 0;
}

void Answer(int j){
	int i;
	for(i=0;i<j;i++){
		if((t[i]==-1) || (k[i]==-1))
			printf("F\n");
		else if(t[i]+k[i]<30)
			printf("F\n");
		else if((30<=t[i]+k[i] && t[i]+k[i]<50) && s[i]<50)
			printf("D\n");
		else if((30<=t[i]+k[i] && t[i]+k[i]<50) && s[i]>=50)
			printf("C\n");
		else if((50<=t[i]+k[i] && t[i]+k[i]<65))
			printf("C\n");
		else if((65<=t[i]+k[i]) && (t[i]+k[i]<80))
			printf("B\n");
		else if(80<=t[i]+k[i])
			printf("A\n");
	}
}

Measured memory_bytes: 596
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n,hi=-1,lo=1001;
    cin >>n;
    for(int i=0;i<n;i++){
        ll tmp;
        cin >>tmp;
        hi=max(hi,tmp);
        lo=min(lo,tmp);
    }
    ans=abs(hi-lo);

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define MP make_pair
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

// H を i
// W を j
// H * i + W * j - i*j = N

int main()
{
  int H, W, N; 
  cin >> H >> W >> N;

  int ans = INF;
  for (int i = 0; i <= H; i++) {
    for (int j = 0; j <= W; j++) {
      int num = H*i + W*j - i*j;
      if (num >= N) ans = min(ans, i + j);
    }
  }
  cout << ans << endl;

  return 0;
}


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


int32_t main()
{
    int h,n;
    cin>>h>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
    int dp[h+1];
    memset(dp,INF,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<h+1;i++)
    {
     for(int j=0;j<n;j++)
     {int y=max(0LL,(i-a[j]));
      dp[i]=min(dp[y]+b[j],dp[i]);
     }
    }
    cout<<dp[h];
    
    

    return 0;
}

Measured memory_bytes: 384
n = int(input())
tasks = []
task = []
for i in range(n):
  task = list(map(int,input().split()))
  tasks.append(task)

tasks = sorted(tasks,key=lambda x: x[1])
total = 0
#print(tasks)
for i in tasks:
  total += i[0]
#  print(total,i[0],i[1])
  if total <= i[1]:
    continue
  else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 55252