akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        var scanner = new Scanner(System.in);
        int n, k;
        n = scanner.nextInt();
        k = scanner.nextInt();
        var flag = new boolean[100];

        for (int i = 0; i < k; ++i) {
            int d = scanner.nextInt();
            for (int j = 0; j < d; ++j) {
                int a = scanner.nextInt();
                flag[a - 1] = true;
            }
        }

        var count = 0;
        for (int i = 0; i < n; ++i) {
            if (!flag[i]) {
                ++count;
            }
        }

        System.out.println(count);
    }
}


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

class Point{
	int x, y;
	public Point(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Point) {
			Point key = (Point)obj;
			return this.x == key.x && this.y == key.y;
		}else {
			return false;
		}
	}
	@Override
	public int hashCode() {
		return Objects.hash(x,y);
	}
}

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int h = fs.nextInt(), w = fs.nextInt(), n = fs.nextInt();
		Map<Point, Integer> map = new HashMap<>();
		for(int i=0;i<n;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1;
			for(int j=-1;j<=1;j++) {
				for(int k=-1;k<=1;k++) {
					if(1<=a+j&&a+j<h-1&&1<=b+k&&b+k<w-1) {
						Point p = new Point(a+j,b+k);
						map.put(p, map.getOrDefault(p, 0)+1);
					}
				}
			}
		}
		long total[] = new long[10];
		total[0] = ((long)h-2)*(w-2) - map.size();
		for(int v:map.values()) total[v]++;
		for(int i=0;i<10;i++) {
			System.out.println(total[i]);
		}
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

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

int main() {

int N,A;
cin>>N>>A;
int L=A;
int R=A+N-1;

int eat;
if(R<=0)eat=R;
else if(L>=0)eat=L;
else eat=0;

int answer=(R+L)*(R-L+1)/2-eat;

cout<<answer<<endl;

return 0;

}

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

const int INF = 1001001001;

int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N), skill(M);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; ++i)
    {
        cin >> C.at(i);
        for (int j = 0; j < M; ++j)
        {
            cin >> A.at(i).at(j);
        }
    }

    int ans = INF;
    for (int i = 0; i < 1 << N; ++i)
    {
        int cost = 0;
        vector<int> und(M);
        for (int j = 0; j < N; ++j)
        {
            if (i >> j & 1)
            {
                cost += C.at(j);
                for (int k = 0; k < M; ++k)
                {
                    und.at(k) += A.at(j).at(k);
                }
            }
        }
        bool ok = true;
        for (int j = 0; j < M; ++j)
        {
            if (und.at(j) < X)
            {
                ok = false;
            }
        }
        if (ok)
        {
            ans = min(ans, cost);
        }
    }
    if (ans == INF)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }

    return 0;
}

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

