akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce


N = a_int()
L = ints()
L.sort()
cnt = 0
for i, j, k in combinations(ra(N), r=3):
    if L[k] < L[j] + L[i] and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
        cnt += 1
print(cnt)


Measured memory_bytes: 74392
import java.util.Scanner;

public class Main {

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

		long sum = 0;
		int[] s = new int[n];
		for( int i=1 ; i<n ; i++ ) {
			s[sc.nextInt()-1]++;
		}
		
		for( int i=0 ; i<n ; i++ ) {
			System.out.println(s[i]);
		}
		
	}
		
	static int gcd(int... array) {
		int gcd = 0;
		for(int i = 0; i < array.length; i ++) { gcd = gcd(gcd, array[i]); }
		return gcd;
	}
	
	static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

}


Measured memory_bytes: 56008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int main(){
    int A,B,M;
    int Amn = INF;
    int Bmn = INF;
    int ans = 0;
    int sum1 = INF;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    vector<int> x(M);
    vector<int> y(M);
    vector<int> c(M);
    vector<int> sum(M);
    for(int i = 0;i < A;i++){
        cin >> a.at(i);
        Amn = min(Amn,a.at(i));
    }
    for(int i = 0;i < B;i++){
        cin >> b.at(i);
        Bmn = min(Bmn,b.at(i));
    }   
    for(int i = 0;i < M;i++){
        cin >> x.at(i) >> y.at(i) >> c.at(i);
    }
    ans = Amn + Bmn;
    for(int i = 0;i < M;i++){
        sum.at(i) = a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i);
        sum1 = min(sum1,sum.at(i));
    }
    cout << min(ans,sum1) << endl;

    
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int MAX = 1e6 + 5;
int dp[MAX][2];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  reverse(rng(s));
  s += '0';
  int n = s.size();
  rep(i, MAX) rep(j, 2) dp[i][j] = inf;
  dp[0][0] = 0;
  rep(i, n+1) rep(j, 2) {
    int x = s[i] - '0', ni = i+1;
    x += j;
    if (x < 10) chmin(dp[ni][0], dp[i][j]+x);
    if (x > 0) chmin(dp[ni][1], dp[i][j]+(10-x));
  }
  std::cout << dp[n][0] << "\n";
}


Measured memory_bytes: 9116
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n, m = inl()


def solve():
    return (n - 1) * (m - 1)


print(solve())


Measured memory_bytes: 9104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		sc.close();

		while (true) {
			C -= B;
			if (C <= 0) {
				System.out.println("Yes");
				break;
			}
			A -= D;
			if (A <= 0) {
				System.out.println("No");
				break;
			}
		}

	}

}

Measured memory_bytes: 35716
#include<stdio.h>

int main( ){

int x,y;

while(1){scanf("%d%d",&x,&y);
  if (x==0 && y==0) break;
 else if (x<=y){printf("%d %d\n",x,y);}
  else if (x>=y){printf("%d %d\n",y,x);}
 }


return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int N, T, t[200010], dt[200010];
  cin >> N >> T;
  for (int i = 0; i < N; i++) cin >> t[i];
  dt[0] = 0;
  for (int i = 1; i < N; i++) {
    dt[i] = t[i] - t[i-1];
  }

  long long ans = 0;
  for (int i = 1; i < N; i++) {
    ans += min(dt[i], T);
  }
  ans += T;

  cout << ans << endl;
  return 0;
}


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

