akhauriyash/Code-Regression huggingface dataset:
if __name__ == "__main__":
    N = int(input())
    if N % 10 == 3:
        print("bon")
    elif N % 10 == 0 or N % 10 == 1 or N % 10 == 6 or N % 10 == 8:
        print("pon")
    else:
        print("hon")

Measured memory_bytes: 9172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var S = Read();
            Println(Regex.Matches(S, "ABC").Count);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

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

int main(){
  int i;
  cin >> i;
  if(i%10 == 2 ||i%10 == 4 ||i%10 == 5 ||i%10 == 7 ||i%10 == 9)
    cout << "hon" << endl;
  else if(i%10 == 3)
    cout << "bon" << endl;
  else
    cout << "pon" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <climits>

int main()
{
	int n;
	int max, argmax;
	int a, v;
	
	std::cin >> n;
	std::cin >> a >> v;
	argmax = a; max = v;
	for (int i=1; i<n; i++) {
		std::cin >> a >> v;
		if (v > max) {
			max = v;
			argmax = a;
		} else if ( v == max && a < argmax ) {
			argmax = a;
		}
	}
	
	std::cout << argmax << " " << max << std::endl;
	
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int a[10][10];
int main(){
    int n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int t = 0;
            for(int k = 0; k < d; k++){
                t += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
            }
            int k = (int) sqrt(t) * sqrt(t);
            if(k == t){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
upper = list(map(int, input().split()))
lower = list(map(int, input().split()))



ret = 0
cumsum_u = []
for i in range(len(upper)):
    ret += upper[i]
    cumsum_u += [ret]



ret = 0
cumsum_l =  []
for i in range(len(lower)):
    ret += lower[len(lower) - i - 1]
    cumsum_l = [ret] + cumsum_l



ans = 0
for i in range(len(lower)):
    ans = max(ans, cumsum_u[i] + cumsum_l[i])


print(ans)

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

int main(void){
  string s;
  string c = "CODEFESTIVAL2016";

  int count = 0;

  cin >> s;

  for(int i = 0; i < s.size(); i ++)
    if(s.at(i) != c.at(i)) count ++;

  cout << count << endl;

  return 0;
}
	

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

S=input()

A = [0]
a=0
for i in range(N):
    if S[i]=="#":
        a+=1
    A.append(a)
min_score=N

for i in range(N+1):
    min_score=min((N-i-(A[N]-A[i]))+A[i],min_score)
print(min_score)

Measured memory_bytes: 11140
from collections import deque
n, m = map(int, input().split(" "))
load = {i:[] for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split(" "))
    load[a].append(b)
    load[b].append(a)

queue = deque([1])
visited = {1: 1}

while len(queue) != 0:
    curr = queue.popleft()
    for _next in load[curr]:
        if visited.get(_next, -1) == -1:
            visited[_next] = curr
            queue.append(_next)

if len(visited) == n:
    print("Yes")
    for i in range(2, n+1):
        print(visited[i])
else:
    print("No")

Measured memory_bytes: 50796
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,num=0,ans=0,mi=1e9;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<0){
            num++;
        }
        ans+=abs(a[i]);
        mi=min(mi,abs(a[i]));
    }
    if(num%2==0){
        cout << ans<<endl;
    }
    else{
        cout << ans-2*mi<<endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let s: Vec<usize> = i::s()
        .iter()
        .map(|&c| c as i32 - '0' as i32)
        .map(|i| i as usize)
        .collect();
    let mut left = vec![n; 10];
    let mut right = vec![0; 10];

    for i in 0..n {
        left[s[i]] = min(left[s[i]], i);
        right[s[n - i - 1]] = max(right[s[n - i - 1]], n - i - 1);
    }

    //dbg!(&left, &right);

    let mut set = HashSet::new();

    for i in 1..(n - 1) {
        let k = s[i];
        for l_i in 0..10 {
            let l = left[l_i];
            for r_i in 0..10 {
                let r = right[r_i];
                //println!("{} {} {}", l, k, r);
                if l < i && i < r {
                    let s = l_i * 100 + k * 10 + r_i;
                    // println!("{}", s);
                    set.insert(s);
                }
            }
        }
    }
    println!("{}", set.len());
    //  dbg!(set);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int K;
	cin >> K;
	
	ll cur = 7;
	int ans = 1;
	vector<int> done(K + 1);
	while (cur % K != 0) {
		if (done[cur]) {
			puts("-1");
			return 0;
		}
		done[cur] = true;
		cur = (cur * 10 + 7) % K;
		++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		call(N);
		sc.close();
	}

	public static void call(int n) {
		int i = 1;
		while(i <= n) {
			if(i % 3 == 0) {  // 3の倍数かどうか
				System.out.print(" " + i);
			}else {  // 3を含む数かどうか（例：13, 31, 322）
				int x = i;
				while(x > 0) {
					if(x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				}
			}
			i++;
		}
		System.out.println();
	}
}


Measured memory_bytes: 28648
num = int(input())
h = 0
t = 0
for n in range(num):
    str_list = input().split(" ")
    str0 = str_list[0]
    str1 = str_list[1]
    str_list.sort()
    if str1 == str0:
        h += 1
        t += 1
        continue
    else:
        if str0 == str_list[0]:
            t += 3
            continue
        elif str0 == str_list[1]:
            h += 3
            continue
print(str(h) + " " + str(t))


Measured memory_bytes: 5592
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int ans = 0;
        if(N < 600) {
            ans = 8;
        }else if(N < 800) {
            ans = 7;
        }else if(N < 1000) {
            ans = 6;
        }else if(N < 1200) {
            ans = 5;
        }else if(N < 1400) {
            ans = 4;
        }else if(N < 1600) {
            ans = 3;
        }else if(N < 1800) {
            ans = 2;
        }else if(N < 2000) {
            ans = 1;
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 35752
#include<stdio.h>
int main()
{
	double r,Pi, a, b;
	scanf("%lf", &r);
	Pi = 3.141592653589;

	a = Pi*r*r;
	b = 2 * Pi*r;
	printf("%f %f\n", a, b);
	
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define INF INT_MAX
#define INFLL _I64_MAX
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
//エラトステネスのふるい(1からnまでの数字の間に何個素数があるのかを数え上げる)
void Eratosthenes(bool f[100001], int c[100001])
{
	rep(i, 100001) f[i]=false;

	f[0]=true; f[1]=true;

	repr(i, 2, 100001){
		if(!f[i]){
			for(int j=i+i; j<=100000; j+=i){
				f[j]=true;
			}
		}
	}
	for(int i=3; i<=100000; i+=2) if(!f[i]&&!f[(i+1)/2]) c[i]++; //iと(i+1)/2がいずれも素数なら1
	for(int i=3; i<=100000; i++) c[i]+=c[i-1]; //累積和
}

int main(void)
{
	int q, l, r, c[100001]={};

	bool f[100001];

	cin>>q;

	Eratosthenes(f, c);

	rep(i, q){
		cin>>l>>r;
		int ans=c[r]-c[l];
		if(!f[l]&&!f[(l+1)/2]) ans++;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1152
n = int(input())
s = input()

mod = 10**20 + 7
base = 12345

def ok(l):
    array = {}
    rolling_hash = 0
    for i in range(n):
        rolling_hash *= base
        rolling_hash += ord(s[i])
        if i - l >= 0:
            rolling_hash -= ord(s[i-l]) * pow(base, l, mod)
        rolling_hash %= mod
        if i >= l-1:
            if rolling_hash in array.keys():
                array[rolling_hash].append(i)
            else:
                array[rolling_hash] = [i]
    for check in array.values():
        if max(check) - min(check) >= l:
            return True
    return False

top = n
bottom = 0

while top - bottom > 1:
    mid = (top + bottom)//2
    if ok(mid):
        bottom = mid
    else:
        top = mid
print(bottom)


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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m;
    a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2, HELL)
#define size(a) (int) a.size()

int n;
const int maxN = 2e5 + 5;
int arr[maxN];
getMat(dp, maxN, 4, INF);

int res(int index = 0, int miss = 0) {
	if (index >= n) {
		return 0;
	}
	if (dp[index][miss] != INF) {
		return dp[index][miss];
	}
	int val;
	if (n % 2 == 0) {
		if (miss == 1) {
			val = res(index + 2, miss) + arr[index];
		} else {
			val = max(res(index + 1, miss + 1), res(index + 2, miss) + arr[index]);
		}
	} else {
		if (miss == 2) {
			val = res(index + 2, miss) + arr[index];
		} else {
			val = max(res(index + 1, miss + 1), res(index + 2, miss) + arr[index]);
		}
	}
	dp[index][miss] = val;
	return val; 
}

int32_t main() { fastio;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	cout << res() << endl;
    return 0;
}


Measured memory_bytes: 23528
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;

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

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 100000

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int dp[2][64][4096];
int N, M, S;

int main(){
  while(cin >> N >> M >> S){;
    if(!N && !M && !S) break;
    memset(dp, 0, sizeof(dp));
    int res = 0;
    int cur, tar;
    dp[0][0][0]=1;
    REP(i, 1, M+1){
      cur = (i+1)%2;
      tar = (cur+1)%2;
      memset(dp[tar], 0, sizeof(dp[tar]));
      rep(j,SQ(N)){
	rep(k, S){
	  if(k+i <= S) dp[tar][j+1][k+i] = (dp[tar][j+1][k+i] + dp[cur][j][k])%MOD;
	  dp[tar][j][k] = (dp[tar][j][k] + dp[cur][j][k])%MOD;
	}
      }
      /*      rep(i, SQ(N)+1){
	rep(j, S+1) cout << dp[tar][i][j] << " ";
	cout << endl;
	}cout<<endl;*/
      res = (res+dp[tar][SQ(N)][S])%MOD;
    }
    //    int res = 0;
    
    //    REP(i,1, M+1) res = (res+dp[tar][i][S])%MOD;
    //    cout << res << endl;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

int main(void) {
    int h;
    while (cin >> h) {
        if (h == 0) {
            break; 
        }
        VII table(h, VI(5));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> table[i][j];
            }
        }

        int score = 0;
        while (1) {
            bool change = false;
            for (int i = 0; i < h; i++) {
                int j = 0;
                while (j < 3) {
                    int k;
                    for (k = j + 1; k < 5; k++) {
                        if (table[i][k] != table[i][j]) {
                            break;
                        }
                    }
                    if (k - j > 2 && table[i][j] != 0) {
                        score += (k - j) * table[i][j];
                        for (int l = j; l < k; l++) {
                            table[i][l] = 0;  
                        }
                        change = true;
                    }
                    j = k;
                }
            }

            if (! change) {
                break;
            }
            for (int i = h - 1; i > 0; i--) {
                for (int j = 0; j < 5; j++) {
                    if (table[i][j] == 0) {
                        for (int k = i - 1; k >= 0; k--) {
                            if (table[k][j] != 0) {
                                table[i][j] = table[k][j];
                                table[k][j] = 0;
                                break;
                            }
                        }
                    }
                }
            }

        }
        cout << score << endl;
    }
    return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static int64_t kRem = 1000000007;

int coins[501][501] = { 0 };

struct Point {
	int x;
	int y;
};

void process(vector<pair<Point, Point>>& path, vector<Point>& cur, bool& is_moving, int x, int y)
{
	if (!is_moving && (coins[x][y] & 1) == 0) return;

	cur.push_back({ x, y });
	if ((coins[x][y] & 1) == 0) return;

	if (is_moving) {
		FOR_LT(i, 0, cur.size() - 1) {
			path.push_back(make_pair(cur[i], cur[i + 1]));
		}
		cur.clear();
	}

	is_moving = !is_moving;
}

int main()
{
	int h, w; cin >> h >> w;

	FOR_LT(y, 0, h) {
		FOR_LT(x, 0, w) {
			int a; cin >> a;
			coins[x + 1][y + 1] = a;
		}
	}

	vector<pair<Point, Point>> path;
	vector<Point> cur;

	bool is_moving = false;
	FOR_LE(y, 1, h) {
		if (y & 1) {
			FOR_LE(x, 1, w) {
				process(path, cur, is_moving, x, y);
			}
		}
		else {
			FOR_DW(x, w, 1) {
				process(path, cur, is_moving, x, y);
			}
		}

	}

	cout << path.size() << endl;
	for (auto& elem : path) {
		cout << elem.first.y << " " << elem.first.x << " " << elem.second.y << " " << elem.second.x << endl;
	}

	return 0;
}


Measured memory_bytes: 5104
N,S=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
dp=[[0]*(S+1) for _ in range(N+1)]
dp[0][0]=1

for i in range(1,N+1):
  for j in range(S+1):
    dp[i][j]+=dp[i-1][j]*2
    if j-A[i-1]>=0:
      dp[i][j]+=dp[i-1][j-A[i-1]]
    dp[i][j]%=mod
print(dp[N][S])
    


Measured memory_bytes: 132648
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin >> s;
    
    int count[] = {0, 0};
    char a[] = {'0', '1'};
    
    for (size_t i = 0; i < s.size(); i++) {
        if (s[i] == a[i%2]) {
            count[0]++;
        } else {
            count[1]++;
        }
    }
    std::cout << min(count[0], count[1]) << std::endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
int N = 20, M = 0;
LL L;
int a[1123];
int b[1123];
LL c[1123];
int main() {
	LL x = 1;
	for (int i = N - 1; i >= 2;i--) {
		a[M] = i;
		b[M] = i + 1;
		c[M] = 0;
		M++;
		a[M] = i;
		b[M] = i + 1;
		c[M] = x;
		M++;
		x <<= 1;
	}
	cin >> L;
	if ((L >> 19) & 1) {
		a[M] = 1;
		b[M] = 2;
		c[M] = 0;
		M++;
		a[M] = 1;
		b[M] = 2;
		c[M] = 1<<18;
		M++;
	}
	for (int i = 0; i <= 18; i++) {
		if ((L >> i) & 1) {
			a[M] = 1;
			b[M] = 20 - i;
			c[M] = (L >> (i + 1)) << (i + 1);
			M++;
		}
	}
	cout << N << " " << M << endl;
	for (int i : range(M)) {
		cout << a[i] << " " << b[i] << " " << c[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int di[] = {0,1,0,-1};
int dj[] = {1,0,-1,0};
int main() {

  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  
  int ans = 0;
  rep(i,h)rep(j,w) {
    queue<P> q;
    vector<vector<int>> d(h,vector<int>(w,100000));
    
    auto push = [&](int x, int y, int val) {
      if (x<0||h<=x||y<0||w<=y||d[x][y]!=100000||s[x][y]!='.') {
        return;
      }
      q.emplace(x,y);
      d[x][y] = val;
      ans = max(ans,val);
    };

    push(i,j,0);
    while ( !q.empty() ) {
      P p = q.front();
      int x = p.first, y = p.second;
      q.pop();
      rep(dir,4) push(x+di[dir],y+dj[dir],d[x][y]+1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int n, a[100100];
ll b[100100], c = 0, d;

main(){
    b[0]=1;
    scanf("%d", &n);
    for(int i=0; i<=n; i++){
      /*
        if(b[i]>1000000000000000){
            puts("-1");
            return 0;
        }
      */
        scanf("%d", &a[i]);
        if(a[i] <= b[i]){
            b[i+1] = min(2*(b[i]-a[i]), 100000000000000000);
        }else {
            puts("-1");
            return 0;
        }
    }if(b[n]<(a[n]+1)/2){
        puts("-1");
        return 0;
    }
    ll x = a[n],y=a[n];
    for(int i=n-1; i>=0; i--){
        y=a[i] + min(y, b[i]-a[i]);
        x += y;
    }
    printf("%lld", x);
    return 0;
}

Measured memory_bytes: 2828
import java.util.*;
import java.io.*;
public class Main {
	static final int NONUM=-1;
	
	public static void main(String[] args)throws IOException{
		final Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		NODE[] n = new NODE[a];
		
		for(int i=0;i<n.length;i++){
			int id=sc.nextInt();
			n[id]=new NODE();
			n[id].id=id;
			n[id].k=sc.nextInt();
			n[id].p=NONUM;
			n[id].t="leaf";
			if(n[id].k>0){
				n[id].c=new int[n[id].k];
				for(int j=0;j<n[id].k;j++){
					n[id].c[j]=sc.nextInt();
				}
				n[id].t="internal node";
			}
		}
		
	     for(int i=0; i<a; i++){
	    	 for(int k=0; k<n[i].k; k++){
	    		 n[n[i].c[k]].p = n[i].id;
	         }
	     }
		
		for(int i=0;i<a;i++){
			if(n[i].p==NONUM){
				n[i].t="root";
				for(int j=0;j<n[i].k;j++){
				getdepth(n,n[i].c[j],1);
				}
			}
		}
		
		for(int i=0;i<a;i++){
			System.out.print("node "+n[i].id+": parent = "+n[i].p+ ", depth = "+n[i].d+", "+n[i].t+", [");
			for(int j=0;j<n[i].k;j++){
				if(j==0) System.out.print(n[i].c[j]);
				else System.out.print(", "+n[i].c[j]);
			}
			System.out.println("]");
		}
	}
	
	static void getdepth(NODE[] n,int i,int d){

		n[i].d=d;
		d++;
		for(int j=0;j<n[i].k;j++){
			getdepth(n,n[i].c[j],d);
		}
	}		
}

class NODE{
	int id;
	int k;
	int[] c;
	int p;
	int d;
	String t; 
}

Measured memory_bytes: 138360
#include<stdio.h>

int main(void)

{

 long long int a[10000],min=1000000,max=-1000000,sum=0;

 int n,i;

 scanf("%d",&n);

 for(i=0;i<n;i++){

    scanf("%lld",&a[i]);

    if(a[i]>=max){

       max=a[i];

     }

     if(a[i]<=min){

        min=a[i];

     }

     sum+=a[i];

   }

   printf("%lld %lld %lld\n",min,max,sum);

   return 0;

}

Measured memory_bytes: 2740
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <vector>
#include <string>
#include <limits.h>
#include <set>
#define ll long 
#define lli long long
# define M_PI           3.14159265358979323846
using namespace std;


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

    ll N;
    cin>>N;
    int M;
    cin>>M;
    ll sum = 0;
    ll num;
    int i;
    for(i=0; i<M; i++)
    {
    	cin>>num;
    	sum = sum+num;
    }

    if(sum>N)
    	cout<<"-1";
    else
    	cout<<(N-sum);
    return 0;
}


Measured memory_bytes: 3664
/*
 * D.cpp
 *
 *  Created on: 2020/07/25
 *      Author: 17k1028
 */



#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define REPD(i,n) for(ll i=n-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=a; i<=ll(b); i++)
#define FORD(i,a,b) for(ll i=a; i>=ll(b); i--)

int main(){
	ll N;
	cin >> N;
	ll A[N];
	REP(i,N) cin >> A[i];
	ll backet=1000, have=0;
	REP(i,N){
		if(i==N-1){
			backet += have*A[i];
		}else{
			if(A[i]<A[i+1]){
				ll temp = backet/A[i];
				backet -= temp*A[i];
				have += temp;
			}else{
				backet += have*A[i];
				have = 0;
			}
		}
	}
	cout << backet << endl;
}





Measured memory_bytes: 3628
#include<stdio.h>

int S[100000];

int binaryserch(int q,int n) {
    int high, low,mid;
    high = n - 1;
    low = 0;
    while (high >= low) {
        mid = (high + low) / 2;
        if (S[mid] == q) {
            return 1;
        }
        else if (S[mid] > q) {
            high = mid - 1;
        }
        else {
            low = mid + 1;
        }
    }
    return 0;
}


int main(void) {
    int i, j, q, n;
    int T[50000];
    int count = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &T[i]);
    }

    for (i = 0; i < q; i++) {
        count += binaryserch(T[i], n);
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 1184
xy = list(map(int,input().split() ))
vx12 = xy[2] - xy[0]
vy12 = xy[3] - xy[1]
vx3 = (-1)*vy12
vy3 = vx12
vx4 = (-1)*vy3
vy4 = vx3
print(xy[2]+vx3,xy[3]+vy3,xy[2]+vx3+vx4,xy[3]+vy3+vy4)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <cstring>
using namespace std;

int main(){
	string str,buf;
	stack<long long int> memory;
	long long int a,b;
	getline(cin,str);
	stringstream ss(str);
	while(ss >> buf){
		a = atoi(buf.c_str());
		if(buf == "+"){
			a = memory.top();
			memory.pop();
			b = memory.top();
			memory.pop();
			memory.push(a+b);
		}
		else if(buf == "-"){
			a = memory.top();
			memory.pop();
			b = memory.top();
			memory.pop();
			memory.push(b-a);
		}
		else if(buf == "*"){
			a = memory.top();
			memory.pop();
			b = memory.top();
			memory.pop();
			memory.push(a*b);
		}
		else if(buf == "/"){
			a = memory.top();
			memory.pop();
			b = memory.top();
			memory.pop();
			memory.push(b/a);
		}
		else memory.push(a);
	}
	cout << memory.top() << endl;
	return 0;
}

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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < 2; i++) {
        int diff = c[i + 1][0] - c[i][0];
        for (int j = 1; j <= 2; j++) {
            if (c[i + 1][j] - c[i][j] != diff) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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


int heap[MAX];
int size;


int left(int i){
  return 2*i;
}


int right(int i){
  return 2*i+1;
}


int parent(int i){
  return i/2;
}


void maxHeapify(int i){
  int l, r, x, largest;
  
  l = left(i);
  r = right(i);
  
  if( l <= size && heap[l] > heap[i] ){
    largest = l;
  }
  else{ 
    largest = i;
  }
  
  if( r <= size && heap[r] > heap[largest] ){
    largest = r;
  }
  
  if( largest != i ){
    x = heap[i];
    heap[i] = heap[largest];
    heap[largest] = x;
    
    maxHeapify(largest);
  }
  
}


int extractMax(void){
  int max;
  
  max = heap[1];
  heap[1] = heap[size];
  size = size - 1;
  
  maxHeapify(1);
  
  return max;

}


void increaseKey(int i, int key){
  int x;

    heap[i] = key;
    
    while( i > 1 && heap[parent(i)] < heap[i] ){
      x = heap[i];
      heap[i] = heap[parent(i)];
      heap[parent(i)] = x;
      i = parent(i);
    }
    
}


void maxHeapInsert(int key){
  
  size = size + 1;
  heap[size] = -1;
  increaseKey(size, key);
  
}



main(){
  int i, key, max;
  char command[10];  

  while(1){
  
    scanf("%s", command);

    if( strcmp("end", command) == 0 ) break;
    
    else if( strcmp("extract", command) == 0 ){
      max = extractMax();
      printf("%d\n", max);
    }

    else if( strcmp("insert", command) == 0 ){
      scanf("%d", &key);
      maxHeapInsert(key);
    }

    else continue;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 4696
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void xyz(int a[], int n)
{
	if(a[n] == 0)
	{
		a[n]++;
	}
	else
	{
		a[n] = 0;
		xyz(a,n + 1);
	}
}

int main()
{
	int n;
	cin >> n;
	
	vector< vector<int> > f;
	f = vector< vector<int> >(n, vector<int>(10));
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 10; j++)
		{
			cin >> f[i][j];
		}
	}
	
	vector< vector<int> > p;
	p = vector< vector<int> >(n, vector<int>(11));
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 11; j++)
		{
			cin >> p[i][j];
		}
	}
	
	int che[10] = {0};
	int ans = 0;
	int cnt = 0;
	while(cnt != 1023)
	{
		cnt++;
		xyz(che, 0);
		int sum[n] = {0};
		
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < 10; j++)
			{
				if(che[j] == 1)
				{
					sum[i] += f[i][j];
				}
			}
		}
		
		int profit = 0;
		for(int i = 0; i < n; i++)
		{
			profit += p[i][sum[i]];
		}
		
		if(cnt == 1)
		{
			ans = profit;
		}
		
		if(ans < profit)
		{
			ans = profit;
		}
	}
	
	cout << ans << endl;
	return 0;
}	

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

int main(){
	LL n;
	cin>>n;
	LL res = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				res+=__gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<res;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> a;
    for (int i = 1; i < N + 1; i++)
    {
        string S;
        int P;
        cin >> S >> P;
        P = -P; // sortは昇順なので、降順にするために-1かける
        a.push_back(make_pair(make_pair(S, P), i));
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < N; i++)
    {
        cout << a[i].second << endl;
    }
    return 0;
}

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

#define x first
#define y second
#define int64 long long
#define debug(x) cerr << #x << " is " << x << endl;
#define MaxN 100000

int64 res;
pair<int, pair<int, int>> v[MaxN+1];
pair<int, pair<int, int>> u[MaxN+1];
pair<int, int> a[MaxN+1];
int chosen[MaxN+1];
int N;

void Compute()
{
    int i, j, idx, pos = 0;
    int64 temp = 0;

    sort(v + 1, v + N + 1);
    sort(u + 1, u + N + 1);
    for(i = 1; i <= N; ++i) chosen[i] = 0;
    for(j = 1, i = N; i >= 1; --i)
    {
        idx = v[i].y.y;
        if(chosen[idx]) continue;

        chosen[idx] = 1;
        if(pos < v[i].x){
            temp = temp + v[i].x - pos;
            pos = v[i].x;
        }

        else if(pos > v[i].y.x){
            temp = temp + pos - v[i].y.x;
            pos = v[i].y.x;
        }

        while(chosen[ u[j].y.y ] && j <= N) ++j;
        if(j > N) continue;
        idx = u[j].y.y;
        chosen[idx] = 1;

        if(pos > u[j].x){
            temp = temp + pos - u[j].x;
            pos = u[j].x;
        }

        else if(pos < u[j].y.x){
            temp = temp + u[j].y.x - pos;
            pos = u[j].y.x;
        }
    }

    temp = temp + abs(pos);
    res = max(res, temp);
}

int main(){



    int i, x, y;

    scanf("%d", &N);
    for(i = 1; i <= N; ++i)
    {
        scanf("%d %d", &x, &y);
        v[i] = {x, {y, i}};
        u[i] = {y, {x, i}};
        a[i] = {x, y};
    }

    Compute();
    for(i = 1; i <= N; ++i) a[i] = {-a[i].y, -a[i].x};
    for(i = 1; i <= N; ++i){
        v[i] = {a[i].x, {a[i].y, i}};
        u[i] = {a[i].y, {a[i].x, i}};
    }

    Compute();
    printf("%lld\n", res);


return 0;
}


Measured memory_bytes: 3712
N = int(input())
A = list(map(int,input().split()))

ans = 1

#state0は未定、1は広義単調増加、2は広義単調減少
state = 0
m = A[0]

i = 1
while i <= N-1:
    if m < A[i]:
        if state == 0:
            state = 1
            m = A[i]
        elif state == 1:
            m = A[i]
        else:
            ans += 1
            state = 0
            m = A[i]
    elif m > A[i]:
        if state == 0:
            state = 2
            m = A[i]
        elif state == 1:
            ans += 1
            state = 0
            m = A[i]
        else:
            m = A[i]
    i += 1
print(ans)


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

const Int MOD = 1e9+7;
vector<Int> f(200010);

//---------- べき乗 ----------
Int power(Int a, Int n){
    if(a == 0) return 0;
    if(n == 0) return 1;
    
    Int res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD; n /= 2;
    }
    return res;
}

//---------- 逆元 ----------
Int inv(Int a){
    return power(a, MOD-2);
}

//---------- 階乗 ----------
void factorial(){
    f[0] = 1;
    for(int i=1; i<=200010; i++) f[i] = i * f[i-1] % MOD;
}

//--------- 組み合わせ ---------
Int comb(Int n, Int r){
    return (f[n] * inv(f[r]) % MOD) * inv(f[n-r]) % MOD;
}
 
int main(){
    Int N, K; cin >> N >> K;

    factorial();

    Int ans = 0;
    rep(i, min(K+1,N)){
        ans = (ans + comb(N,i)*comb(N-1,N-i-1)%MOD) % MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const int N = 1e5 + 18;


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        //for (int tt = 1; tt <= t; tt++) {
        int n, m, r;
        cin >> n >> m >> r;
        if (m * r >= n)
            cout << "Yes";
        else
            cout << "No";
    }
    return 0;

}




Measured memory_bytes: 3652
import math
n,d=input().split(' ')
n=int(n)
d=int(d)
count=0

for i in range(0,n):
    x,y=input().split(' ')
    x=int(x)
    y=int(y)
    dist=math.sqrt((x*x)+(y*y))
    if(dist<=d):
        count+=1
print(count)

Measured memory_bytes: 9080
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    List<Character> list1 = new ArrayList<>();

    int a = sc.nextInt();
    int b = sc.nextInt();
    
    System.out.println(lcm(a, b));

    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }


}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  int n,t,e;
  cin>>n>>t>>e;
  REP(i,n) {
    int x;
    cin >> x;
    for (int j=t-e; j<=t+e; ++j) {
      if (j%x==0) {
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int n,W,wt[101],v[101];
long long dp[101][100002];
int main()
{
    scanf("%d %d",&n,&W);
    int sum(0);
    for(int i=1;i<=n;i++){
        scanf("%d %d",&wt[i],&v[i]);
        sum+=v[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=sum;j++){
            dp[i][j]=1e18+100;
        }
    }
    for(int i=0;i<=n;i++){
        dp[i][0]=0;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=sum;j++){
            if(v[i]<=j){
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+wt[i]);
            }
            dp[i][j]=min(dp[i][j],dp[i-1][j]);

        }
    }
    int ans=0;
    for(int i = 0; i<=sum ;i++){
        if(dp[n][i]<=W)ans=i;
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 79104
R,C,A,B = map(int,input().split())
if (A+B)*2 > R*C:
    print('NO')
    exit()

ans = [['.' for j in range(C)] for i in range(R)]

if R%2:
    for i in range(C//2):
        if A == 0: break
        ans[-1][i*2] = '<'
        ans[-1][i*2+1] = '>'
        A -= 1
if C%2:
    for i in range(R//2):
        if B == 0: break
        ans[i*2][-1] = '^'
        ans[i*2+1][-1] = 'v'
        B -= 1

for i in range(R//2):
    for j in range(C//2):
        if A > 1:
            for k in range(2):
                ans[i*2+k][j*2] = '<'
                ans[i*2+k][j*2+1] = '>'
                A -= 1
        elif B > 1:
            for k in range(2):
                ans[i*2][j*2+k] = '^'
                ans[i*2+1][j*2+k] = 'v'
                B -= 1
        elif A == 1:
            ans[i*2][j*2] = '<'
            ans[i*2][j*2+1] = '>'
            A -= 1
        elif B == 1:
            ans[i*2][j*2] = '^'
            ans[i*2+1][j*2] = 'v'
            B -= 1

if R%2 and C%2 and B and ans[-2][-3] == '.':
    if ans[-1][-3] == '<':
        ans[-1][-2] = '<'
        ans[-1][-1] = '>'
    ans[-2][-3] = '^'
    ans[-1][-3] = 'v'
    B -= 1

if A > 0 or B > 0:
    print('NO')
else:
    print('YES')
    print(*[''.join(row) for row in ans], sep='\n')


Measured memory_bytes: 13940
#include<iostream>
#include <string>
#include <utility>
using namespace std;

int main(){
while(1){
int n = 0;
cin >> n;
if(n == 0){break;}
int sum = 1;
int a[7];
for(int i = 0;i <= 6;i++){
a[i] = i + 1;
}
for (int i = 1;i <= n;i++){
string c;string N = "North";string E = "East";string S  = "South";string W = "West";
string R = "Right";string L = "Left";
cin >> c;
if(c == N){
a[6] = a[0];a[0] = a[1];a[1] = a[5];a[5] = a[4];a[4] = a[6];
}
if(c == S){
a[6] = a[0];a[0] = a[4];a[4] = a[5];a[5] = a[1];a[1] = a[6];
}
if(c == E){
a[6] = a[0];a[0] = a[3];a[3] = a[5];a[5] = a[2];a[2] = a[6];
}
if(c == W){
a[6] = a[0];a[0] = a[2];a[2] = a[5];a[5] = a[3];a[3] = a[6];
}
if(c == R){
a[6] = a[1];a[1] = a[2];a[2] = a[4];a[4] = a[3];a[3] = a[6];
}
if(c == L){
a[6] = a[1];a[1] = a[3];a[3] = a[4];a[4] =a[2];a[2] = a[6];
}
sum = sum + a[0];
}
cout << sum << endl;
}
    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000000

int main(){

    int n, Y; cin >> n >> Y;
    int x, y, z;
    for(x = 0; x <= n; x++){
        for(y = 0; x + y <= n; y++){
            z = n - x - y;
            //cout << x << " " << y << " " << z << endl;
            if(10000*x + 5000*y + 1000*z == Y){
                cout << x << " " << y << " " <<  z << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void append(int t, int n, int table[]) {
    table[t] = 1;
    for (int i=0; i<=n-t; i++) {
        if (table[i] < 0) {
            continue;
        }
        if (table[i+t] < 0) {
            table[i+t] = table[i]+1;
        }
        else {
            table[i+t] = min(table[i]+1, table[i+t]);
        }
    }
}

int main() {
    int n;
    int dp[1000000];
    int dp_odd[1000000];
    for (int i=0; i<1000000; i++) {
        dp[i] = -1;
        dp_odd[i] = -1;
    }
    for (int i=0; true; i++) {
        int t = i*(i+1)*(i+2)/6;
        if (t > 1000000) {
            break;
        }
        append(t, 1000000, dp);
        if (t%2 == 1) {
            append(t, 1000000, dp_odd);
        }
    }
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        cout << dp[n] << ' ' << dp_odd[n] << endl;
    }
}

Measured memory_bytes: 8972
k = int(input())

num = [1,2,3,4,5,6,7,8,9]
def lunlun(m):
    for i in range(10):
        if(abs((m%10) - i ) <=1):
            if(m*10+i > 3234566667):
                return
            num.append(m*10+i)
            lunlun(m*10+i)

for j in range(1,10):
    lunlun(j)

num = sorted(num)

print(num[k-1])

Measured memory_bytes: 8496
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
a = t.count("s")
b = t.count("p")
c = t.count("r")
t = list(t)
for i in range(n-k):
    if t[i] == t[i + k]:
        if t[i] == "s":
            a -= 1
            t[i+k] = "x"
        elif t[i] == "p":
            b -= 1
            t[i+k] = "x"
        else:
            c -= 1
            t[i+k] = "x"
print(a*r+b*s+c*p)


Measured memory_bytes: 4084
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

// c[i][j] : 1<=k<=N なる k のうち, 先頭が i で 末尾が j であるものの個数
int c[10][10];

void solve()
{
    int N;
    cin >> N;

    REP1 (i, N)
    {
        int x = i;
        while (x > 9) x /= 10;
        c[x][i % 10]++;
    }

    LL ans = 0;

    REP0 (i, 10)
    {
        REP0 (j, 10)
        {
            ans += c[i][j] * c[j][i];
        }
    }

    cout << ans << endl;
    ;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#include <cstdlib>
#include <map>
#include <algorithm>
#include <queue>

#include <iostream>
#include <sstream>
#include <cstdio>
#include <set>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  while(true){
    map<string, int> m;
    string str, s;

    getline(cin, str);
    const int n = atoi(str.c_str());
    if(n == 0) break;

    REP(i,n){

      getline(cin, str);
      stringstream ss(str);

      while(ss >> s){
        m[s]++;
      }
    }

    string c; getline(cin, c);

    vector<pair<int, string> > ans;

    FOR(it, m){
      if(it->first[0] == c[0]){
        ans.push_back(make_pair(-it->second, it->first));
      }
    }

    sort(ans.begin(), ans.end());

    REP(i,min(5, (int)ans.size())){
      if(i != 0) cout << " ";
      cout << ans[i].second;
    }

    if(ans.size() == 0) cout << "NA";
    cout << endl;
  }

  return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n+1);
    rep(i,n) cin >> h[i];
    vector<vector<int>> g(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    rep(i,n){
        bool ok = true;
        for(auto x : g[i]){
            if(h[x]<h[i]) ok = true;
            else{ ok = false; break;}
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8768