int main () {
    int N; cin >> N;
    int w[N], ans = 10000;
    int sum1 = 0, sum2 = 0;
    for (int i = 0; i < N; i++) {
        cin >> w[i];
    }
    for (int i = 1; i < N; i++) {
        sum1 = 0; sum2 = 0;
        for (int j = 0; j < i; j++) {
            sum1 += w[j];
        }
        for (int j = i; j < N; j++) {
            sum2 += w[j];
        }
        ans = min(ans, abs(sum1 - sum2));
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef vector<ll> vll;

int N, A, B;
vll V;
vector<vll> C;

void make_xCy(int n) {
	C.clear();
	vll v;
	v.resize(n + 1, 0);
	C.resize(n + 1, v);
	for (int x = 0; x <= n; ++x) {
		for (int y = 0; y <= x; ++y) {
			if (y == 0 || y == x)
				C[x][y] = 1LL;
			else
				C[x][y] = (C[x - 1][y - 1] + C[x - 1][y]);
		}
	}
}

ll calcu_comb(void) {
	ll cmb = 1LL;
	if (A == N)
		return cmb;
	if (V[A - 1] != V[A])
		return cmb;
	int in_same = 1;
	for (int i = A - 2; i >= 0; --i) {
		if (V[A - 1] == V[i])
			++in_same;
	}
	int out_same = 0;
	for (int i = A; i < N; ++i) {
		if (V[A - 1] == V[i])
			++out_same;
	}
	
	int x = in_same + out_same;
	int y = in_same;
	make_xCy(x);
	
	if (in_same != A)
		cmb = C[x][y];
	else {
		cmb = 0LL;
		int xx = min(x, B);
		for (int i = A; i <= xx; ++i)
			cmb += C[x][i];
	}
	return cmb;
}

int main(void) {
	cin >> N >> A >> B;
	V.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> V[i];
	sort(V.begin(), V.end(), greater<ll>());

	ll sum = 0;
	for (int i = 0; i < A; ++i)
		sum += V[i];
	double ave = (double)sum / A;
	cout << fixed;
	cout.precision(7);
	cout << ave << '\n';

	ll cmb = calcu_comb();
	cout << cmb << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll h, n;
  cin >> h >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll sum = 0;
  rep(i,n) {
    sum += a[i];
  }
  if (sum >= h) yn;
  return 0;
}

Measured memory_bytes: 1024
hoge = [int(x) for x in input().split()]
N = hoge[0]
M = hoge[1]
K = hoge[2]
frag = False
foo = []
tmp = 0
for i in range(N):
    tmp += M
    foo.append(tmp)
    if foo[-1] == K:
        frag = True
for i in range(len(foo)):
    for j in range(M):
        ii = i+1
        foo[i] -= ii
        foo[i] += (N-ii)
        if foo[i] == K:
            frag = True
            break

    if frag == True:
        break

if frag == True:
    print("Yes")
else:
    print("No")

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

int main() {
	 
	int W, H, C, divisor, bolck_sum, ans;
	cin >> W >> H >> C;

	/* 回数を減らすために少ない方に入れ替える */
	if (W >= H)swap(W, H);

	for (int i = 1; i <= W; i++) {
		if (W % i == 0) {  /* 約数を求める */
			divisor = i;
			if (H % divisor == 0) bolck_sum = divisor * divisor;  /* 求めた約数から正方形を求める */
		}
	}

	/* 最小の費用の計算 */
	ans = C * (W * H) / bolck_sum;  /* 値段×( 縦の土地 × 横の土地 ) / 正方形の土地 */

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3124
import collections

n, m = map(int, input().split())

in_graph = [[] for i in range(n)]
out_graph = [[] for i in range(n)]
in_count = [0] * n
out_count = [0] * n
for i in range(n + m - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    out_graph[a].append(b)
    out_count[a] += 1
    in_graph[b].append(a)
    in_count[b] += 1
root = in_count.index(0)
ranks = [0] * n
parent = [0] * n
dq = collections.deque()
for i in range(n):
    if out_count[i] == 0:
        dq.append(i)
rank = n
while dq:
    v = dq.popleft()
    ranks[v] = rank
    rank -= 1
    for nv in in_graph[v]:
        out_count[nv] -= 1
        if out_count[nv] == 0:
            dq.append(nv)

for i in range(n):
    max_v = -1
    max_rank = -1
    for v in in_graph[i]:
        if max_rank < ranks[v]:
            max_rank = ranks[v]
            max_v = v
    print(max_v+1)

Measured memory_bytes: 77728
#![allow(unused)]

#[allow(unused_imports)]
use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::*;
use collections::{HashMap, HashSet};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let (a, b, k) = {
        let abk = parse_vec::<i32>();
        (abk[0], abk[1], abk[2])
    };

    for i in (a..(b + 1)).filter(|x| x - a < k || b - x < k) {
        println!("{}", i);
    }
}


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

int main(int argc, char const *argv[]) {
  char str[1001];

  while(1){
    scanf("%s", str);
    if(str[0] == '0') break;
    int sum = 0;
    for (int i = 0; i < strlen(str); i++) {
      sum += (str[i] - '0');
    }
    printf("%d\n", sum);
  }

  return 0;
}

Measured memory_bytes: 2700
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,k=mp()
a=lmp()
l=[]
i=0
ch=[0]*(n+1)
while True:
    if ch[i]==1:
        break
    else:
        ch[i]=1
        l.append(a[i])
        i=a[i]-1


x=l.index(a[i])
y=len(l)-x

if k<=x:
    print(l[k-1])
else:
    print(l[(k-x-1)%y+x])



Measured memory_bytes: 32556
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>

#define MAX_INT 2147483647
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::string;
using std::pair;
using std::cin;
using std::cout;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<bool> sugar(f + 1);
    vector<bool> water(f + 1);
    sugar[0] = water[0] = true;
    for (int i = 0; i < f; i++) {
        if (sugar[i]) {
            if (i + c <= f) {
                sugar[i + c] = true;
            }
            if (i + d <= f) {
                sugar[i + d] = true;
            }
        }
        if (water[i]) {
            if (i + a * 100 <= f) {
                water[i + a * 100] = true;
            }
            if (i + b * 100 <= f) {
                water[i + b * 100] = true;
            }
        }
    }
    int best_s = 0;
    int best_w = 100 * a;
    for (int s = 0; s <= f; s++) if (sugar[s]) {
        for (int w = 0; s + w <= f; w++) if (water[w]) {
            if (s * 100 <= w * e) {
                if (s * best_w >= best_s * w) {
                    best_s = s;
                    best_w = w;
                }
            }
        }
    }

    cout << (best_s + best_w) << " " << best_s << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int age,price;
 cin>>age>>price;
  if(age<=5)
    cout<<"0";
  else if(age>=6&&age<=12)
  { price=price/2;
   cout<<price;
  }
  else
    cout<<price;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define double long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 1000005;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,m,s=0,x;
        cin>>n>>m;
        for(int i=0;i<m;i++)cin>>x,s+=x;
        if(s>n)s = -1;
        else s=n-s;
        cout<<s<<endl;
    }
    return 0;
}
/*
Test Case
*/


Measured memory_bytes: 3660
// ALDS1_11_C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

vector<int> d(110,-1);
vector<vector<int>> to(110);
vector<int> setu(110,0);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    rep(i,n){
        int u,k;
        cin>>u>>k;
        setu[u]=k;
        rep(j,k){
            int q;
            cin>>q;
            to[u].emplace_back(q);
        }
    }
    queue<int> next;
    next.push(1);
    d[1]=0;
    while(!next.empty()){
        int cur=next.front();
        next.pop();
        for(int i=0;i<setu[cur];i++){
            int t=to[cur][i];
            //１に近いところから見ているので、もし距離が更新されているならそれ以上距離が短くなることはない。
            //よって、そのnodeからの探索はしなくていい。a⇔bのときに無限ループしちゃう。
            if(d[t]!=-1) continue; 
            d[t]=d[cur]+1;
            next.push(t);
        }
    }
    for(int i=1;i<=n;i++){
        cout<<i<<" "<<d[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3220
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(a, b int) int {
	if a < b {
		a = b
	}
	return a
}

// ref.
// https://qiita.com/tnoda_/items/b503a72eac82862d30c6
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	dpNoFlip := 0
	dpDoFlip := -1 * (2 << 61)

	for i := 0; i < n; i++ {
		aI := nextInt()
		tmpNoFlip := dpNoFlip
		tmpDoFlip := dpDoFlip
		dpNoFlip = max(tmpNoFlip+aI, tmpDoFlip-aI)
		dpDoFlip = max(tmpNoFlip-aI, tmpDoFlip+aI)
	}

	fmt.Println(dpNoFlip)
}


Measured memory_bytes: 2304
n = int(input())
li = []
c = 0
for i in range(n):
    w = input()
    if w in li:
        c = 1
    
    li.append(w)

for i in range(1,n):
    if li[i-1][-1] != li[i][0]:
        c = 1

if c == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	int n=s.size();
	int out=0;
	loop(i,1,n/2){
		bool h=true;
		rep(j,i)if(s[j]!=s[j+i])h=false;
		if(h)out=i;
	}
	cout<<out*2<<endl;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 998244353;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() cin.tie(0), ios::sync_with_stdio(false)

using ll = long long;
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) (res *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return res;
}

int N;

int main() {
  cin >> N;
  vector<int> x(N + 1);
  for(int i = 0; i < N; i++) { cin >> x[i + 1]; }

  ll ans = 0;

  for(int i = 1; i <= N; i++) {
    ans += mod_pow(2, N - i, mod) * x[i] % mod *
           mod_pow(x[i] + 1, i - 1, mod) % mod;
    ans %= mod;
  }
  cout << ans % mod << endl;
}


Measured memory_bytes: 6728
//package ac144;
import java.lang.*;
import java.math.*;
import java.util.Scanner;
import java.io.*;
public class Main {
	static Scanner scn = new Scanner(System.in);
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		
		int a = scn.nextInt();
		int b = scn.nextInt();
		if(a>=1&&a<=9&&b>=1&&b<=9) {
			int ans = a*b;
			System.out.println(ans);
		}else {
			System.out.println(-1);
		}
	}

}


