akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

string s;

// for 1s
vector<int> ls;
// for 0s
vector<int> rs;

int main(void) {
    int N, K;
    cin >> N >> K;

    cin >> s;

    if (s[0] == '0') {
        ls.push_back(0);
    }

    {
        int pos = 1;
        int cnt = 1;
        char prev = s[0];
        while (pos < N) {
            if (s[pos] == prev) {
                cnt++;
            } else {
                if (prev == '0') {
                    rs.push_back(cnt);
                } else {
                    ls.push_back(cnt);
                }
                prev = s[pos];
                cnt = 1;
            }
            pos++;
        }
        if (prev == '0') {
            rs.push_back(cnt);
        } else {
            ls.push_back(cnt);
        }
    }

    if (s[N - 1] == '0') {
        ls.push_back(0);
    }

#ifdef DEBUG
    printf("ls: \n");
    for (auto x : ls) {
        cout << x << " ";
    }
    cout << endl;

    printf("rs: \n");
    for (auto x : rs) {
        cout << x << " ";
    }
    cout << endl;
#endif

    if ((int) rs.size() <= K) {
        // can satisfy all people
        cout << N << endl;
        return 0;
    }

    int acc = 0;
    for (int i = 0; i < K; i++) {
        acc += ls[i];
        acc += rs[i];
    }
    acc += ls[K];

    int ans = acc;
    for (int i = K; i < (int) rs.size(); i++) {
        acc -= ls[i - K];
        acc -= rs[i - K];
        acc += ls[i + 1];
        acc += rs[i];
        chmax(ans, acc);
    }

    cout << ans << endl;

    return 0;
}


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

bool isprime(int x) {
    if (x <= 1) return false;
    for (int i = 2; i*i <= x; i++) {
        if (x%i == 0) return false;
    }
    return true;
}

int main(void){
    int x;
    cin >> x;
    int p = x;
    while (!isprime(p)) p++;
    cout << p << endl;
    return 0;
}

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