int main() {
    int h,w;
    while(true){
        cin >> h >> w;
        if(h==0 && w==0){
            return 0;
        }
        for(int i = 0;i<h;i++){
            for(int j = 0;j<w;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;
int main(void){
  int W, H, N;
  int x[110], y[110], a[110];
  cin >> W >> H >> N;
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> a[i];
  }

  bool XY[110][110];
  for(int j = 0; j < W; j++){
    for(int k = 0; k < H; k++){
      XY[j][k] = false;
    }
  }
  //fill(XY, XY + 110, false);
  for(int i = 0; i < N; i++){
    if(a[i] == 1){
      for(int j = 0; j < x[i]; j++){
        for(int k = 0; k < H; k++){
          XY[j][k] = true;
        }
      }
    }
    else if(a[i] == 2){
      for(int j = x[i]; j < W; j++){
        for(int k = 0; k < H; k++){
          XY[j][k] = true;
        }
      }
    }
    else if(a[i] == 3){
      for(int k = 0; k < y[i]; k++){
        for(int j = 0; j < W; j++){
          XY[j][k] = true;
        }
      }
    }
    else if(a[i] == 4){
      for(int k = y[i]; k < H; k++){
        for(int j = 0; j < W; j++){
          XY[j][k] = true;
        }
      }
    }
  }
  int cnt = 0;
  for(int j = 0; j < W; j++){
    for(int k = 0; k < H; k++){
      if(XY[j][k] == false) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
#define ll long long


int main(){
        int N,i;
        cin >> N;
        vector <int> a(N);
        for(i=0; i<N; i++) {
                cin >> a[i];
        }
        sort(a.begin(), a.end() );
        cout << a[N-1]-a[0] << endl;


        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long int a,b,c,d;
    cin >> a >> b >> c >> d;
    long int max = b*d;
    if(a*c>max) max = a*c;
    if(a*d>max) max = a*d;
    if(b*c>max) max = b*c;
    printf("%ld\n",max);
    return 0;
}

Measured memory_bytes: 3760
#!/usr/bin/env ruby

while (h, w = gets.chomp.split.map(&:to_i)) != [0, 0]
  str = ''
  str2 = ''
  w.times do |i|
    if i.odd?
      str += '#'
      str2 += '.'
    else
      str += '.'
      str2 += '#'
    end
  end
  h.times { |i| puts (i.odd? ? str : str2) }
  puts
end

Measured memory_bytes: 6884
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    
    int n, i;
    long long max = -1000000, min = 1000000, tmp, sum = 0;
    
    
    scanf("%d", &n);
    
    for (i=0; i<n; i++) {
        scanf("%lld", &tmp);
        sum += (long long)tmp;
        
        if(max <= tmp) {
            max = tmp;
        }
        if (min >= tmp) {
            min = tmp;
        }

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

Measured memory_bytes: 3220
x1, y1, x2, y2 = input().split(' ')
x1 = int(x1)
y1 = int(y1)
x2 = int(x2)
y2 = int(y2)
a = x2-x1
b = y2-y1
x3 = x2-b
y3 = y2+a
x4 = x3-a
y4 = y3-b
print(x3, y3, x4, y4)

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

using namespace std;

using ll = long long;

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); 

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
    cin >> n;
    int jumps[n];
    vector<int> dp(n, 0); // dp[i] : Minimum cost for the frog to reach position i.
    for (int i = 0; i < n; i++) cin >> jumps[i];
    dp[1] = abs(jumps[1] - jumps[0]); // Base value
    for (int i = 2; i < n; i++)
        dp[i] = min(abs(jumps[i] - jumps[i - 1]) + dp[i - 1], abs(jumps[i] - jumps[i - 2]) + dp[i - 2]);
    cout << dp[n - 1];
    return 0;


}


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int32_t main()
{
	int n, x = 0;
	cin >> n;
	vector<int> arr(n);
	for(int &w : arr) cin >> w, x ^= w;
	for(int &w : arr) cout << (w ^ x) << ' ';
	puts("");

	return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
 
using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll ;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<str> vstr;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;
 
#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define NP next_permutation
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)
 
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数
 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}

void solve(vvint kukan,int n){
  int ans = 1;
  int loc = kukan[0][1];
  REP(i,n-1){
    if(kukan[i+1][0]>=loc){
      ans+=1;
      loc = kukan[i+1][1];
    }
  }
  cout << ans <<endl;
}

int main(){
  ll n;
  vvint kukan(100000,vint(2));
  cin >> n;
  REP(i,n){
    int x,l;
    cin >> x;
    cin >> l;
    kukan[i][0]=x-l;
    kukan[i][1]=x+l;
  }
  sort(kukan.begin(),kukan.begin()+n,[](const vint &alpha,const vint &beta){return alpha[1] < beta[1];});
  solve(kukan,n);
}

Measured memory_bytes: 11136
h, w = map(int, input().split())

field = []
visited = {(1, 1)}

white_count = 0

field.append("#" * (w+2))


for i in range(h):
    row = input()
    field.append("#"+row+"#")
    white_count += row.count(".")

field.append("#" * (w+2))


def is_movable(x, y):
    state = (x, y)

    # 通った道であればFalseを返す
    if state in visited:
        return False

    if field[y][x] == "#":
        return False
    else:
        return True


def breadth_search(field):
    # x, y, count
    queue = [(1, 1, 1)]

    while queue:
        x, y, count = queue.pop(0)

        if(x == w and y == h):
            return count

        if(is_movable(x+1, y)):
            visited.add((x+1, y))
            queue.append((x+1, y, count+1))

        if(is_movable(x, y+1)):
            visited.add((x, y+1))
            queue.append((x, y+1, count+1))

        if(is_movable(x-1, y)):
            visited.add((x-1, y))
            queue.append((x-1, y, count+1))

        if(is_movable(x, y-1)):
            visited.add((x, y-1))
            queue.append((x, y-1, count+1))

    return 0


count = breadth_search(field)

if count == 0:
    print(-1)
else:
    print(white_count-count)


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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();
            String[] Line = S.Split(' ');
            int[] H = new int[N];
            int res = 0;
            int ans = 0;

            for(int i=0; i<N; i++)
            {
                H[i] = int.Parse(Line[i]);
                if(i >= 1)
                {
                    if(H[i] <= H[i - 1])
                    {
                        res++;
                    }
                    else
                    {
                        res = 0;
                    }
                    if (res > ans)
                    {
                        ans = res;
                    }

                }
            }

            Console.WriteLine(ans);


        }
    }
}

Measured memory_bytes: 25052
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
//        String b = scan.next();
        int c = Integer.parseInt(scan.next());
        String answer = "No ";
        int count = 0;
        count = (c/a)*b;
       PrintWriter out = new PrintWriter(System.out);
        out.println(count);
        out.flush();
        scan.close();
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define NMAX 4002
using namespace std;
int main(){
  long long N,ans = 0;
  char S[NMAX];
  vector<int> v[3];
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> S[i];
    if(S[i] == 'R') v[0].push_back(i);
    else if(S[i] == 'G') v[1].push_back(i);
    else if(S[i] == 'B') v[2].push_back(i);
  }
  for (int i = 0; i < v[0].size(); ++i)
  {
    for (int j = 0; j < v[1].size(); ++j)
    {
      int num = 0;
      if(find(v[2].begin(), v[2].end(),(v[0][i]*2-v[1][j])) != v[2].end()) num++;
      if(find(v[2].begin(), v[2].end(),(v[1][j]*2-v[0][i])) != v[2].end()) num++;
      if(find(v[2].begin(), v[2].end(),(v[0][i]+v[1][j])/2) != v[2].end() && (v[0][i]+v[1][j])%2 == 0) num++;
      ans += v[2].size() - num;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i=0; i<N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  if (N==1) {
    cout << S.at(0) << endl;
  }
  else {
    for (int j=0; j<N-1; j++) {
      cout << S.at(j);
    }
    cout << S.at(N-1) << endl;
  }
}

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

#include <atcoder/dsu.hpp>
#include <atcoder/fenwicktree.hpp>
#include <atcoder/segtree.hpp>
#include <atcoder/lazysegtree.hpp>
#include <atcoder/maxflow.hpp>
#include <atcoder/mincostflow.hpp>
#include <atcoder/modint.hpp>
#include <atcoder/convolution.hpp>

using namespace std;
using namespace atcoder;

////////////////	型名など
typedef long long ll;
#define endl '\n'

////////////////	各種定数
const ll INF = 1LL << 60;
const double EPS = 1e-12;

////////////////	便利なテンプレート関数
template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

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

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

	const ll BIG = 10000000000000LL;

	int N, K; cin >> N >> K;
	vector<vector<ll>> A(N);
	for (int i = 0; i < N; i++) {
		A[i].resize(N);
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}

	mcf_graph<ll, ll> G(N * 2 + 2);
	const int s = N * 2, t = s + 1;

	for (int i = 0; i < N; i++) {
		G.add_edge(s, i, K, 0);
		G.add_edge(i + N, t, K, 0);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			G.add_edge(i, j + N, 1, BIG - A[i][j]);
		}
	}
	G.add_edge(s, t, N * K, BIG);

	auto result = G.flow(s, t, N * K);
	cout << BIG - (result.second % BIG) << endl;

	vector<string> ans(N);
	for (int i = 0; i < N; i++) {
		ans[i].resize(N);
		for (int j = 0; j < N; j++) {
			ans[i][j] = '.';
		}
	}
	
	auto e = G.edges();
	for (auto itr = e.begin(); itr != e.end(); itr++) {
		if (itr->from < s && itr->to < s && itr->flow > 0) {
			ans[itr->from][itr->to - N] = 'X';
		}
	}

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

	return 0;
}

