akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-18;
const double INF = 1e9;



int main(){
	string str;
	while(cin>>str){
		string res="";
		REP(i,SZ(str)){
			if(str[i]=='@'){
				int num=(int)(str[i+1]-'0');
				REP(j,num)res+=str[i+2];
				i+=2;
			}else res+=str[i];
		}
		cout<<res<<endl;
	}
	return 0;
}

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

int main() {
  int N, n1, n2, n3, n4;
  cin >> N;

  n1 = N / 1000;
  n2 = (N - n1 * 1000) / 100;
  n3 = (N - (n1 * 1000) - (n2 * 100)) / 10;
  n4 = (N - (n1 * 1000) - (n2 * 100) - (n3 * 10));

  if ((n1 == n2 && n1 == n3) || (n2 == n3 && n2 == n4)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3640
#include<iostream>
#include<queue>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
struct Point{int y, x;};

int W[100][50], w, h;

int bfs(){
  Point s;
  s.y = s.x = 0;
  queue<Point> Q;
  int d[50][50];
  rep(i, h) rep(j, w) d[i][j] = (1<<21);
  d[0][0] = 1;
  Q.push(s);
  Point u, v;
  int dy[4] = {0, -1, 0, 1};
  int dx[4] = {1, 0, -1, 0};
  int ny, nx, ii, jj;

  while(!Q.empty()){
    u = Q.front(); Q.pop();
    if ( u.y == h-1 && u.x == w-1 ) return d[u.y][u.x];
    rep(r, 4){
      nx = u.x + dx[r];
      ny = u.y + dy[r];
      if ( nx < 0 || ny < 0 || ny >= h || nx >= w || d[ny][nx] != (1<<21)) continue;
      if ( W[u.y*2+dy[r]][u.x-((r==2)?(1):0)] )	continue;
      d[ny][nx] = d[u.y][u.x] + 1;
      v.x = nx;
      v.y = ny;
      Q.push(v);
    }
  }

  return 0;
}

main(){
  while(cin>> w >> h && (w&&h)){
    rep(i, h*2-1) rep(j, ((i%2)?w:w-1)) cin >> W[i][j];
    cout << bfs() << endl;
  }
}

Measured memory_bytes: 932
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e5+2;
typedef long long ll;
int a[maxx];
vector<int> b;
int main(){
    int n,k;cin>>n>>k;
    int mx=0,sum=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        mx=max(mx,a[i]);
        sum+=a[i];
    }
    for(int i=sum;i;i--){
        if(sum%i) continue;
        b.clear();
        for(int j=1;j<=n;j++){
            b.push_back(a[j]%i);
        }
        sort(b.begin(),b.end());
        int l=0,r=n-1;
        int ans=0;
        while(l<r){
            while(b[l]==0) l++;
            if(l>=r) break;
            int x=i-b[r];
            //cout<<i<<" "<<l<<" "<<r<<" "<<x<<endl;
            while(x&&l<r){
                if(b[l]>=x){
                    b[l]-=x;
                    ans+=x;
                    b[r]=0;
                    r--;

                    break;
                }else{
                    ans+=b[l];
                    x-=b[l];
                    b[l]=0;
                    l++;
                }
            }
        }
        int f=0;
        for(auto x:b){
            if(x){
                f=1; break;
            }
        }
        if(f) continue;
        if(ans>k) continue;
        cout<<i<<endl;
        return 0;
    }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long n,x;
  long c=0;
  cin>>n>>x;
  long arr[n];
  for(int i=0;i<n;i++)cin>>arr[i];
  if(arr[0]>x){
    c = arr[0]-x;
    arr[0]=x;
  }
  for(int i=1; i <n; i++){
    int a;
    a = arr[i] + arr[i-1];
    if(a > x){
      c+=a-x;
      arr[i] -=a-x;
    }
  }
  cout<<c;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
int f( int x ){
    return x*x;
}

int main(){
    int d, s, i;
 
    while( scanf("%d", &d) != EOF ){
 
        s=0;
 
        for( i=0; i<600; i+=d ){
            s += d*f(i);
        }
 
        printf("%d\n", s);
    }
 
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int n ;
vector<int> v[2] ;
int dfs(int x,int y,int sum){
    sum += v[x][y] ;
    if ( x == 1 && y == n-1 ){
        return sum ;
    }
    int right = 0, left = 0 ;
    if ( y + 1 < n )
        right = dfs(x,y+1,sum);
    if ( x + 1 < 2 )
        left = dfs(x+1,y,sum);
    return max(right,left);
}
int main(){
    cin >> n ;
    for(int i=0;i<n;i++){
        int x ;
        cin >> x ;
        v[0].push_back(x);
    }
    for(int i=0;i<n;i++){
        int x ;
        cin >> x ;
        v[1].push_back(x);
    }
    vector<int> sum1(n+1);
    vector<int> sum2(n+1);
    sum1[0] = 0 ;
    sum2[0] = 0 ;
    for(int i=1;i<=n;i++){
        sum1[i] = sum1[i-1] + v[0][i-1];
        sum2[i] = sum2[i-1] + v[1][i-1];
    }
    int ans = 0 ;
    for(int i=0;i<n;i++){
        int res = sum1[i+1] + sum2[n] - sum2[i] ;
        ans = max(ans,res);
    }
    cout << ans << endl;
    return 0 ;
}


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

using namespace std;

int INF=1e9;

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

    int x,y;
    cin>>x>>y;

    long long ans=0;

    if(x>0){
        if(y>=x)ans=y-x;
        else if(y>0)ans=(x-y)+2;
        else if(x>=-y)ans=1+(x+y);
        else ans=(-y-x)+1;
    }
    else if(x==0){
        if(y>=0)ans=y;
        else ans=-y+1;
    }
    else{
        if(y<x)ans=2+(x-y);
        else if(y<=0)ans=y-x;
        else if(y<=-x)ans=1+(-x-y);
        else ans=1+(y+x);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc076/tasks/abc076_c"

def main():
    S = input()
    T = input()
    ans = 'UNRESTORABLE'
    words = []
    if S.count('?') == 0:
        print(S)
        exit()

    for i in range(len(S)):
        if S[i] != T[0] and S[i] != '?':
            continue
        s = S[i:i + len(T)]
        if len(s) < len(T):
            continue

        flg = False
        for j, ss in enumerate(s):
            flg = True if ss == T[j] or ss == '?' else False
            if not flg: break
        if flg:
            words.append(S[:i] + T + S[i + len(T):])
    if not words:
        print(ans)
        exit()
    for i in range(len(words)):
        words[i] = words[i].replace('?', 'a')
    words.sort()
    print(words[0])


if __name__ == '__main__':
    main()


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

int A[20], B[20], C[20];

int main() {
  int N, result;
  int i;
  scanf ("%d", &N);
  
  for (i=0;i<N;i++) {
      scanf("%d", &A[i]);
  }
  for (i=0;i<N;i++) {
      scanf("%d", &B[i]);
  }
  for (i=0;i<N-1;i++) {
      scanf("%d", &C[i]);
  }
  
  result = 0;
  for (i=0;i<N;i++) {
  	result += B[i];
  	if ((i>0)&&(A[i]==A[i-1]+1)) result += C[A[i-1]-1];
  }
  
  
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 128
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N+1)
	for i := 0; i <= N; i++ {
		fmt.Scan(&A[i])
	}
	back_min := make([]int, N+1)
	back_max := make([]int, N+1)

	back_min[N] = A[N]
	back_max[N] = A[N]
	for i := N - 1; i >= 0; i-- {
		back_min[i] = A[i] + (back_min[i+1]+1)/2
		back_max[i] = A[i] + back_max[i+1]
	}

	if back_min[0] > 1 || back_max[0] < 1 {
		fmt.Println(-1)
		return
	}

	x := make([]int, N+1)
	x[0] = 1
	for i := 1; i <= N; i++ {
		forward_max := (x[i-1] - A[i-1]) * 2
		if back_min[i] > forward_max {
			fmt.Println(-1)
			return
		}
		x[i] = min(forward_max, back_max[i])
	}

	s := 0
	for i := 0; i <= N; i++ {
		// fmt.Printf("%d %d %d\n", x[i], back_min[i], back_max[i])
		s += x[i]
	}

	fmt.Println(s)
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
int n, x, f[100005], m;
int main() {
    scanf("%d", &n);
    for (int i=0;i<n;i++) scanf("%d", &x), f[x-1]++, f[x]++, f[x+1]++;
    for (int i=0;i<=100000;i++) {
        m = max(m, f[i]);
    }
    printf("%d\n", m);
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <bitset>

using namespace std;

using ll = long long;
#define REP(i, n) for(int (i) = 0;(i) < (n);(i)++)

int n;
string s;

using i64 = int64_t;
const i64 B = 100000007;
const i64 MOD[3] = {998244353, 1000000007, 1000000009};
i64 t[3] = {1, 1, 1};
i64 sz;
vector<vector<i64>> Table;

bool func(int x) {

  map<i64, int> M[3];
  bool res = true;
  bitset<5000 + 10> bs[3];

  for (int i = 0; i < 3; i++) {

    int flag = 0;

    i64 mod = MOD[i];
    i64 t = 1;
    for (int j = 0; j < x; j++) {
      t = (t * B) % mod;
    }

    i64 h = 0;
    for (int j = 0; j < x; j++) {
      h = ((h * B) % mod + s[j]) % mod;
    }

    M[i][h] = x;

    for (int j = x; j < n; j++) {
      h = ((h * B) % mod + s[j]) % mod;
      h = (h + mod - ((s[j - x] * t) % mod)) % mod;
      if (M[i].count(h) && (j + 1 - M[i][h]) >= x) {
        bs[i][j] = 1;
      }
      if (!M[i][h]) M[i][h] = (j + 1);
    }

    bs[0] &= bs[i];
  }
  return bs[0].count() >= 1;
}

int main(void) {
  cin >> n >> s;
  int l = 0, r = n + 1;
  while (l + 1 != r) {
    int mid = (l + r) / 2;
    if (func(mid)) l = mid;
    else r = mid;
  }
  cout << l << '\n';
}



Measured memory_bytes: 4524
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to

void main()
{
  string s = chomp(readln());
   int a = to!int(s); // 第0要素を整数に変換
    if(a > 999){
        writeln("ABD");
    } else {
        writeln("ABC");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x,k;
    cin>>x>>k;
    if(x%k==0)
    {
        cout<<0;
    }
    else
    {
        long long a,b,c;
        a = x%k;
        b = x/k;
        c = abs(x- k*(b+1));
        //<<a<<" " <<b<<endl;
        cout<<min(a,c);
    }
    return 0;
}


Measured memory_bytes: 3552
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        if (a == 1) {
            System.out.println("Hello World");
        } else {
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            System.out.println(b + c);
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define MAX 3010
using namespace std;

int P;
int arr[MAX];
int poly[MAX];

inline int add(int a, int b)
{
	return (a + b) % P;
}

inline int prod(int a, int b)
{
	return a * b % P;
}

int main(void)
{
	cin >> P;
	for (int i = 0; i < P; i++)
	{
		int val;
		cin >> val;
		if (!val) continue;
		arr[P] = 1;
		for (int j = P; j > 0; j--)
		{
			poly[j - 1] = add(poly[j - 1], P - arr[j]);
			arr[j - 1] = prod(arr[j], i);
			if (j == 2) arr[1] = add(arr[1], P - 1);
			arr[j] = 0;
		}
	}
	for (int i = 0; i < P; i++) cout << poly[i] << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {
 int N;
int ans=0;
cin>>N;
fx(N){
int k;
cin>>k;
ans+=k-1;
}
ce(ans);
}

Measured memory_bytes: 256
let n = read_int ()
let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun i -> i))
let m = (n - 1) / 2

let rec f ans i =
  if i <> m then f (ans + a.(i) * 2) (i - 1)
  else if n mod 2 = 1 then ans + a.(m)
  else ans

let () =
  Array.sort (fun x y -> x - y) a;
  let ans = f a.(n - 1) (n - 2) in
  Printf.printf "%d\n" ans


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

int main(){
  int ans=0,n,array[200];
  cin>>n;
  for(int i=0;i<2*n;i++){
    cin>>array[i];
  }
  sort(array,array+2*n);
  for(int i=0;i<2*n;i+=2){
    ans+=array[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a,b,c,p[100005],ans=0;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(b*2==a+c)printf("YES");
	else printf("NO");
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,q,a[100005],c[100005];
int main(){
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++) cin>>a[i],c[a[i]]++;
	for(int i=1;i<=n;i++)
	{
		if(k-(q-c[i])>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 2176
n = int(input())
a_ls = list(map(int, input().split()))
b_ls = list(map(int, input().split()))

ret = 0

for i in range(n):
    if a_ls[i] >= b_ls[i]:
        ret += b_ls[i]
    else:
        ret += a_ls[i]
        left = b_ls[i] - a_ls[i]
        ret += min(left, a_ls[i+1])
        a_ls[i+1] = max(0, a_ls[i+1] - left)

print(ret)


Measured memory_bytes: 18468
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;
    int ans=0;
    if(((0<=x)&&(x<y))||((x<y)&&(y<=0))) cout << y-x << endl;
    else if(x==1e9&&y==1) cout << 1000000001 << endl;
    else if((0<=y)&&(y<x)){
        x=-x;
        cout << y-x+1 << endl;
    } else if((y<x)&&(x<0)){
        x=-x;
        cout << abs(y)-x+2 << endl;
    } else if((x<=0)&&(0<=y)){
        if(abs(x)<=abs(y)){
            x=-x;
            cout << y-x+1 << endl;
        } else{
            x=-x;
            cout << x-y+1 << endl;
        }
    } else if((y<=0)&&(0<=x)){
        if(abs(x)<=abs(y)){
            cout << abs(y)-x+1 << endl;
        } else{
            x=-x;
            cout << y-x+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(ipt())
    ans = [0]*n
    a = [int(i) for i in ipt().split()]
    cts = [(a[0],0)]
    d = defaultdict(int)
    d[a[0]] = 1
    tot = a[0]
    for i,ai in enumerate(a[1::]):
        tot += ai
        d[ai] += 1
        if cts[-1][0] < ai:
            cts.append((ai,i+1))

#    print(d,cts)
    nms = sorted(d.keys(),reverse=True)
    lc = len(cts)-1
    na = cts[lc][0]
    ps = cts[lc][1]
    sm = 0
    for i in nms:
        sm += d[i]
        if i == na:
            lc -= 1
            na = cts[lc][0]
            ans[ps] += sm*(i-na)
            pps = ps
            ps = cts[lc][1]
        else:
            ans[pps] += d[i]*(i-na)
#        print(ans)

    ans[0] = tot-sum(ans[1::])

    for i in ans:
        print(i)



    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 111276
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

LL w, h;
int main() {
	cin >> w >> h;
	vector<pair<LL, int>>v;//コスト、縦0横1
	for (int i = 0; i < w; i++) {
		int a;
		cin >> a;
		v.emplace_back(mp(a, 0));
	}
	for (int i = 0; i < h; i++) {
		int a;
		cin >> a;
		v.emplace_back(mp(a, 1));
	}
	sort(ALL(v));
	w++, h++;
	LL ans = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i].second == 0) {
			ans += v[i].first*h;
			w--;
		}
		else {
			ans += v[i].first*w;
			h--;
		}
	}
	cout << ans << endl;
}

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

int main() {
  char x,y;
  cin >> x >> y;
  if (x-y > 0) {
    cout << ">" << endl;
  } else if (x-y < 0) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
}

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

using namespace std;
char s[100005];
int main()//最终个数难以确定时观察奇偶性 
{
	scanf("%s",s+1);int len=strlen(s+1);
	if(s[1]==s[len])
		if(len&1) puts("Second"); else puts("First");
	else 
		if(len&1) puts("First"); else puts("Second");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int a[m];
  for(int i=0;i<m;i++){
    cin>>a[i];
  }
  if(n<x){
    int ans=0;
    for(int i=0;i<m;i++){
      if(a[i]>x&&a[i]<n)ans++;
    }
    cout<<ans<<endl;
  }
  else{
    int cnt_0=0,cnt_n=0;
    for(int i=0;i<m;i++){
      if(a[i]>0&&a[i]<x)cnt_0++;
      else if(a[i]>x&&a[i]<n)cnt_n++;
    }
    cout<<min(cnt_0,cnt_n)<<endl;
  }
}


Measured memory_bytes: 256
N = int(input())
nums=[int(input()) for _ in range(N)]
MAX = 10**4
dp = [0] * (MAX+1)
dp[0] = 1
for num in nums:
  for i in range(MAX+1)[::-1]:
    if dp[i] == 1 and (i + num) <= MAX*MAX:
      dp[i+num] = 1
ans = 0
for i in range(MAX+1):
  if dp[i] == 1 and i%10 != 0:
    ans = i
print(ans)


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

int main() {
  int a,b;
  string o,e;
  o = "Odd";
  e = "Even";
  cin >> a >> b;
  if (a%2 == 1 && b%2 == 1){
    cout << o << endl;
  }
  else {
    cout << e << endl;
  }
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int n, lim;
int a[N];

ll Check(int x) {
	ll cnt = 0;
	for (int i = 1; i <= n; i++)
		cnt += (a[i] - 1) / x;
	return cnt;
}

int BSearch(int L, int R) {
	while (L < R) {
		int M = (L + R) / 2;
		if (Check(M) > lim)
			L = M + 1;
		else
			R = M;
	}
	return L;
}

int main() {
	ios::sync_with_stdio(0);

	cin >> n >> lim;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	cout << BSearch(1, 1e9) << endl;

	return 0;
}


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

int main(void){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(x < 0 || y < 0 || x > w || y > h){
        cout << "No" << endl;
        return 0;
    }
    
    if(x < r || y < r || x > w-r || y > h-r){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    while(M--){
        int a;cin>>a;
        N-=a;
    }
    chmax(N,-1);
    cout<<N<<endl;
}



Measured memory_bytes: 3668
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	FULL_MATCH,
	ELSE,
};

ll length,POW[16];
ll num_array[20];
ll dp[20][10000][2][2];

ll getNUM(ll pre_num,ll next){
	return (10*pre_num+next)%10000;
}

bool is_OK(ll number){
	if((number/1000)%10 != 5)return false;
	if(number-5000 <= 99 || number-5000 >= 200)return false;
	if(number%10 != 3)return false;
	return true;
}

ll recursive(ll pre_num,ll digit,Type type,bool is_completed){

	if(digit == length){
		if(is_completed)return 1;
		else{
			return 0; //G数が成立しないならreturn 0;
		}
	}

	if(dp[digit][pre_num][type][is_completed] != -1){
		return dp[digit][pre_num][type][is_completed]; //計算済ならreturn
	}

	if(is_completed == true && type == ELSE){
		return dp[digit][pre_num][type][is_completed] = POW[length-digit];
	}

	ll ret = 0;
	ll limit;
	if(type == FULL_MATCH){
		limit = num_array[digit]-1;
	}else{
		limit = 9;
	}

	ll tmp;

	for(int next = 0; next <= limit; next++){
		tmp =  getNUM(pre_num,next);
		ret += recursive(tmp,digit+1,ELSE,is_completed||is_OK(tmp));
	}

	if(type == FULL_MATCH){
		tmp = getNUM(pre_num,num_array[digit]);
		ret += recursive(tmp,digit+1,FULL_MATCH,is_completed||is_OK(tmp));
	}

	return dp[digit][pre_num][type][is_completed] = ret;
}


int main(){

	for(int i = 0; i < 16; i++){
		POW[i] = pow(10,i);
	}

	ll N;
	scanf("%lld",&N);

	if(N <= 5102){
		printf("0\n");
		return 0;
	}

	stack<ll> S;

	//Nを桁別に分解する
	while(N > 0){
		S.push(N%10);
		N /= 10;
	}

	ll index = 0;

	while(!S.empty()){
		num_array[index++] = S.top();
		S.pop();
	}

	length = index;

	for(int digit = 0; digit <= length-1; digit++){
		for(int pre_num = 0; pre_num <= 9999; pre_num++){
			for(int p = 0; p <= 1; p++){
				for(int k = 0; k <= 1; k++){
					dp[digit][pre_num][p][k] = -1;
				}
			}
		}
	}

	printf("%lld\n",recursive(0,0,FULL_MATCH,false));

	return 0;
}




Measured memory_bytes: 9008
#include <bits/stdc++.h>
#define r(i,n) for(long i = 0; i<n; i++)
using namespace std;
 
int main() {
	long long n,k;
  long long count1 = 0,count2=0;
	cin >> n>>k;
	vector<long> v(2*n);
	r(i,n) {
      cin >>v.at(i);
      v.at(i+n)=v.at(i);
    }
  r(i,n){
    for(long j = i+1;j<2*n;j++){
      if(v.at(i)>v.at(j))count2++;
      if(v.at(i)>v.at(j)&&j<n)count1++;
    }
  }
  if(k%2==0){
    long long k2=k/2;
  cout << ((count2-count1)*(k-1)%1000000007*k2%1000000007+count1*k%1000000007)%1000000007<<endl;
  }
  else {
    long long k2=(k-1)/2;
    cout << ((count2-count1)*k2%1000000007*k%1000000007+count1*k%1000000007)%1000000007<<endl;
       }
}


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

using namespace std;
int main() {
    string s; cin>>s;
    int i =0, j = s.size() - 1;
    int ans = 0;
    while (i < j){
        if(s[i] != s[j]){
            ans++;
        }
        i++;
        j--;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int h, n, i, tmp, total = 0;
  scanf("%d %d", &h, &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &tmp);
    total += tmp;
  }
  if (total >= h)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, k, t, ans;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        ans += min(t, abs(k - t)) * 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin

  int N=in();
  string S; cin >> S;
  int K=in();

  char c = S[K-1];

  dump(S);

  for(char &w : S){
    if(w!=c) w = '*';
  }

  cout << S << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    vector<pair<string, int>> p(n);
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        int t; cin >> t;

        p[i] = make_pair(s, t);
    }

    string x; cin >> x;

    int ans = 0;

    bool match = false;

    for (auto a : p) {
        if (a.first == x) {
            match = true;
            continue;
        }

        if (match) {
            ans += a.second;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

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

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

	ll N;
	cin >> N;

	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;

	if (N % 2 == 0) {
		ans = N / 2;
		ans *= (N - 1);

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

	ans = (N - 1) / 2;
	ans *= N;

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)

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

    int ans = 0;
    int cnt = 0;
    rep(i, 0, s.length()) {
        if (s[i] == 'R') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
n,k = map(int, input().split())
mod = 10**9 + 7
ans = 0
A = [0 for _ in range(k+1)]

for x in range(k,0,-1):
    tmp = pow(k//x,n,mod)
    i = 2
    while i*x <= k:
        tmp -= A[i*x]
        i += 1
    A[x] = tmp
    A[x] %= mod
ans = 0
for i in range(1,k+1):
    ans += i * A[i]
    ans %= mod

print(ans)

Measured memory_bytes: 73704
def main():
    N,C = [int(_n) for _n in input().split()]
    L = 100010
    table = [[0]*L for _ in range(C)]
    for i in range(N):
        s,t,c = [int(_n) for _n in input().split()]
        c -= 1
        s -= 1
        t -= 1
        table[c][s] += 1
        table[c][t+1] -= 1 
    for c in range(C):
        for j in range(L-1):
            table[c][j+1] += table[c][j]
    for i in range(C):
        for j in range(L):
            table[i][j] = min(1, table[i][j])
    for j in range(L):
        for c in range(C-1):
            table[c+1][j] += table[c][j]
    print(max(table[C-1]))
    # print(table)
    # print(table)
    # acc = [0] * len(times)
    # progs.sort(key = lambda x:x[2])



main()

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

int a[200005], pf[200005], sf[200005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++)
		pf[i] = max(a[i], pf[i - 1]);
	for (int i = n; i >= 1; i--)
		sf[i] = max(a[i], sf[i + 1]);
	for (int i = 1; i <= n; i++)
		cout << max(pf[i - 1], sf[i + 1]) << '\n';
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll N,K,S;
    cin >> N >> K >> S;
    if(S == 1000000000){
        rep(i,K) cout << (i==0?"":" ")<< S;
        rep(i,N-K) cout << " " << 1;
        cout << endl;
    }else{
        rep(i,K) cout << (i==0?"":" ") << S;
        rep(i,N-K) cout << " " << S + 1;
        cout << endl;
    }
}

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

int main(){
    long long A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    long long ans=1e9+1;

    for (int Z=0;Z<=2*max(X,Y);Z+=2){
        ans=min(ans,A*(max(0ll,X-Z/2))+B*(max(0ll,Y-Z/2))+Z*C);
    }

    cout<<ans<<endl;

    return 0;
}

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

long long a[12345];

int main() {
  long long k;
  scanf("%lld", &k);
  int n = 50;
  for (int i = 0; i < n; i++) {
    a[i] = n - 1;
  }
  long long kn = (k + n - 1) / n * n;
  for (int i = 0; i < n; i++) {
    a[i] += kn / n;
  }
  while (kn > k) {
    --kn;
    for (int i = 0; i < n; i++) {
      if (a[i] >= n) {
        a[i] -= n;
        for (int j = 0; j < n; j++) if (j != i) a[j]++;
        break;
      }
    }
  }
  printf("%d\n", n);
  for (int i = 0; i < n; i++) {
    if (i > 0) putchar(' ');
    printf("%lld", a[i]);
  }
  puts("");
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

struct Combination{
    int MAX_N;
    int MOD;
    int *fac, *finv, *inv;
    Combination(int max_n,int mod): MAX_N(max_n+1),MOD(mod){ //make table
        fac = new int[MAX_N];finv = new int[MAX_N];inv = new int[MAX_N];
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for (int i = 2; i < MAX_N; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    int COM(int n,int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    void free_COM(){
        delete[] fac;
        delete[] finv;
        delete[] inv;
    }
    
};


int MOD=1000000007;
int N,M;
int X,Y;
char S[1000];
signed main(){
    scanf("%lld %lld",&X,&Y);
    Combination CB(max(X,Y),MOD);
    if((2*Y-X)%3!=0||(2*X-Y)%3!=0){
        printf("0\n");
        return 0;
    }
    int X_1=(2*Y-X)/3,X_2=(2*X-Y)/3;//X方向はi+1にx_１回進む
    printf("%lld\n",CB.COM(X_1+X_2,X_1)%MOD);
    CB.free_COM();
    return 0;
}


Measured memory_bytes: 23680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var l = p[1];
		Console.WriteLine((n-1)*(l-1));
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static long Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;

const int MAXN = 100001;
const int mod = 1000000007;

vector<int> adj[MAXN];
vector<int> bdj[MAXN];

int mxdis[MAXN];

void dfs(int x, bool vis[]){
    vis[x] = 1;
    for(int c : adj[x]){
        if(!vis[c])dfs(c, vis);
        mxdis[x] = max(mxdis[x] , mxdis[c] + 1);
    }
}

int solve(int n){
    bool vis[n+1];
    fill(vis, vis+n+1, 0);

    int ans = 0;

    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            dfs(i, vis);
        }
        ans = max(ans, mxdis[i]);
    }


    return ans;
}

int main(){
   inp_out_work
   int n, m;
   cin>>n>>m;

   fr(i,m){
    int u, v;
    cin>>u>>v;
    adj[u].pb(v);
    bdj[v].pb(u);
   }

   cout<< solve(n);

}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
int INF = 1e9+7;
using ll = long long;
int main()
{
  string s;
  cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i += 2)
  {
    if(s[i] == 'L')
    {
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 1; i < n; i += 2)
  {
    if(s[i] == 'R')
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

// typedef pair<int, int> P;
// typedef pair<int, P> PP;

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

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

int N;
int F[100];
int P[100][11];

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

	cin >> N;
	int w;
	REP(i, 0, N) {
	    F[i] = 0;
		REP(j, 0, 10) {
			cin >> w;
			if(w == 1)	F[i] |= (1 << j);
		}
	}
	REP(i, 0, N) {
	    REP(j, 0, 11) {
	        cin >> w;
	        P[i][j] = w;
	    }
	}
	
	int64 ans = -10000000000;
	int64 wk;
	int k;
	// ２の１０乗回、繰り返す（５日間の午後、午前の有無の組み合わせ）
	for(int i = (1 << 10) - 1; i > 0; i--) {
		wk = 0;
		REP(j, 0, N) {
			k = __builtin_popcount(i & F[j]);
			wk += P[j][k];
//			cout << "F[" << j << "] = " << F[j] << " i = " << i 
//					<< "  k = " << k << "  w = " << w << "  P[j][k] = " << P[j][k] << endl;
		}
//		cout << "i = " << i << "  max(" << ans << ", " << w << ")" << endl;
		ans = max(ans, wk);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll x,n;
    cin>>n>>x;
    int res;
    res=n*500;
    if(res>=x){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {

  int X , Y ;
  
  cin >> X >> Y ;
  
  int a = Y - 2*X;
  int b = 4*X - Y;
  
  if(a%2==0 && b%2==0 && a >= 0 && b >= 0){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
  
  return 0;
  
}


Measured memory_bytes: 3632
D = map(int, open(0).read().split()[:-3])
for m, f, r in zip(*[iter(D)]*3):
    if m < 0 or f < 0 or m + f < 30:
        print('F')
    elif m + f < 50 and r < 50:
        print('D')
    elif m + f < 65 or (m + f < 50 and r >= 50):
        print('C')
    elif m + f < 80:
        print('B')
    else:
        print('A')


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {

  long long int n, input;
  cin >> n;

  vector< long long int > map, flag;
  flag.push_back( 0 );
  for ( long long int i = 0; i < n; i++ ) {
    cin >> input;
    map.push_back( input );
    flag.push_back( n+1 );
  }

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

  while( q.size() > 0 ) {

    long long int k = q.front();
    q.pop();

    if ( map[k] == 0 ) {
      for ( long long int i = 1; i <= 6; i++ ) {
	long long int l = k + i;
	if ( l >= n ) break;
	if ( flag[l] > flag[k]+1 ) {
	  flag[l] = flag[k]+1;
	  q.push( l );
	}
      }

    }else {

      long long int l = k + map[k];
      if ( flag[l] > flag[k] ) {
	flag[l] = flag[k];
	q.push( l );
      }
    }

  }

  cout << flag[n-1] << endl;

  return 0;

}

Measured memory_bytes: 2924
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table.sort()
    return table

n = int(input())
ans = 0
for i in range(1, n+1, 2):
    if len(divisor(i)) == 8: ans += 1
print(ans)


Measured memory_bytes: 3060
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: f64,
        xys: [(f64, f64); n],
    }

    let ans = xys
        .into_iter()
        .filter(|(x, y)| x.powi(2) + y.powi(2) <= d.powi(2))
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 7828
using System;
using System.IO;
using System.Linq;

namespace AtCoder.R167.C
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        private static void WriteAnswer(TextWriter tw, int answer)
        {
            tw.WriteLine(answer);
        }

        private static int Parse(TextReader tr)
        {
            var w = tr.ReadLine().Split().Select(c => int.Parse(c)).ToArray();
            var n = w[0];
            var x = w[2];
            var ca = new int[n][];
            
            for (int i = 0; i < n; ++ i)
            {
                ca[i] = tr.ReadLine().Split().Select(l => int.Parse(l)).ToArray();
            }

            return Calc(x, ca);
        }

        public static int Calc(int x, int[][] ca)
        {
            var res = int.MaxValue;

            var max = 1 << ca.Length;
            
            for (var mask = 0; mask < max; ++mask)
            {
                res = Math.Min(res, Check(x, ca, mask));
            }

            return res == int.MaxValue ? -1 : res;
        }

        private static int Check(int x, int[][] ca, int mask)
        {
            var s = new int[ca[0].Length];

            for (int i = 0; i < ca.Length; ++i)
            {
                if ((mask & (1 << i)) != 0)
                {
                    for (int j = 0; j < s.Length; ++j)
                    {
                        s[j] += ca[i][j];
                    }
                }
            }

            return s.Skip(1).All(t => t >= x) ? s[0] : int.MaxValue;
        }
    }
}


Measured memory_bytes: 29224
#include <iostream>
#include <vector>
int main() {
    int N;
    int T;
    std::cin >> N;
    std::cin >> T;

    std::vector<int> c;
    std::vector<int> t;
    for (int i = 0; i < N; ++i) {
        int tmp;
        std::cin >> tmp;
        c.push_back(tmp);
        std::cin >> tmp;
        t.push_back(tmp);
    }

    int inf = (int) 1e9;
    int minCost = inf;

    for (int i = 0; i < N; ++i) {
        if (t[i] <= T) {
            minCost = std::min(minCost, c[i]);
        }
    }

    if (minCost < inf) {
        std::cout << minCost << std::endl;
    } else {
        std::cout << "TLE" << std::endl;
    }
}


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

int main(){
 int n,u,k,v;
 cin>>n;
 vector< vector<bool> > M(n,vector<bool>(n));
 for(int i=0;i<n;i++){
  cin>>u>>k;
  u--;
  for(int j=0;j<k;j++){
   cin>>v;
   v--;
   M[u][v]=true;
  }
 }

 for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
   if(j) cout<<" ";
   cout<<M[i][j];
  }
  cout<<endl;
 }
 return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e15;

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

    vector<long long int> a(3*n);
    vector<long long int> sum1(n+1), sum2(n+1);
    priority_queue<long long int, vector<long long int>, greater<long long int>> pq1;
    priority_queue<long long int> pq2;
    for(int i=0; i<3*n; i++){
        cin >> a[i];
        if(i < n){
            sum1[0] += a[i];
            pq1.push(a[i]);
        }
        if(i >= 2*n){
            sum2[n] += a[i];
            pq2.push(a[i]);
        }
    }

    for(int i=0; i<n; i++){
        pq1.push(a[n+i]);
        sum1[i+1] = sum1[i] + a[n+i] - pq1.top();
        //cout << sum1[i+1] << " = " << sum1[i] << " + " << a[n+i] << " - " << pq1.top() << endl;
        pq1.pop();

        pq2.push(a[2*n-i-1]);
        sum2[n-i-1] = sum2[n-i] + a[2*n-i-1] - pq2.top();
        pq2.pop();
    }
    long long int ans = -INF;
    for(int i=0; i<=n; i++){
        //cout << sum1[i] << " " << sum2[i] << endl;
        ans = max(ans, sum1[i] - sum2[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6516
N,M=map(int,input().split())
Hs=list(map(int, input().split()))
V=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    V[A-1].append(B-1)
    V[B-1].append(A-1)
ans=0
for n in range(N):
    Hn=Hs[n]
    for n_adj in V[n]:
        if Hn <= Hs[n_adj]:
            break
    else:
        # good
        ans+=1
        continue
    # bad

print(ans)

Measured memory_bytes: 29484
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = a1+a2+a3
n = int(input())
b = list(int(input()) for _ in range(n))

for i in b:
    if i in a :
        a[a.index(i)] = "h"

if a[0:3].count("h") == 3 or a[3:6].count("h") == 3 or a[6:9].count("h") == 3:
    print("Yes")
elif a[0] == "h" and a[4] == "h" and a[8] == "h":
    print("Yes")
elif a[2] == "h" and a[4] == "h" and a[6] == "h":
    print("Yes")
elif a[0] == "h" and a[3] == "h" and a[6] == "h":
    print("Yes") 
elif a[1] == "h" and a[4] == "h" and a[7] == "h":
    print("Yes") 
elif a[2] == "h" and a[5] == "h" and a[8] == "h":
    print("Yes") 
else:
    print("No")

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

int main(){
  int64_t N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  int a,b,c;
  int64_t ans=0;
  for(int i=0;i<N;i++){
    a=L.at(i);
    bool flag=true;
    for(int j=i+1;j<N;j++){
      b=L.at(j);
      for(int k=j+1;k<N;k++){
        c=L.at(k);
        if(a>=b+c){
          //flag=false;
          break;
        }
        if(b>=a+c){
          break;
        }
        if(c<a+b){
          ans++;
        }
      }
      if(!flag){
        flag=true;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    long total;
    cin >> N;
    total = 0;
    for(int i = 1;i <= N;i++){
        if(i % 3 != 0 && i % 5 != 0){
            total += i;
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
int main()
{
    std::string s, t;
    std::cin >> s >> t;
    ll ans = 9999999;
    ll s_max = s.size();
    ll t_max = t.size();

    for (ll i = 0; i <= s_max - t_max; ++i) {
        std::string temp1 = s.substr(i, t_max);
        ll temp_ans = 0;
        for (ll j = 0; j < t_max; ++j) {
            if (t[j] != temp1[j]) {
                ++temp_ans;
            }
        }
        ans = std::min(ans, temp_ans);
    }

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

Measured memory_bytes: 3632