int main(){
    int n, m, l, r, i, cg = 0, c = 0;
    cin >> n >> m;
    int g[n+1] = {};
    for(i=0; i<m; i++){
        cin >> l >> r;
        g[l-1]++;
        g[r]--;
    }
    for(i=0; i<n; i++){
        cg += g[i];
        if(cg == m){
            c++;
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 640
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  [n, m] <- readInts
  a      <- readInts
  print $ solve n m a

solve n m a | not b     = 0
            | otherwise = (m `div` (foldl1 lcm as) + 1) `div` 2
 where
  as = map (\x -> x `div` 2) a
  b  = 1 == (length $ group $ map (\aa -> f aa 0) a)

f n acc | even n    = f (n `div` 2) (acc + 1)
        | otherwise = acc


Measured memory_bytes: 19196
#include <stdio.h>
#define ll long long
#define ull unsigned ll
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
ll a[2010];
ull s[40010];
ll sum;
int main()
{
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		scanf("%lld",a+i);
		sum+=a[i];
	}
	s[0]=1;
	rep(i,0,n){
		for(int j=34000-a[i]/64;j>=0;j--){
			if(a[i]%64)s[j+a[i]/64+1]|=s[j]>>(64-a[i]%64);
			s[j+a[i]/64]|=s[j]<<(a[i]%64);
		}
	}
	for(ll ans=sum/2;;ans--)if(bit(s[ans/64],ans%64)){
		printf("%lld",sum-ans);
		return 0;
	}
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
const int N=2510;
int n,m,p;
bool vis[N],vis2[N];
vector<pii >G[N];
vector<int>og[N];
ll dis[N];
const ll inf=2e18;
queue<int>qu;
//
int main(){
	n=getint();m=getint();p=getint();
	rep(i,m){
		int x=getint()-1,y=getint()-1,z=getint();
		G[x].push_back(mp(y,z-p));
		og[y].push_back(x);
	}
	vis[n-1]=true;qu.push(n-1);
	rep(i,n)dis[i]=-inf;
	dis[0]=0;
	while(!qu.empty()){
		int u=qu.front();qu.pop();
		rep(i,og[u].size()){
			if(!vis[og[u][i]]){
				vis[og[u][i]]=true;
				qu.push(og[u][i]);
			}	
		}
	}
	vis2[0]=1;qu.push(0);
	while(!qu.empty()){
		int u=qu.front();qu.pop();
		rep(i,G[u].size()){
			if(!vis2[G[u][i].first]){
				vis2[G[u][i].first]=true;
				qu.push(G[u][i].first);
			}
		}
	}
//	rep(i,n)cout<<vis[i]<< ""<<
	rep(i,n)vis[i]&=vis2[i];
	rep(i,n+1){
		bool flag=false;
		rep(j,n)if(vis[j])rep(k,G[j].size())if(vis[G[j][k].first]&&dis[j]+G[j][k].second>dis[G[j][k].first]){
			dis[G[j][k].first]=dis[j]+G[j][k].second;
			flag=true;
		}
		if(!flag)break;
		if(i==n){
			return !printf("%d\n",-1);
		}
	}
	printf("%lld\n",max(dis[n-1],0ll));
	return 0;
}


Measured memory_bytes: 512
import bisect

N, M = [int(i) for i in input().split()]
alist = [int(i) for i in input().split()]
alist.sort()
inputs = [[int(i) for i in input().split()] for j in range(M)]
inputs.sort(key=lambda x:x[1], reverse=True)

for i in range(N):
    if len(inputs) == 0:
        break
    if inputs[0][1] > alist[i]:
        alist[i] = inputs[0][1]
        inputs[0][0] -= 1
        if inputs[0][0] == 0:
            inputs.pop(0)
    else:
        break
print(sum(alist))



Measured memory_bytes: 27000
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,q,l,r,c=0;
    string s;
    cin>>n>>q>>s;
    vector<ll> v(n);
    v[0]=0;
    for(ll i=0;i<n-1;i++){
        if(s.substr(i,2)=="AC") v[i+1]=++c;
        else v[i+1]=c;
    }
    for(ll i=0;i<q;i++){
        cin>>l>>r;
        cout<<v[r-1]-v[l-1]<<endl;
    }
    return 0;
}

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

vector<int> adj[200005];

int label[200005];
int smd[200005];

int n, q;

void dfs_out(int node, int last, int s) {
  smd[node] = label[node] + s;
  for (int i=0; i<adj[node].size(); i++) {
    int other = adj[node][i];
    if (other == last) continue;
    dfs_out(other, node, smd[node]);
  }
}

int main() {

  cin >> n >> q;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i=0; i<q; i++) {
    int nodenum, val;
    cin >> nodenum >> val;
    label[nodenum] += val;
  }

  dfs_out(1, -1, 0);

  for (int i=1; i<=n; i++) {
    cout << smd[i] << ' ';
  }

}

Measured memory_bytes: 27136
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, INF = 1e9 + 100;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int a, b;
	cin >> a >> b;
	if(b >= a){
		cout << "unsafe\n";
	}else{
		cout << "safe\n";
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAX = 3e5 + 10;

int a[MAX];
int sum[MAX];
void solve() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]%=mod;
    }
    for(int i=n;i>0;i--){
        sum[i]+=a[i]+sum[i+1];
        sum[i]%=mod;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        int tem=a[i]*(sum[i+1])%mod;
        tem%=mod;
        ans+=tem;
        ans%=mod;
    }
    cout<<ans%mod;
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
    //cin>>_;
    while (_--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6744
//
// 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 mut $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")
    };
}