Measured memory_bytes: 3936
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

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


	long long N;
	cin >> N;

	if (N % 2 == 0)
		cout << N << endl;
	else
		cout << N * 2 << endl;


}

Measured memory_bytes: 256
# 20200612_yorukatsu_b.py
def canGo(h,w,y,x):
    if h==y and w==x:
        return False
    if h<0 or h>=H or w<0 or w>=W:
        return False
    if glid[h][w] == "#":
        return False
    return True

def search(h,w):
    dy=[-1,0,1]
    dx=[-1,0,1]
    if glid[h][w]=="#":
        mine[h][w] = -1
        for y in dy:
            for x in dx:
                if canGo(h+y,w+x,h,w):
                    mine[h+y][w+x]+=1

H,W = map(int,input().split())
glid =[]
for i in range(H):
    glid.append(list(input()))
# print(glid)
mine = [[0]*W for i in range(H)]
# print(mine)

for i in range(H):
    for j in range(W):
        search(i,j)
for i in mine:
    for j in i:
        print(j if j!=-1 else "#",end="")
    print()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define _FORTIFY_SOURCE 0 //просто херь
#pragma GCC optimize("Ofast") // векторизацию подрубает, ну там сложно
#pragma GCC optimize("no-stack-protector") //хуйня
#pragma GCC optimize("unroll-loops") // у тебя есть фор по 100 он просто берет и повторяет не фор а 100 раз ну иногда ускоряет
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native") // вот здесь потно ну там 03 02 запускает с битами быстрее работает там тоже векторизация
#pragma GCC optimize("fast-math") //быстрее с вещественными работает ну там float оч быстрый становится
using namespace std;