Measured memory_bytes: 23636
# setting
from itertools import accumulate

#------------------
n, m, q = map(int, input().split())

LR = [[0 for _ in range(n-i)] for i in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    LR[l-1][r-l] += 1

for i in range(n-2, -1, -1):
    for j, acc in enumerate(accumulate(LR[i])):
        LR[i][j] = acc  + (0 if j == 0 else LR[i+1][j-1])

res = list()
for i in range(q):
    p,q = map(int, input().split())
    res.append(LR[p-1][q-p])

for r in res:
    print(r)

Measured memory_bytes: 9560
n=gets.chomp.to_i
s=gets.chomp.split(" ").map{|i|i.to_i}
q=gets.chomp.to_i
t=gets.chomp.split(" ").map{|i|i.to_i}
cnt=0
t.each do |i|
  s.each do |j|
    if i == j
      cnt += 1
      break
    end
  end
end
puts cnt


Measured memory_bytes: 7176
#include <cstdio>

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

using namespace std;

const int P_MAX=100000;
bool er[P_MAX+1];
void sieve(){
	rep(i,P_MAX+1) er[i]=(i>=2);
	for(int i=2;i*i<=P_MAX;i++) if(er[i]) for(int j=i*i;j<=P_MAX;j+=i) er[j]=false;
}

int main(){
	sieve();

	int ans[100001]={};
	for(int i=1;i<=100000;i++){
		ans[i]=ans[i-1];
		if(i%2==1 && er[i] && er[(i+1)/2]) ans[i]++;
	}

	int q; scanf("%d",&q);
	rep(i,q){
		int l,r; scanf("%d%d",&l,&r);
		printf("%d\n",ans[r]-ans[l-1]);
	}

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int number,i;
  char str[5];
  
  fgets(str,sizeof(str),stdin);
  
  for(i=0,number=0;i<4;i++){
    if(str[i]=='+'){
      number++;
    }else{
      number--;
    }
  }
  
  printf("%d\n",number);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define INF 2e9
using namespace std;
const int N=1e6+1;
const int mod=1e9+7;
ll fastexp(ll base,ll exp){
	base%=mod;
	ll ans=1;
	while(exp>0){
		if(exp&1){
			ans*=base;
			ans%=mod;
		}
		base*=base;
		base%=mod;
		exp/=2;
	}
	return ans;
}
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}
ll arr[N];
int main() {
	char x;
	cin >> x;
	if(isupper(x)){
		cout << "A";
	}
	else {
		cout << "a";
	}
	return 0;
}
   






   







Measured memory_bytes: 3628
# ABC48 C - Boxes and Candies
N, X = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if a[i]+a[i+1] > X:
        d = a[i]+a[i+1]-X
        a[i+1] = max(0, a[i+1]-d)
        ans += d
print(ans)

Measured memory_bytes: 14252
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

#include <cassert>
using namespace std;

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

    int n, x;
    cin >> n >> x;
    vector<int> a(2 * n);
    for (int i = n; i < 2 * n; ++i) {
        cin >> a[i];
    }

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

    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        b[i] = a[i];
    }

    long long result = 0;
    for (int i = 0; i < n; ++i) {
        result += b[i];
    }

    for (int len = 1; len <= n; ++len) {
        for (int i = 0; i < n; ++i) {
            b[i] = min(b[i], a[i + n - len]);
        }
        long long curResult = 0;
        for (int i = 0; i < n; ++i) {
            curResult += b[i];
        }
        curResult += 1LL * x * len;
        result = min(result, curResult);
    }

    cout << result << endl;

    return 0;
}

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