// solution 
use std::collections::HashSet;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        a: [usize; N],
    }

    let mut colors: HashSet<&'static str> = HashSet::new();
    let mut count = 0;
    for &a in a.iter() {
        match a/400 {
            0 => {colors.insert("gray");},
            1 => {colors.insert("brown");},
            2 => {colors.insert("green");},
            3 => {colors.insert("light blue");},
            4 => {colors.insert("blue");},
            5 => {colors.insert("yellow");},
            6 => {colors.insert("orange");},
            7 => {colors.insert("red");},
            _ => {count+=1;},
        }
    }

    if colors.len() == 0 {
        println!("{} {}", 1, count);
    } else {
        println!("{} {}", colors.len(), count+colors.len());
    }
}


Measured memory_bytes: 4352
n, k = gets.split.map(&:to_i)

answer = (1..n).inject(0) do |result, num|
  score = num
  double_up_count = 0

  while score < k
    score *= 2
    double_up_count += 1
  end

  possibility = (1.0/n) * (1.0/2) ** double_up_count
  result + possibility
end

puts answer


Measured memory_bytes: 3836
# -*- coding: utf-8 -*-
from math import floor, ceil, sqrt
def isprime(n: int) -> bool:
    """
    Return n is a prime number or not
    """
    tmp = ceil(sqrt(n))
    for i in range(2, tmp + 1):
        if n % i:
            continue
        else:
            return False
    else:
        return True


x = int(input())
if x == 2:
    print(2)
    exit()
for i in range(x, 100004):
    if isprime(i):
        print(i)
        exit()


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

int main() {
    int a,b,c,temp;
    cin>>a>>b>>c;
    temp=b;
    b=a;
    a=c;
    c=temp;
    cout<<a;
    cout<<" ";
    cout<<b;
    cout<<" ";
    cout<<c;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n;
    std::cin>>n;

    int ans = 1;
    for(int i = 0;i < n;i++){
        int k = pow(2, i);
        if(k > n){
            ans = k / 2;
            break;
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
ans = 0
for i in range(n):
    a,b = lr()
    if a==b:
        ans+=1
    else:
        ans=0
    if ans == 3:
        print('Yes')
        sys.exit()
print('No')


Measured memory_bytes: 72680
a = []
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))

n = int(input())

b_list = []
count_list = []

for i in range(n):
    b_list.append(int(input()))

for i in range(3):
    for j in range(3):
        for b in b_list:
            if a[i][j] == b:
                count_list.append(str(i) + str(j))

if ((("00" in count_list) and ("01" in count_list) and ("02" in count_list)) or
   (("10" in count_list) and ("11" in count_list) and ("12" in count_list)) or
   (("20" in count_list) and ("21" in count_list) and ("22" in count_list))):
        print("Yes")
elif ((("00" in count_list) and ("10" in count_list) and ("20" in count_list)) or
   (("01" in count_list) and ("11" in count_list) and ("21" in count_list)) or
   (("02" in count_list) and ("12" in count_list) and ("22" in count_list))):
        print("Yes")
elif ((("00" in count_list) and ("11" in count_list) and ("22" in count_list)) or
   (("02" in count_list) and ("11" in count_list) and ("20" in count_list))):
        print("Yes")
else:
        print("No")
    

        
    










Measured memory_bytes: 3064
(function main() {
  let line = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('');
  // 初めの上昇と平坦を除去
  while (line.length > 0 && line[0] !== '\\') line.shift();
  // 終わりの下降と平坦を除去
  while (line.length > 0 && line[line.length - 1] !== '/') line.pop();

  let height_list = [0];
  let current_height = 0;
  line.forEach(function(e, i){
      if (e === '\\') current_height -= 1
      else if (e === '/') current_height += 1
      height_list.push(current_height);
  });

  let h, sum = 0;
  let holes = [];
  for (;height_list.length > 1;) {
    if (h = makeHole(height_list)) {
      sum += h;
      holes.push(h);
    }
  }

  console.log(sum);
  console.log(holes.length && holes.length + ' ' + holes.join(' '));
})();

function makeHole(list) {
    begin = list.shift();
    let area = 0;
    if (list[0] < begin && begin <= list.reduce((a, b) => Math.max(a, b), -200000)) {
      while (!(list.length === 0 || begin <= list[0])) area += begin - list.shift();
    }
    return area;
}



Measured memory_bytes: 21060
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = in.nextInt();
		while (true) {
			if (isSame(n)) {
				out.println(n);
				break;
			} else {
				n++;
			}
		}
		out.flush();
		out.close();

	}

	private static boolean isSame(int n) {
		// TODO Auto-generated method stub
		char[] a = String.valueOf(n).toCharArray();
		for (int i = 0; i < a.length; i++) {
			if (a[0] != a[i]) {
				return false;
			}
		}
		return true;
	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}

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