const int N = 5e6 + 8, MOD = 1e9 + 7;
const long long INF = 2e16;

#define ss second
#define ff first
//#define int long long
#define double long double

using vi = vector <int>;
using vp = vector <pair <long long, long long>>;

mt19937 Flash_new_51(515151);

int maxx[N], a[N];


signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        maxx[i] = max(a[i], maxx[i - 1]);
    }
    bool ok = true;
    for (int i = 2; i <= n; i++) {
        int delta = maxx[i - 1] - a[i];
        if (delta > 1) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


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

int main()
{
    float r;
    cin >> r;
    cout << r * 2 * PI << endl;
    return 0;
}

Measured memory_bytes: 3788
N = int(input())
prefix = '0{}b'.format(N)
li = [[-1]*N for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x,y = [int(zz) for zz in input().split()]
        li[i][x-1] = y

ans = 0
for i in range(2**N):
    bin = format(i,prefix)
    flag = 1
    for j in range(N):
        if (i>>j)&1:
            for k in range(N):
                if li[j][k] == 1:
                    if bin[-k-1] != '1':
                        flag = 0
                elif li[j][k] == 0:
                    if bin[-k-1] != '0':
                        flag = 0
    if flag:
        ans = max(ans,list(bin).count('1'))

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
vector<int> solve(auto N, auto A, auto B) {
  if(N < A+B-1) return {-1};
  if(A*B < N)   return {-1};
  vector<int> res;
  vector<vector<int>> part(1);
  for(auto i=1; i<=N; ++i) {
    if(part.back().size()==B || N-i+1==A-part.size()) part.emplace_back(0);
    part.back().emplace_back(i);
  }
  for(auto& i: part) reverse(begin(i), end(i));
  for(auto i: part) res.insert(end(res), begin(i), end(i));
  return res;
}
int main() {
  LL N, A, B;
  cin >> N >> A >> B;
  auto v = solve(N, A, B);
  for(auto i=0; i<v.size(); ++i) cout << (i ? " " : "") << v[i];
  cout << endl;
}


Measured memory_bytes: 22700
#include <bits/stdc++.h>
#define N 366
using namespace std;
int n,A[N][4][4];
int mem[N][3][3][7][7][7][7];
int dx[]={0,0,0,1,-1};
int dy[]={0,1,-1,0,0};

int check(int d,int x,int y){
  if(x<0||y<0||x>=3||y>=3)return 0;
  for(int i=0;i<2;i++)
    for(int j=0;j<2;j++)if(A[d][y+i][x+j]) return 0;
  return 1;
}

void getABCD(int x,int y,int &A,int &B,int &C,int &D){
  A++,B++,C++,D++;
  if(x==0&&y==0) A = 0;
  if(x==2&&y==0) B = 0;
  if(x==0&&y==2) C = 0;
  if(x==2&&y==2) D = 0;
}

int dfs(int num=0,int x=1,int y=1,int A=1,int B=1,int C=1,int D=1){
  if(num==n-1) return 1;
  if(mem[num][x][y][A][B][C][D]++) return 0;
  
  for(int i=0;i<5;i++)
    for(int j=0,nx=x,ny=y;j<2;j++){
      nx+=dx[i],ny+=dy[i];
      int nA=A,nB=B,nC=C,nD=D;
      getABCD(nx,ny,nA,nB,nC,nD);
      if(nA==7||nB==7||nC==7||nD==7)continue;
      if(check(num+1,nx,ny)&&dfs(num+1,nx,ny,nA,nB,nC,nD))return 1;
    }
  return 0;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      for(int j=0;j<16;j++) cin>>A[i][j/4][j%4];

    memset(mem,0,sizeof(mem));
    cout<<check(0,1,1)*dfs()<<endl; 
  }
  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    map<char, int> m;
    rep (i, s.size()) {
        m[s[i]]++;
    }

    bool flag = true;
    for (map<char, int>::iterator it = m.begin(), end = m.end(); it != end; it++) {
        if (it->second % 2 != 0) {
            flag = false;
        }
    }
    
    if (flag) {
        Yes
    } else {
        No;
    }
    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }

template<class T>
constexpr T gcd(T a, T b)
{
    if (a < b) gcd(b, a);
    T r = 0;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<class T>
constexpr T lcm(T a, T b)
{
    T g = gcd<T>(a, b);
    return a / g * b;
}

int N, M;
string S, T;
void solve() {
    cin >> N >> M;
    cin >> S >> T;

    auto g = gcd(N, M);
    auto n = N / g;
    auto m = M / g;
    rep(i, g) {
        if (S[n * i] != T[m * i]) { cout << -1 << endn; return; }
    }

    cout << lcm<ll>(N, M) << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int N;
ll a[3100];
ll dp[3100][3100];

ll rec(int i, int j)
{
  if(i>j) return 0;
  if(dp[i][j] > 0) return dp[i][j];
  if(i==j) return a[i];
  
  ll res;
  res = max(a[i] - rec(i+1, j), a[j] - rec(i, j-1));
  return dp[i][j] = res;
}

int main(){
  cin >> N;
  rep(i, N) cin >> a[i];

  cout << rec(0, N-1) << endl;

  return 0;
}


Measured memory_bytes: 74112
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)


int main() {
  int n,m,x,y;
  cin >> n>>m>>x>>y;
 
  int xmax=-1000;
  int ymin=1000;
  
  rep(i,n) {
  int p;
  cin >> p;
  xmax=max(xmax,p);
  }
  
  rep(i,m) {
  int q;
  cin >> q;
  ymin=min(ymin,q);
  }
  
  cout << (xmax<ymin && x<y && !(ymin<=x || y<=xmax)?"No War":"War") << endl;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**10
for i in range(n-k+1):
    left = X[i]
    right = X[i+k-1]
    ans = min(ans, abs(left)+abs(left-right), abs(right)+abs(right-left))
print(ans)


Measured memory_bytes: 14384
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int v,next;}e[MAX<<1];
int h[MAX],cnt=1;
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;}
int f[MAX][25];
int ans,n;
void dfs(int u,int ff)
{
	for(int i=h[u];i;i=e[i].next)
	{
		int v=e[i].v;if(v==ff)continue;
		dfs(v,u);
		for(int j=0;j<=20;++j)f[u][j]+=f[v][j];
	}
	int p=0;
	for(int i=20;~i;--i)
		if(f[u][i]>1){p=i+1;break;}
	while(f[u][p])++p;++f[u][p];
	for(int i=0;i<p;++i)f[u][i]=0;
	ans=max(ans,p);
}
int main()
{
	n=read();
	for(int i=1;i<n;++i)
	{
		int u=read(),v=read();
		Add(u,v);Add(v,u);
	}
	dfs(1,0);printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 17664
n=int(input())
data=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans=[]
res=n
while res>0:
  m=res%26
  res=(res-1)//26
  if m==0:
    ans.append('z')
  else:
    ans.append(data[m-1])
ans.reverse()
print(*ans,sep='')

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,A[10101];
ll i, j, k;
int main(){
    scanf("%lld",  &N);
    j = 0;
    fornum(i,0,N){
        scanf("%lld", &A[i]);
        while(A[i]%2==0){
            A[i] /= 2;
            ++j;
        }
    }
    printf("%lld\n", j);

    return 0;
}

Measured memory_bytes: 384
n,m = map(int,input().split())
if n >= 3 and m >= 3:
    ans = (n-2) * (m-2)
elif n >= 3 and m==1:
    ans = n-2
elif m >= 3 and n==1:
    ans = m-2
elif n==1 and m==1:
    ans = 1
else:
    ans = 0
print(ans)

Measured memory_bytes: 38256
x = int(input())
if 400 <= x < 600:
    ans = 8
elif x < 800:
    ans = 7
elif x < 1000:
    ans = 6
elif x < 1200:
    ans = 5
elif x < 1400:
    ans = 4
elif x < 1600:
    ans = 3
elif x < 1800:
    ans = 2
else:
    ans = 1
print(ans)    

Measured memory_bytes: 9184
#include<stdio.h>

int main(void){
    int N, M;
    int l, r;
    int L, R;
    int i, count = 0;

    scanf("%d %d", &N, &M);

    for(i = 0; i < M; i++){
        scanf("%d %d", &l,&r);
        if(i == 0){
            L = l;
            R = r;
        }else{
            if(l > L){
                L = l;
            }
            if(r < R){
                R = r;
            }
        }
    }
    if(L == R){
        printf("1\n");
    }else if(L != R){
        for(i = L; i <= R; i++){
            count++;
        }
        printf("%d", count);
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
 
 
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int MOD =  1e9 + 7; 
 
 
 
ll power(ll a, ll b){
	if(b == 0) return 1;
	else {
		ll x = power(a,b/2);
		x = (x*x)%MOD;
		if(b&1) return (x*a)%MOD;
		else return x;
	}
}
 
 
ll& Mod(ll& a) {
    if (a >= MOD) {
        return Mod(a -= MOD);
    } else if (a < 0) {
        return Mod(a += MOD);
    } else {
        return a;
    }
}
 
ll gcd(ll a, ll b) { 
	// b < a
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 

const int N = 1e5 + 100;
ll cnt[N];
int main() {
	fast_cin();	
	ll n, k; cin >> n >> k;

	ll ans = 0;
	for(ll i = k; i >= 1; i--){
		cnt[i] = 0;
		Mod(cnt[i] += power(k/i, n));
		for(ll j = 2*i; j <= k; j+=i) { 
			Mod(cnt[i] -= cnt[j]);
		}
		//debug(i, cnt);
		Mod(ans += (cnt[i]*i)%MOD);
	}
	
	cout << ans << '\n';
}


Measured memory_bytes: 4300
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	vs a(8);
	rep(i,8)
		cin>>a[i];
	vs b(8,string(8,' '));
	rep(k,3){
		rep(i,8)
			rep(j,8)
				b[i][j]=a[7-j][i];
		cout<<(k+1)*90<<endl;
		rep(i,8){
			rep(j,8)
				cout<<b[i][j];
			cout<<endl;
		}
		a=b;
	}
	
	return 0;
}

Measured memory_bytes: 0
A, B, K = map(int, input().split())
if B-A+1 >= 2*K: # A以上B以下の整数の数が2K以上
    res_list = [i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)]
else: # A以上B以下の整数の数が2K未満
    res_list = [i for i in range(A, B+1)]
for i in res_list:
    print(i)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int ma, n;
	
	while (scanf("%d", &ma) && ma){
		bool state[256][256] = {{0}};
		int a[256] = {0};
		
		scanf("%d", &n);
		
		for (int i = 1; i <= n; i++) scanf("%d", a + i);

		n += 2;

		for (int i = 0; i < n; i++){
			for (int j = 1; j <= ma && i + j < n; j++){
				state[i][min(n - 1, max(0, i + j + a[i + j]))] = true;
			}
		}
		
		for (int k = 0; k < n; k++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					if (state[i][k] && state[k][j]) state[i][j] = true;
		
		bool ng = false;
		for (int i = 0; i < n - 1; i++) if (state[0][i] && !state[i][n - 1]) ng = true;
		printf("%s\n", ng ? "NG" : "OK");
	}
	
	return (0);
}

Measured memory_bytes: 1084
#include<cstdio> 
#include<cmath> 
#include<cstring> 
#include<algorithm> 
using namespace std; 

#define debug(x) cerr<#x<<"="<<x<<endl;
#define m(a,b) memset(a,b,sizeof(a))
typedef long long ll;

int main(){
	int a, b, c; 
	scanf("%d%d%d", &a, &b, &c); 
	for(int i = 1; i < 1000000; i++){
		if(((i * a) % b == c % b)){
			printf("YES\n"); 
			return 0; 
		} 
	} 
	printf("NO\n"); 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string s;
int n;
array<char,26> alf;
vector<string> ans;

template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }

string fx(const string& v){
    string t = v;
    bool used[26];
    fill(used,used+26,false);
    for(int i=0;i<n;i++){
        if(t[i]=='a') continue;
        if(!used[t[i]-'a']){
            t[i]--;
        }
        used[v[i]-'a']=true;
    }
    return t;
}

void solve(){
    ans.assign(0,"");
    n=s.size();

    for(int mask=0;mask<(1<<n);mask++){
        string ss = s;
        bool f=true;
        bool exist[26];
        fill(exist,exist+26,false);
        for(int i=0;i<n;i++){
            if(mask & (1<<i)){
                if(ss[i]=='z'){
                    f=false;break;
                }
                ss[i]++;
                if(exist[ss[i]-'a']){
                    f=false;break;
                }
            }
            exist[ss[i]-'a'] = true;
        }

        if(!f){
            //ss = s;
            //for(int i=0;i<n;i++){
            //    if(mask & (1<<i)) ss[i]++;
            //}
            //cout << ss << endl;
            continue;
        }
        string fs = fx(ss);
        //cout << ss << " " << fs << endl;
        if(fs==s)
            ans.pb(ss);
    }
    sort(all(ans));

    cout << ans.size() << endl;
    if(ans.size()<=10){
        for(auto x : ans) cout << x <<endl;
        return;
    }
    for(int i=0;i<5;i++) cout << ans[i] << endl;
    for(int i=ans.size()-5;i<ans.size();i++) cout << ans[i] << endl;
}

void init(){
    for(int i=0;i<26;i++){
        alf[i]=i+'a';
    }
}

int main(){
    while(1){
        cin >> s;
        if(s=="#") break;
        solve();
    }
}

Measured memory_bytes: 4268
N, W = list(map(int, input().split()))
WE = []
V = []
for i in range(N):
    w, v = list(map(int, input().split()))
    WE.append(w)
    V.append(v)

MAX_W = 10 ** 5

# DP[i][j]: i以降の品物で重さj以下のときの価値の最大
DP = []
for i in range(N):
    a = [None] * (MAX_W + 1)
    DP.append(a)
DP.append([0] * (MAX_W+1))

for i in range(N-1, -1, -1):
    for j in range(MAX_W+1):
        if i == N:  # i番目の品物はない
            DP[i][j] == 0
        elif j < WE[i]:  # この重さの品物は入れないから無視
            DP[i][j] = DP[i+1][j]
        else:
            DP[i][j] = max(DP[i+1][j], DP[i+1][j-WE[i]]+V[i])

# for i in range(N):
#     print(DP[i][:10])
print(DP[0][W])

Measured memory_bytes: 259080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  vector<pair<ll, ll>> task;
  ll n;
  cin >> n;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    task.push_back(make_pair(b, a));
  }
  sort(ALL(task));
  ll t = 0;
  REP(i, n) {
    t += task[i].second;
    if (t > task[i].first) {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
  return 0;
}


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

unordered_map<int, bool> mp;
const int nax = 1e4;

int main() {

    int a, b, h, m;
    cin >> a >> b >> h >> m;



    double min_an = 6*m;
    double hour_an = 30*h;

    hour_an += (m * 1.0) / 2;

    double theta;
    


    if(hour_an > min_an) {
        theta = min(hour_an - min_an, 360 + min_an - hour_an);
    }else {
        theta = min(min_an - hour_an, 360 + hour_an - min_an);
    }

    double rad = (theta * (3.14159265358979323846)) / 180;

    double ans_sq = a*a*1.0 + b*b*1.0 - 2.0*a*b*cos(rad);


    double ans = pow(ans_sq, 0.5);

    printf("%0.23lf\n", ans);
}

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

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
           
           int  x = int.Parse(Console.ReadLine());

            if (x == 7 || x == 5 || x == 3)

                Console.WriteLine("YES");

            else
                Console.WriteLine("NO");

            Console.ReadKey();
        }
    }
}


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int H, W, N;
void MAIN() {
    scanf("%d%d%d", &W, &H, &N);
    int ans = min((N+H-1)/H, (N+W-1)/W);
    printf("%d\n", ans);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> s(N);
    int Sum = 0;
    for(int i = 0;i < N;i++){
        cin >> s[i];
        Sum += s[i];
    }
    std::sort(s.begin(), s.end());
    int Sum_d = Sum;
    for(int i = 0;i < N;i++){
        if((Sum_d % 10) == 0){
            Sum_d = Sum - s[i];
        }else{
            break;
        }
    }
    if((Sum_d % 10) == 0){
        cout << 0;
    }else{
        cout << Sum_d;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] parts = scanner.nextLine().split(" ");
        int n = Integer.parseInt(parts[0]);
        int k = Integer.parseInt(parts[1]);

        int[] nums = new int[n];

        parts = scanner.nextLine().split(" ");
        for (int i = 0; i < nums.length; i++) {
            nums[i] = Integer.parseInt(parts[i]);
        }

        //dp[i] will be true if the first player wins  if there are i stones remaining
        boolean[] dp = new boolean[k + 1];

        for (int stones = 0; stones <= k; stones++) {
            for (int x : nums) {
                if (stones >= x && !dp[stones - x]) {
                    dp[stones] = true;
                    break;
                }
            }
        }

        System.out.println(dp[k] ? "First" : "Second");
    }

}


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