int main()
{
  long long a, b;
  cin >> a >> b;
  for (int i = 1; i <= b; i++)
  {
    if ((a * i) % b == 0)
    {
      cout << a * i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]

ct = 0

while(max(H) > 0):
    t = max(H)
    k = H.index(t)
    s = {k}
    while(k < N-1 and H[k+1] == H[k]):
        s.add(k+1)
        k += 1
    else:
        for j in s:
            H[j] -= 1
        ct += 1

print(ct)


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    	return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}
const ll N=200000+11;
ll fact[N];
ll inv[N];
void pri(ll mod){
	fact[0]=fact[1]=1;
	for(int i=2;i<=2e5;i++){
		fact[i]=(i*fact[i-1])%mod;
	}
	inv[200000]=modinv(fact[200000],mod);
	for(int i=200000-1;i>=0;i--){
		inv[i]=(inv[i+1]*(i+1))%mod;
	}
	
}
void solve(){
	
    ll i,j,k,l,n,m,x,y,z,r;
	 ll mod=998244353;
	 
	 pri(mod);
	 
	 cin>>n>>m>>k;
	 ll ans=0;
	 for(i=0;i<=k;i++){
	 	ll tt=pow1(m-1,n-1-i,mod);
	 	tt*=m;
	 	tt%=mod;
	 	// cout<<tt<<endl;
	 	tt*=fact[n-1];
	 	tt%=mod;
	 	
	 	tt*=inv[i];
	 	tt%=mod;
	 	
	 	tt*=inv[n-1-i];
	 	tt%=mod;
	 	
	 	// cout<<tt<<endl;
	 	ans+=tt;
	 	ans%=mod;
	 }
	 
	 cout<<ans<<endl;
 
	
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll binarySearch(ll arr[], ll l, ll r, ll x)
{
    if (r >= l) {
        ll mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);

        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
int main(){
    ll t;
    cin>>t;
    ll a[4]={0};
    while(t--){
        string s;
        cin>>s;
        if(s=="AC"){
            a[0]++;
        }
        else if(s=="WA"){
            a[1]++;
        }
        else if(s=="TLE"){
            a[2]++;
        }
        else{
            a[3]++;
        }
    }
    cout<<"AC x "<<a[0]<<endl<<"WA x "<<a[1]<<endl<<"TLE x "<<a[2]<<endl<<"RE x "<<a[3]<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    String az="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	    int h=gi();
	    int w=gi();


	    for (int i=0; i<h;i++) {
	    	for (int j=0; j<w;j++) {
	    		String s= gs();
	    	    if (s.equals("snuke")) {
	    	    	System.out.print(String.valueOf(az.charAt(j))+(i+1));
	    	    	return;
	    	    }
	    	}
	    }

	    //System.out.print(c);
//	    if (n%10==3) {
//	    	System.out.print("bon");
//	    }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
//	    	System.out.print("pon");
//	    } else {
//	    	System.out.print("hon");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38924
n = int(input())
x = 0
y = 0
time = 0
for i in range(n):
    m = list(map(int,input().split()))
    if (m[0]-time)>=abs(m[1]-x)+abs(m[2]-y):
        if ((m[0]-time) -(abs(m[1]-x) + abs(m[2]-y)))%2 ==0:
            x = m[1]
            y = m[2]
            time = m[0]
            if i == n-1:
                print("Yes")
        else:
            print("No")
            break
    else:
        print("No")
        break

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	vector<int> water;
	for (int i = 0; i <= 30; i++) {
		for (int j = 0; j <= 30; j++) {
			water.emplace_back(100 * a * i + 100 * b * j);
			if (water.back() > f || water.back() == 0) {
				water.pop_back();
			}
		}
	}
	
	vector<int> sugar;
	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {
			sugar.emplace_back(c * i + d * j);
			if (sugar.back() > f) {
				sugar.pop_back();
			}
		}
	}

	sort(water.begin(), water.end());
	water.erase(unique(water.begin(), water.end()), water.end());
	sort(sugar.begin(), sugar.end());
	sugar.erase(unique(sugar.begin(), sugar.end()), sugar.end());

	double ret = -1.0;
	int x, y;
	for (auto &i : water) {
		for (auto &j : sugar) {
			if (i + j > f || i * e < j * 100) {
				continue;
			}

			if (ret < (double)j / (i + j)) {
				ret = (double)j / (i + j);
				x = i;
				y = j;
			}
		}
	}
	cout << x + y << " " << y << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[32];
	int i,j,k,n,m;
	char c;
	for(i=0;i<32;i++){
		a[i]=i;
	}
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>j>>c>>k;
		swap(a[j],a[k]);
	}
	for(i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
  int total,a;
  char ch, r;
  int j,i;
  int cards[4][13];

  for(i=0;i<4;i++){
    for(j=1;j<14;j++){
      cards[i][j]=0;
    }
  }

  scanf("%d",&total);
  for(a=0;a<total;a++){
    scanf("%c%c %d",&r,&ch,&j);
    if(ch=='S') i=0;
    if(ch=='H') i=1;
    if(ch=='C') i=2;
    if(ch=='D') i=3;
    cards[i][j]=1;
  }
  for(i=0;i<4;i++){
    for(j=1;j<14;j++){
      if(cards[i][j]!=1){
	if(i==0) ch='S';
	if(i==1) ch='H';
	if(i==2) ch='C';
  	if(i==3) ch='D';
	printf("%c %d\n",ch,j);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// ここから開始
int main(){
  int n;
  string s;
  cin>>n>>s;
  string s1,s2;
  for(int i = 0; i < s.length()/2; i++){
    s1+=s[i];
  }
  for(int i = s.length()/2; i < s.length(); i++){
    s2+=s[i];
  }
  // cout<<s1<<s2;
  if(s1==s2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll n;
	cin >> n;
	vector<ll> a(n);
	ll ans = 0;
	rep(i, n)
	{
		cin >> a[i];
	}
	ll ma = a[0];
	for (int i = 1; i < n; i++)
	{
		if (a[i] < ma)
		{
			ans += ma - a[i];
		}
		else
			ma = a[i];
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  int n,d;
  cin>>n>>d;
  vector<vector<int>> xy(n,vector<int>(2));
  vector<vector<int>> xif;
  for(int i=0;i<n;i++){
    cin>>xy.at(i).at(0)>>xy.at(i).at(1);
    xif.push_back({xy.at(i).at(0),i,0});
    xif.push_back({xy.at(i).at(1),i,1});
  }
  sort(xif.begin(),xif.end());
  two_sat f(n);
  for(int l=0,r=0;l<n*2;l++){
    while(r<n*2&&xif.at(r).at(0)<xif.at(l).at(0)+d)
      r++;
    for(int i=l+1;i<r;i++)
      f.add_clause(xif.at(l).at(1),!(bool)xif.at(l).at(2),xif.at(i).at(1),!(bool)xif.at(i).at(2));
  }
  cout<<(f.satisfiable()?"Yes":"No")<<endl;
  if(!f.satisfiable())
    return 0;
  vector<bool> a=f.answer();
  for(int i=0;i<n;i++)
    cout<<xy.at(i).at((int)a.at(i))<<endl;
}

Measured memory_bytes: 3876
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include<algorithm>
#include <queue>
using namespace std;
 
#define int long long
#define INF 1001001001

int arr[200001];
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}


int num[3];

int32_t main() {
	
   int N,M;
   
   cin >> N>>M; 
   num[0] = num[1] = num[2] = -1;

   for(int i=0; i<M; i++){
   	
   		int s,c;
   		
   		cin >> s >> c;  		
   		
   	 	if(num[s-1] != -1 && num[s-1] != c){
   	 		cout << "-1" << endl;
   	 		return 0;
		}			
   	
   		num[s-1] = c;
   }
   
   if(num[0] == 0 && N>1){
   		cout << "-1" << endl;
   }
   else{
   		if(N==1 && num[0]==-1){
   			cout << 0 << endl;
		   }
   		else{
		   
   		
	   		for(int i =0; i<N;i++){
	   			
	   			if(num[i] ==-1 && i==0){
	   				cout << 1;
				}
	   			else{
	   				if(num[i] == -1)
	   					cout << 0 ;
	   				else
	   					cout << num[i];
				}	
	   			
			}
  		 }
   }
}

Measured memory_bytes: 3156
#include<iostream>
#include<sstream>
using namespace std;
int main(){
  string s;
  while(cin >> s) {
    for(int i=0;i<s.size();i++) if(s[i]==',') s[i]=' ';
    stringstream ss(s);
    int id;double w,h;
    ss >> id >> w >> h;
    double bmi=w/(h*h);
    if(bmi>=25.0) cout << id << endl;
  }
}



Measured memory_bytes: 3200
// A C++ program to find maximal Bipartite matching.
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
 
// M is number of applicants and N is number of jobs
#define M 110
#define N 110
typedef	pair<int, int>	pii;
pii pb[N], pr[N];
// A DFS based recursive function that returns true if a
// matching for vertex u is possible
bool bpm(bool bpGraph[M][N], int u, bool seen[], int matchR[])
{
    // Try every job one by one
    for (int v = 0; v < N; v++)
    {
        // If applicant u is interested in job v and v is
        // not visited
        if (bpGraph[u][v] && !seen[v])
        {
            seen[v] = true; // Mark v as visited
 
            // If job 'v' is not assigned to an applicant OR
            // previously assigned applicant for job v (which is matchR[v]) 
            // has an alternate job available. 
            // Since v is marked as visited in the above line, matchR[v] 
            // in the following recursive call will not get job 'v' again
            if (matchR[v] < 0 || bpm(bpGraph, matchR[v], seen, matchR))
            {
                matchR[v] = u;
                return true;
            }
        }
    }
    return false;
}
 
// Returns maximum number of matching from M to N
int maxBPM(bool bpGraph[M][N])
{
    // An array to keep track of the applicants assigned to
    // jobs. The value of matchR[i] is the applicant number
    // assigned to job i, the value -1 indicates nobody is
    // assigned.
    int matchR[N];
 
    // Initially all jobs are available
    memset(matchR, -1, sizeof(matchR));
 
    int result = 0; // Count of jobs assigned to applicants
    for (int u = 0; u < M; u++)
    {
        // Mark all jobs as not seen for next applicant.
        bool seen[N];
        memset(seen, 0, sizeof(seen));
 
        // Find if the applicant 'u' can get a job
        if (bpm(bpGraph, u, seen, matchR))
            result++;
    }
    return result;
}

bool adj[N][N];

int main (){
	int n;
	
	scanf("%d", &n);
	
	for(int i = 0 ; i < n ; i++){
		scanf("%d%d", &pr[i].first, &pr[i].second);
	}
	
	for(int i = 0 ; i < n ; i++){
		scanf("%d%d", &pb[i].first, &pb[i].second);
	}
	
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			if(pr[i].first < pb[j].first && pr[i].second < pb[j].second){
				adj[i][j] = true;
			}
		}
	}
	
	printf("%d\n", maxBPM(adj));
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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



int main(){
	int n,m;
	vector<vector<int> > ans;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && n==0) break;
		
		vector<int> tmp;
		for(int i=n;i<=m;i++){
			bool isok = i % 400 == 0 
				? true : i % 100 == 0
				? false : i % 4 == 0
				? true : false;

			if(isok){
				tmp.push_back(i);
			}
		}

		ans.push_back(tmp);
	}

	for(int i=0;i<ans.size();i++){
		for(int j=0;j<ans[i].size();j++){
			cout << ans[i][j] << endl;
		}

		if(ans[i].size() == 0)
		{
			cout << "NA" << endl;
		}

		printf("%s",i==ans.size()-1 ? "" : "\n");
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int n;
string s;
int reddp[4004];
int greendp[4004];
int bluedp[4004]; 
void init(int start){
	if(start==n-1){
		if(s[start]=='R') reddp[start]=1;
		else if(s[start]=='G') greendp[start]=1;
		else if(s[start]=='B') bluedp[start]=1;
		return;
	}
	
	init(start+1);
	reddp[start]=reddp[start+1];
	greendp[start]=greendp[start+1];
	bluedp[start]=bluedp[start+1];
	
	if(s[start]=='R') reddp[start]+=1;
	else if(s[start]=='G') greendp[start]+=1;
	else bluedp[start]+=1;
}

long long solve(int start){ //start에서 시작하는 조합 개수  
	long long ret=0;
	
	if(s[start]=='R'){
		for(int j=start+1; j<n; j++){
			if(s[j]=='G'){//
				ret+=bluedp[j+1];
				if(s[2*j-start]=='B') ret-=1;	
			}
			else if(s[j]=='B'){//
				ret+=greendp[j+1];
				if(s[2*j-start]=='G') ret-=1;
			}
		}	
	}
	else if(s[start]=='G'){
		for(int j=start+1; j<n; j++){
			if(s[j]=='R'){//
				ret+=bluedp[j+1];
				if(s[2*j-start]=='B') ret-=1;
			}
			else if(s[j]=='B'){//
				ret+=reddp[j+1];
				if(s[2*j-start]=='R') ret-=1;
			}
		}
	}
	else{
		for(int j=start+1; j<n; j++){
			if(s[j]=='R'){
				ret+=greendp[j+1];
				if(s[2*j-start]=='G') ret-=1;
			}
			else if(s[j]=='G'){
				ret+=reddp[j+1];
				if(s[2*j-start]=='R') ret-=1;
			}
		}
	}
	return ret;
}
int main(){
	cin>>n>>s;
	init(0);
	long long ret=0;
	for(int i=0; i<n; i++) ret+=solve(i);
	cout<<ret;
}

Measured memory_bytes: 3276
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string s;
   cin >> s;
   for (int i = 0; i < (int)s.size(); i++) {
      if (s[i] == ',') cout << " ";
      else cout << s[i];
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+10;
vector<int> ps[L];
char c[L];

bool target[L];
bool f(int r,int p)
{
	bool ok=c[r]=='W';
	vector<int> nx;
	for(auto j:ps[r]){
		if(j!=p){
			if(f(j,r)){
				ok=true;
				nx.push_back(j);
			}
		}
		else if(p){
			nx.push_back(j);
		}
	}
	nx.swap(ps[r]);
	target[r]=ok;
	return ok;
}
P g(int r,int p)
{
	int d=0;
	bool odd=ps[r].size()%2;
	bool black=c[r]=='B';
	if(odd==black){
		d++;
	}
	P ret=P(d,r);
	for(int j:ps[r]){
		if(j!=p){
			auto q=g(j,r);
			q.first+=d;
			ret=max(ret,q);
		}
	}
	return ret;
}
int main() {
	int N;
	cin >> N;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		ps[a].push_back(b);
		ps[b].push_back(a);
	}
	cin >> (c+1);
	int r=0;
	for(int i=1;i<=N;i++){
		if(c[i]=='W'){
			r=i;
			break;
		}
	}
	if(r==0){
		cout << 0 << endl;
		return 0;
	}
	f(r,0);
	int d=0;
	int a=0;
	for(int i=1;i<=N;i++){
		if(target[i]){
			d++;
			bool odd=ps[i].size()%2;
			bool black=c[i]=='B';
			if(odd==black)
			{
				a++;
			}
		}
	}
	if(d==1){
		cout << 1 << endl;
		return 0;
	}
	int ret=2*(d-1)+a;
	//cerr << d << ", " << a << endl;
	//cerr << ret << endl;
	auto p=g(r,0);
	//cerr << p.first << "," << p.second << endl;
	p=g(p.second,0);
	//cerr << p.first << "," << p.second << endl;
	ret-=2*p.first;
	cout << ret << endl;

	return 0;
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 3030;

#define prev qowieurowilaksdfj


int n, m;
string s,t;

int dp[maxn][maxn];
pair<int,int> prev[maxn][maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>s>>t;
    n=s.length();
    m=t.length();

    for (int i=1; i<=n; i++) {
	for (int j=1; j<=m; j++) {
	    if (s[i-1]==t[j-1]) {
		if (1+dp[i-1][j-1]>dp[i][j]) {
		    dp[i][j]=1+dp[i-1][j-1];
		    prev[i][j]=make_pair(i-1,j-1);
		}
	    }

	    if (dp[i-1][j-1]>dp[i][j]) {
		dp[i][j]=dp[i-1][j-1];
		prev[i][j]=make_pair(i-1,j-1);
	    }

	    //j-1
	    if (dp[i][j-1]>dp[i][j]) {
		dp[i][j]=dp[i][j-1];
		prev[i][j]=make_pair(i,j-1);
	    }

	    //i-1
	    if (dp[i-1][j]>dp[i][j]) {
		dp[i][j]=dp[i-1][j];
		prev[i][j]=make_pair(i-1,j);
	    }
	}
    }

    cerr<<dp[n][m]<<endl;

    string res;
    int i=n;
    int j=m;
    while (i>0 && j>0) {
	if (s[i-1]==t[j-1]) {
	    res += s[i-1];
	}
	auto to = prev[i][j];
	i = to.first;
	j = to.second;
    }

    reverse(res.begin(), res.end());
    out(res);
  

    return 0;
}


Measured memory_bytes: 107520
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;

struct Connection
{
	vector<int> connects;
	int currentCount = 0;
	int myCount = 0;
};

void Dfs(int currentCount, Connection* connections, int index,int parent)
{
	currentCount += connections[index].myCount;
	connections[index].currentCount = currentCount;
	for(int l : connections[index].connects)
	{
		if (l == parent) continue;
		Dfs(currentCount, connections, l,index);
	}
}

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

	Connection *connections = new Connection[N];
	for (int i = 0; i < N - 1;++i) {
		int a, b;
		cin >> a >> b;
		connections[a - 1].connects.push_back(b - 1);
		connections[b - 1].connects.push_back(a - 1);
	}

	for (int i = 0; i < Q; ++i) {
		int p, q;
		cin >> p >> q;
		connections[p - 1].myCount += q;
	}

	Dfs(0,connections,0,-1);

	for (int i = 0; i < N; ++i) {
		cout << connections[i].currentCount << " " ;
	}

	delete[] connections;
}


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

int solve(int e){
  int x, y, z;
  int y2, z3;
  int y_end, z_end;
  int m = INT_MAX / 2;
  for(z = 0; z < e; z++){
    z3 = z * z * z;
    if(z3 > e) break;
    for(y = 0; y < e; y++){
      y2 = y * y;
      if(z3 + y2 > e) break;
      x = e - z3 - y2;
      if(x < 0) break;
      m = min(x + y + z, m);
    }
  }
  return m;
}

int main(){
  while(true){
    int e;
    scanf(" %d", &e);
    if(e == 0) break;
    printf("%d\n", solve(e));
  }
}


Measured memory_bytes: 1188