int main(){
  int n;
  cin>>n;
  if(n<3){
    cout<<"No"<<endl;
  }
  else{
    vector<int> d1, d2;
    while(n--){
      int a,b;
      cin>>a>>b;
      d1.push_back(a);
      d2.push_back(b);
    }
    for(int i=0; i<d1.size(); ++i){
      if(i==(d1.size()-2)){
        cout<<"No"<<endl;
        break;
      }
      if((d1[i]==d2[i]) && (d1[i+1]==d2[i+1]) && (d1[i+2]==d2[i+2])){
        cout<<"Yes"<<endl;      
        break;
      }
    }
  }
}


Measured memory_bytes: 3628
a,b,c,d=map(int,input().split())
#小文字の方は動かさない
x=a
y=b
l=[]
while y<d:
    y+=1
    l.append('U')
while x<c:
    x+=1
    l.append('R')
while y>b:
    y-=1
    l.append('D')
while x>a:
    x-=1
    l.append('L')
x-=1
l.append('L')
while y<=d:
    y+=1
    l.append('U')
while x<c:
    x+=1
    l.append('R')
y-=1
l.append('D')
x+=1
l.append('R')
while y>=b:
    y-=1
    l.append('D')
while x>a:
    x-=1
    l.append('L')
y+=1
l.append('U')
print(''.join(l))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
typedef int integer;
#define int long long
#define pb push_back
#define mp make_pair
#define sz(x) (int) x.size()
#define mod 1000000007
using namespace std;


int ar[100000];
int n;


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

    cin >> n;
    map<int, int> M;
    for (int i = 0; i < n; i++){
        cin >> ar[i];
        M[ar[i]]++;
    }
    priority_queue<int> pq;
    for (auto z : M){
        pq.push(z.second);
    }
    while (pq.top() > 1 && sz(pq) > 1){
        int x = pq.top();
        pq.pop();
        int y = pq.top();
        pq.pop();
        x--;
        y--;
        if (x){
            pq.push(x);
        }
        if (y){
            pq.push(y);
        }
    }

    cout << sz(pq) << endl;


}

Measured memory_bytes: 8444
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 200010
ll n,p[N],a[N];
int main(){
    cin>>n;
    lol(i,n){cin>>p[i];a[p[i]-1]=i;}
    ll res=0,cur=1;
    for(ll i=1;i<n;i++){
	if(a[i-1]>a[i])cur=1;
	else cur++;
	res=max(res,cur);
    }
    if(n==1)res=1;
    cout<<n-res<<endl;
    return 0;
}






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