int main() {
  int n,m;
  cin >> n>>m;
  
  int ans;
  rep2(i,1,sqrt(m)+1){
    if(m%i==0){
      if(n<=m/i){
        ans=max(ans,i);
      }
      if(n<=i){
        ans=max(ans,m/i);
      }
    }
  }
  
  cout<<ans<<endl;
  
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto& p : mp) {
        int s = p.second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

vi *g;
int grid[2005][2005];

void bfs(int s, int n){
  vi dst(n+1, 1e5);
  vi vis(n+1, 0);
  queue<int> q;
  int t = s;
  vis[s] = 1;
  q.push(s);
  dst[s] = 0;
  while(!q.empty()){
    s = q.front(); q.pop();
    vi &adj = g[s];
    for(auto k : adj){
      if(vis[k]) continue;
      vis[k] = 1;
      dst[k] = dst[s] + 1;
      q.push(k);
    }
  }
  f(i, sz(dst)) {
    if(dst[i] < 2005) grid[t][dst[i]]++;
  }
}

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n, x, y; cin >> n >> x >> y;
    g = new vi[n+1];
    fo(i, 1, n){
      g[i].pb(i+1);
      g[i+1].pb(i);
    }
    g[x].pb(y); g[y].pb(x);

    fo(i, 1, n+1) bfs(i, n);
    vi ans(n+1, 0);
    fo(i, 1, n+1){
      f(j, n){
        ans[j] += grid[i][j];
      }
    }
    fo(i, 1, n) cout << ans[i]/2 << "\n";
    return 0;
}


Measured memory_bytes: 16128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Student> student = new ArrayList<Student>();
		//入力をリストに格納
		String buf;
		while((buf = br.readLine()) != null){
			String[] input = buf.split(",");
			student.add(new Student(Integer.parseInt(input[0]), Double.parseDouble(input[1]), Double.parseDouble(input[2])));
		}
		//肥満判定
		for(Student s : student){
			if(isFat(s)){
				System.out.println(s.id);
			}
		}
	}
	
	public static boolean isFat(Student student){
		boolean isFat = false;
		double bmi = student.weight / (student.height * student.height);
		if(bmi >= 25.0){
			isFat = true;
		}
		return isFat;
	}
}

class Student{
	int id;
	double weight;
	double height;
	Student(int id, double weight, double height){
		this.id = id;
		this.weight = weight;
		this.height = height;
	}
}

Measured memory_bytes: 9780