int main()
{
  string S;

  cin >> S;

  int N = S.size();

  string ans = "Yes";

  for (int i = 0; i < N / 2; i++)
  {
    if (S.at(i) != S.at(N - 1 - i))
      ans = "No";
  }

  for (int i = 0; i < (N - 1) / 2; i++)
  {
    if (S.at(i) != S.at((N - 1) / 2 - 1 - i))
      ans = "No";
  }

  for (int i = (N + 3) / 2 - 1; i < N; i++)
  {
    if (S.at(i) != S.at(N - i + N / 2))
      ans = "No";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
R = S.count("R")
G = S.count("G")
B = S.count("B")
countRGB = R * G * B

for i in range(N):
    try:
        for j in range(N):
            if S[i] != S[i + j] and S[i] != S[i + 2 * j] and S[i+j] != S[i + 2 * j]:
                countRGB -= 1
    except:
        pass
print(countRGB)

Measured memory_bytes: 68172
/**** Last Updated 19-June-2020*****/
/*
*
*/
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define sets            set<string> //insert() .top()
#define seti            set<int>
#define pii             pair<int,int>
#define vi              vector<int> //push_back()
#define mii             map<int,int>
#define pqb             priority_queue<int> //insert()
#define pqs             priority_queue<int,vi,greater<int> >
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{
    FIO;
   int a;cin>>a;
   cout<<a+a*a+a*a*a<<endl;
}



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


int main(void) {
  int n, k;
  cin >> n >> k;


  double ans = 0.0;
  for (int i = 1; i <= n; ++i) {
    double temp = 1.0 / n;
    int j = i;
    while (j < k) {
      j *= 2;
      temp *= 0.5;
    }
    ans += temp;
  }

  cout << fixed << setprecision(10);
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;

	cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No");

	return 0;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
ans = ((i < h-1 and s[i+1][j] == '#') or (i > 0 and s[i-1][j] == '#') or (j > 0 and s[i][j-1] == '#') or (j < w-1 and s[i][j+1] == '#') for i in range(h) for j in range(w) if s[i][j] == '#')
if False in ans:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x; cin>>x;
	cout<<((x == 7 || x == 5 || x == 3) ? "YES": "NO");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++){
      int n, a, b;
      cin >> n >> a >> b;
      cout << min(n*a, b)<<endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
t = [0]
x = [0]
y = [0]
for i in range(n):
    tt, xx, yy = map(int, input().split(" "))
    t.append(tt)
    x.append(xx)
    y.append(yy)

ans = "Yes"
for i in range(n):
    dt = t[i+1] - t[i]
    ddis = abs(x[i + 1] + y[i + 1] - (x[i] + y[i]))
    if not (ddis <= dt and ((dt % 2 == 0 and ddis % 2 == 0) or (dt % 2 == 1 and ddis % 2 == 1))):
        ans = "No"
        break

print(ans)

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

int main(){
    int n;
    cin >> n;
    long long int L[87];
    L[0] = 2;
    L[1] = 1;
    int i;
    for(i=2;i<=n;i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[n] << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import fractions
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

#最小公倍数
def union_lcm(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=num*lists[i]//fractions.gcd(num,lists[i])
        return num


#最大公約数
def union_gcd(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=fractions.gcd(num,lists[i])
        return num
mod=10**9+7   
n=int(input())
lists=list(map(int,input().split()))
a=union_lcm(lists)
c=0
a=a%mod

for i in range(n):
    c+=a*modinv(lists[i],mod)
   
print(c%mod)


Measured memory_bytes: 68440
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>


using namespace std;

int main()
{
    string s;
    cin>>s;
    int x=s.size();
    if(x==19&&s[5]==','&&s[13]==',')
    {
        replace( s.begin(), s.end(), ',', ' ');
    }
    cout<<s;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  bool ok = true;
  rep(i,n) {
    if(a[i]%2 == 0){
      if(a[i]%3 == 0 || a[i]%5 == 0){
        continue;
      }
      else{
        ok = false;
      }
    }
  }
  cout << (ok ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let abcd: String = parse_line().unwrap();
    let mut abcd = abcd.chars();
    let a = abcd.next().unwrap().to_digit(10).unwrap() as i32;
    let b = abcd.next().unwrap().to_digit(10).unwrap() as i32;
    let c = abcd.next().unwrap().to_digit(10).unwrap() as i32;
    let d = abcd.next().unwrap().to_digit(10).unwrap() as i32;

    let mut op: Vec<i32> = vec![1, 1, 1];
    'outer: for x in 0..2 {
        let op_b;
        if x == 0 {
            op_b = 1;
        } else {
            op_b = -1;
        }
        for y in 0..2 {
            let op_c;
            if y == 0 {
                op_c = 1;
            } else {
                op_c = -1;
            }
            for z in 0..2 {
                let op_d;
                if z == 0 {
                    op_d = 1;
                } else {
                    op_d = -1;
                }
                if a + b * op_b + c * op_c + d * op_d == 7 {
                    op[0] = op_b;
                    op[1] = op_c;
                    op[2] = op_d;
                    break 'outer;
                }
            }
        }
    }
    let mut op = op.iter().map(|&x| if x == 1 { '+' } else { '-' });
    println!(
        "{}{}{}{}{}{}{}=7",
        a,
        op.next().unwrap(),
        b,
        op.next().unwrap(),
        c,
        op.next().unwrap(),
        d
    );
}


Measured memory_bytes: 2104
/*
  A - 居合を終え、青い絵を覆う / UOIAUAI
  <http://abc049.contest.atcoder.jp/tasks/abc049_a>
  [Tips]
  ・文字列の初期化<http://www.cc.kyoto-su.ac.jp/~yamada/programming/string.html>
*/

#include <stdio.h>
#include <string.h>

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

char c;
char vowels[] = "aiueo";
int len = strlen( vowels );
int i;

scanf("%c", &c);

i = 0;
while( i < len ){
  if( vowels[i] == c ){
    printf("vowel\n");
    return 0;
  }
  i++;
}

printf("consonant");
return 0;
}


Measured memory_bytes: 128
from collections import Counter
 
n = int(input())
s = [list(input()) for _ in range(n)]
for i in range(n):
    s[i].sort()
    s[i] = ''.join(s[i])
counter = Counter(s)
#print(counter)
ans = 0
for val in counter.values():
    #countC2
    ans += val*(val-1)//2
    
print(ans)

Measured memory_bytes: 32136
var print = console.log; // like python
var input_lines; // ?¨??????\????????????????????????????????????

function read_input(_input) {
    input_lines = _input.split("\n");
    return function () {
        return input_lines.shift();
    };
}

function IL(min1Flg) {
    var s = input_lines.shift().split(' ');
    var offset = min1Flg ? -1 : 0;
    var res = [];
    for (var i = 0; i < s.length; i++) {
        res.push(parseInt(s[i]));
    }
    return res;
}

function MAX() {
    var res = arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        res = res > arguments[i] ? res : arguments[i];
    }
    return res;
}

function MIN() {
    var res = arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        res = res < arguments[i] ? res : arguments[i];
    }
    return res;
}


/**
 * @return {number}
 */
Array.prototype.SUM = function SUM() {
    var sum = 0;
    this.forEach(function (elm) {
        sum += elm;
    });
    return sum;
};

/**
 * @return {string}
 */
Array.prototype.Format = function Format(split) {
    if (split === undefined) {
        split = " ";
    }
    return this.join(split);
};

function item_getter_key(x, desc, func_when_eq) {
    var sign = 1;
    if (desc) {
        sign = -1;
    }
    return function (a, b) {
        if (a[x] < b[x]) return -1 * sign;
        else if (a[x] > b[x]) return sign;

        if (func_when_eq === undefined) {
            return 0;
        } else {
            return func_when_eq(a, b);
        }
    };
}

/*

(((???????????)??? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

*/

// input?????\??????????????¨????????\???
function Main(_input) {
    var input = read_input(_input);
    while (1) {
        var MN = IL();
        if (MN[0] === 0) {
            return;
        }
        var fields = [];
        for (var i = 0; i < MN[0]; i++) {
            fields.push(input().split(""));
        }
        var D = {
            ">": [1, 0]
            , "v": [0, 1]
            , "^": [0, -1]
            , "<": [-1, 0]
        };
        var x = 0, y = 0;
        while (fields[y][x] !== ".") {
            if (fields[y][x] === "a") {
                break;
            }
            var d = D[fields[y][x]];
            fields[y][x] = "a";
            x += d[0];
            y += d[1];
        }
        if (fields[y][x] === "a") {
            print("LOOP");
        } else {
            print(x, y);
        }
    }
}

//*???????????\????????¨??????????????§????????????????¨??????\????????????????????????????????????Main????????????????????????
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//Main(require("fs").readFileSync("input.txt", "utf8"));

Measured memory_bytes: 16792
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005

inline void read(int& x)
{
	x=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
}
int n,a[maxn],sum[maxn],c[maxn+maxn];

inline int lowbit(int x)
{
	return x&(-x);
}
inline void modify(int pos)
{
	for(int i=pos;i<=200000;i+=lowbit(i)) ++c[i];
}
inline int query(int pos)
{
	int ans=0;
	for(int i=pos;i;i-=lowbit(i)) ans+=c[i];
	return ans;
}

bool check(int x)
{
	sum[0]=0;
	for(int i=1;i<=n;++i)
		sum[i]=sum[i-1]+(a[i]>=x?1:-1);
	memset(c,0,sizeof(c));
	long long ans=0;
	for(int i=0;i<=n;++i)
	{
		ans+=query(sum[i]+100000);
		modify(sum[i]+100000);
	}
	return (ans<<2)>=1ll*n*(n+1);
}
int main()
{
	int l=0x3f3f3f3f,r=-0x3f3f3f3f,mid;
	read(n);
	for(int i=1;i<=n;++i) read(a[i]),l=min(l,a[i]),r=max(r,a[i]);
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 1792
def prime_factorization(n):
    l = []
    i = 2
    while i * i <= n:
        if n % i == 0:
            n //= i
            l.append(i)
        else:
            i += 1
    if n > 1:
        l.append(n)
    return l


if __name__ == '__main__':
    n = int(input())
    ans = str(n) +  ':'
    ret = prime_factorization(n)
    for e in ret:
        ans += f' {e}'
    print(ans)




Measured memory_bytes: 5608
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A,B,K;
  cin>>A>>B>>K;
  if(B-A<2*K){
    FOR(i,A,B+1)cout<<i<<endl;
  }else{
    FOR(i,A,A+K)cout<<i<<endl;
    FOR(i,B-K+1,B+1)cout<<i<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n, s = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        s += r - l + 1;
    }
    printf("%d", s);
}


Measured memory_bytes: 128
n, k, *aa = map(int, open(0).read().split())

imp = 0
psbl = 10**9

while psbl - imp > 1:
    mid = (psbl + imp) // 2
    cost = sum(0--a//mid - 1 for a in aa)
    if cost <= k:
        psbl = mid
    else:
        imp = mid

print(psbl)

Measured memory_bytes: 109116
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <cstdint>
#include <bitset>
using namespace std;
using i64 = int64_t;

int main(void){
    string s;
    cin >> s;
    i64 sum = 0;
    int n = s.size()-1;
    for(int bit=0; bit<(1<<n); bit++){
        bitset<9> bs(bit);
        int m = 0;
        for(int i=1; i<=n; i++){
            if(bs.test(i-1)){
                string t = s.substr(m, i-m);
                sum += stoll(t);
                m = i;
            }
        }
        string t = s.substr(m);
        sum += stoll(t);
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

/**
 * マージソート
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=ja">ALDS1_5_B</a>
 */
public class Main {

	private static int count = 0;
	private static int l[] = new int[1000000];
	private static int r[] = new int[1000000];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];

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

		Arrays.fill(l, Integer.MAX_VALUE);
		Arrays.fill(r, Integer.MAX_VALUE);

		mergeSort(a, n, 0, n);

		System.out.println(Arrays.toString(a).replace("[", "").replace("]", "").replace(",", ""));
		System.out.println(count);

		sc.close();

	}

	private static void mergeSort(int a[], int n, int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(a, n, left, mid);
			mergeSort(a, n, mid, right);
			merge(a, n, left, mid, right);
		}
	}

	private static void merge(int a[], int n, int left, int mid, int right) {
		for (int i = 0; i < mid - left; i++) l[i] = a[left + i];
		for (int i = 0; i < right - mid; i++) r[i] = a[mid + i];

		l[mid - left] = r[right - mid] = Integer.MAX_VALUE;

		int j = 0, k = 0;
		for (int i = left; i < right; i++) {
			count++;
			if (l[j] <= r[k]) {
				a[i] = l[j++];
			} else {
				a[i] = r[k++];
			}
		}
	}

}



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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[5];
string mark = "MARCH";

int main() {
  // 入力
  int N;
  cin >> N;
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    auto pos = mark.find(s[0]);
    if (pos == string::npos) continue;
    cnt[pos]++;
  }

  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += 1LL * cnt[i] * cnt[j] * cnt[k];
      }
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	char c;
	cin >> c;
	switch (c) {
		case 'A':
			c = 'T';
			break;
		case 'C':
			c = 'G';
			break;
		case 'G':
			c = 'C';
			break;
		case 'T':
			c = 'A';
			break;
	}
	cout << c << endl;
}


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

using namespace std;

// #define LOG(...) fprintf(stderr, __VA_ARGS__)
#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int main() {
  int N, M;
  while(cin >> N >> M, N) {
    vc virus(N);
    vector<pair<int, pii>> log(M);
    REP(i, M){
      cin >> log[i].first >> log[i].second.first >> log[i].second.second;
      log[i].second.first--;
      log[i].second.second--;
    }
    SORT(log);

    LOG("fuga\n");
    virus[0] = true;
    for(auto p : log) {
      LOG("%d -> %d\n", p.second.first, p.second.second);
      virus[p.second.second] |= virus[p.second.first];
    }
    LOG("hogehgoe\n");
    cout << count(ALL(virus), 1) << endl;
  }
}

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

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


Measured memory_bytes: 640
i = 1

while i == 1:
    r = raw_input()
    x, y = r.split()
    x = int(x)
    y = int(y)
    
    if x == 0 and y == 0:
        i = 0
    elif x > y:
        print ("%d %d" %(y, x))
    else:
        print ("%d %d" %(x, y))
    

Measured memory_bytes: 6324
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int WA[100000],AC[100000];
int main(){
  int n,m;
  cin >> m >> n;
  rep(i,n){
   int tmp;string s;
   cin >> tmp >> s;
   if(s == "AC")AC[tmp - 1] = 1;
   else{
    if(AC[tmp - 1])continue;
     else WA[tmp -1]++;
   }
  }
  int ac = 0,wa = 0;
  rep(i,m)ac += AC[i];
  rep(i,m)if(AC[i])wa += WA[i];
  cout << ac << " " << wa << endl;
  return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return 0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

struct mset
{
  vector<mint> fact;  // n! (mod MOD)
  vector<mint> ifact; // k!^{M-2} (mod MOD)
  mset(int n) : fact(n + 1), ifact(n + 1)
  {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint perm(int n, int k)
  { // nPk (mod MOD)
    if (k < 0 || n < k)
      return 0;
    return fact[n] * ifact[n - k];
  }
  mint comb(int n, int k)
  { // nCk (mod MOD)
    if (k < 0 || n < k)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  mset ms(200005);
  mint xres = 0;
  mint yres = 0;
  // x axis
  for (int i = 1; i < m; i++) {
    xres += ((mint)i * (m - i) * n * n);
  }
  xres *= ms.comb(n * m - 2, k - 2);
  // y axis
  for (int i = 1; i < n; i++) {
    yres += ((mint)i * (n - i) * m * m);
  }
  yres *= ms.comb(n * m - 2, k - 2);
  cout << xres + yres << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3328