akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e6;
    
     int mod= 1e9+7;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
   
  
      int f;
      
     void solve(){
         int n;
          cin>>n;
          
          vi v(n,0);
          
          rep(i,0,n)
             cin>>v[i];
          
          for(int i=n-1;i>0;i--){			  
			  if(v[i]<v[i-1])
			     v[i-1]--;			    
		  }
		  
		  rep(i,1,n){
			  if(v[i]<v[i-1]){
				  f++;
				  break;
			  }
		  }
		  
		  if(f)
		   cout<<"No\n";
		  else
		    cout<<"Yes\n";    
         
              
     }
   
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


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

int main(void){
  int i,a,b,temp,r,lcm;

  while(cin >> a >> b){
    if(a<b){
      temp=a;
      a=b;
      b=temp;
    }

    int x=a,y=b;

    while(b>0){
      r=a%b;
      a=b;
      b=r;
    }

    lcm=x*(y/a);
    printf("%d %d\n",a,lcm);
  }

  return 0;
}

Measured memory_bytes: 1144
quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = parse.(Int, split(readline()))

function main()
  N,M = in_a()
  A = in_a()
  @assert length(A) == M
  println(N >= sum(A) ? N - sum(A) : -1)
end

main()


Measured memory_bytes: 174020
<?php
  $n = fgets(STDIN);
  $v = explode(" ",fgets(STDIN));
  $c = explode(" ",fgets(STDIN));
  $sum = 0;

 for($i=0;$i<$n;$i++){
   $sa = $v[$i]-$c[$i];
    if($sa >0){
        $sum += $sa; 
      }
    }
  
  echo $sum;

  ?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll n,x,t;
	cin>>n>>x>>t;
	ll val=(n/x)*t;
	if(n%x) val+=t;
	cout<<val<<'\n';
	return 0;	
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3636
#!/usr/bin/env python3

N = input()

N_list = list(N)
num = []

even_0 = 0
even_1 = 0
odd_0 = 0
odd_1 = 0


for a in range(len(N_list)):
    if a % 2 == 0: #odd
        if N_list[a] == "0":
            odd_0 += 1
        elif N_list[a] == "1":
            odd_1 += 1

    elif a % 2 == 1: #even
        if N_list[a] == "0":
            even_0 += 1
        elif N_list[a] == "1":
            even_1 += 1

if max(even_0,even_1,odd_0,odd_1) == even_0:
    print(even_1 + odd_0 )

elif max(even_0,even_1,odd_0,odd_1) == even_1:
    print(even_0 + odd_1 )

elif max(even_0,even_1,odd_0,odd_1) == odd_0:
    print(even_0 + odd_1 )

elif max(even_0,even_1,odd_0,odd_1) == odd_1:
    print(even_1 + odd_0 )



    
    


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <string.h>
#include <map>

using namespace std;

int main(){

  map< char, int> ans;
  string str;
  
  while( cin >> str){
    for( int i = 0; i < str.size(); ++i){
      ++ans[str[i]];
    }
  }

  char a;
  map<char,int>::iterator itr1,itr2;
  for( int i = 0; i < 26; ++i){
    itr1 = ans.find('a'+i);
    itr2 = ans.find('A'+i);
    a = 'a' + i;
    cout << a << " : " <<  itr1->second + itr2->second << endl;
  }
  return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






long long int gcd(long long int a,long long int b)
{
 
  long long int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}

///////////////////////////
int main() {
  int n;
  cin>>n;
  vector<int> v(n),a(n);
  rep(i,n) cin>>v[i];
  a[0]=0;
  a[1]=abs(v[1]-v[0]);
  for(int i=1;i<n-1;i++){
    a[i+1]=min(a[i]+abs(v[i+1]-v[i]),a[i-1]+abs(v[i+1]-v[i-1]));
  }
  cout<<a[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstring>

typedef long long ll;

int n;
ll p[4000];
std::vector<int> ord;
bool used[4000];

int main()
{
	while( std::cin >> n, n )
	{
		memset( p, 0, sizeof( p ) );
		memset( used, false, sizeof( used ) ); 
		ord.clear();

		for( ll a, b, c, i = 0; i < n; ++i )
		{
			std::cin >> a >> b >> c;
			p[a-1] += b * c;
			ord.push_back( a - 1 );
		}

		bool fl = false;
		for( int i = 0; i != ord.size(); ++i )
			if( !used[ord[i]] && p[ord[i]] >= 1000000 )
				std::cout << ord[i] + 1 << std::endl, used[ord[i]] = true, fl = true;

		if( !fl )
			std::cout << "NA" << std::endl;
	}
	return 0;
}

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

ll h[100000];
int main() {
	ll n,a,b;scanf("%lld%lld%lld",&n,&a,&b);
	rep(i,n)scanf("%lld",&h[i]);
	ll l=0,r=INT_MAX;
	while(l!=r){
		ll t=(l+r)/2;
		ll cnt=0;
		rep(i,n){
			if(h[i]>b*t)cnt+=(h[i]-b*t)/(a-b)+!!((h[i]-b*t)%(a-b));
		}
		if(cnt<=t)r=t;
		else l=t+1;
	}
	printf("%lld\n",l);
}


Measured memory_bytes: 1024
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

ll n,m;
vi a[N];
ll dp[N];

ll solve(ll node){
	if(dp[node]!=-1)return dp[node];
	ll ans=0;
	for(auto i:a[node]){
		ans=max(ans,solve(i));
	}
	ans++;
	return dp[node]=ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	rep(i,0,N)dp[i]=-1;
	while(TESTS--)
	{
			cin>>n>>m;
			rep(i,0,m){
				ll x,y;
				cin>>x>>y;
				a[x].pb(y);
			}
			ll ans=0;	
			rep(i,1,n+1){
				ans=max(ans,solve(i));
			}
			cout<<ans-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 11868
n = gets.chomp.to_i
a = gets.chomp.split(' ').map{|i| i.to_i}
max = 0
n.times do |i|
        i + 1.upto(n - 1) do |j|
                if max < (a[i] - a[j]).abs then
                        max = (a[i] - a[j]).abs
                end
        end
end
puts max

Measured memory_bytes: 1788
//#include <cmath>
//#include <cstdio>
//#include <vector>
//#include <map>
//#include <iostream>
//#include <algorithm>
//#include <set>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vb = vector<bool>;
using pli = pair<ll,int>; 		
#define fi first
#define v vector
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
int INF = 1e9+7;
ll inf = 1e18+7;
int MOD = 1e9+7;

void add_self(auto &a, auto b){
	a += b;
	if(a >= MOD){
		a -= MOD;
	}
}

void max_self(auto &a, auto b){
	if(b > a)	a = b;
}

void topsort(int i, v<vi>& graph, vb& visit, stack<int>& res){
	visit[i] = true;
	
	for(int x : graph[i]){
		if(!visit[x])
		topsort(x,graph,visit,res);
	}
	res.push(i);
}

const int N = 1010;

ll dp[N][N];

void solve(){
	int h,w;
	cin >> h >> w;
	v<string> arr(h);
	for(int i = 0 ; i < h; ++i){
		cin >> arr[i];
	}
	dp[h][w] = 1;
	for(int i = h; i >= 1; --i){
		for(int j = w; j >= 1; --j){
			max_self(dp[i][j],(i < h && arr[i][j-1] == '.' ? dp[i+1][j] : 0) + (j < w && arr[i-1][j] == '.'? dp[i][j+1] : 0));
			if(dp[i][j] >= MOD)	dp[i][j] -= MOD;
		}
	}
	cout << dp[1][1] << endl;

}	



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	//scanf("%d",&t);
	while(t--){
		solve();
	}
		
			
}


Measured memory_bytes: 12500
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int Q = sc.nextInt();
        int[] A = new int[Q];

        int[] sdiff = new int[N + 1];
        for (int i = 0; i < Q; i++) {
            A[i] = sc.nextInt();
            sdiff[A[i]]++;
        }

        for (int i = 1; i <= N; i++) {
            int score = K + sdiff[i] - Q;
            if (score > 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

        return;
    }

}

Measured memory_bytes: 69080
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		while (read())
			solve();
	}
	
	static int W, H;
	static int[][] field;
	static boolean read() {
		W = sc.nextInt(); H = sc.nextInt();
		if (W == 0) return false;
		
		field = new int[2 * H - 1 + 2][2 * W - 1 + 2];
		for (int i = 0; i < 2 * H - 1 + 2; i++) fill(field[i], 0);
		for (int i = 0; i < 2 * H - 1 + 2; i++) field[i][0] = field[i][2 * W] = 1;
		for (int j = 0; j < 2 * W - 1 + 2; j++) field[0][j] = field[2 * H][j] = 1;		
		
		for (int i = 0; i < 2 * H - 1; i++) {
			int w = (i % 2 == 0) ? W - 1 : W;
			int a = (i % 2 == 0) ? 1 : 0;
			for (int j = 0; j < w; j++) {
				field[i + 1][2 * j + a + 1] = sc.nextInt();
			}
		}
		
		return true;
	}

	static int[] dx = {-1, 0, 1, 0};
	static int[] dy = {0, 1, 0, -1};
	static void solve() {
		Queue<State> que = new LinkedList<State>();
		que.add(new State(1, 1, 1));
		while (!que.isEmpty()) {
			State s = que.poll();
			if (field[s.y][s.x] != 0) continue;
			field[s.y][s.x] = s.s;
			for (int i = 0; i < 4; i++) {
				if (field[s.y + dy[i]][s.x + dx[i]] == 0) {
					que.add(new State(s.x + dx[i] * 2, s.y + dy[i] * 2, s.s + 1));
				}
			}
		}
		
		System.out.println(field[2 * H - 1][2 * W - 1]);
	}	
}

class State{
	int x, y, s;
	State(int x, int y, int s) {
		this.x = x; this.y = y; this.s = s;
	}
}

Measured memory_bytes: 13000
#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>;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
    
    double theta_m = m * 6;
    double theta_h = (h + m/60) * 30; 
    
    double dif_theta = abs(theta_h - theta_m);
    
    double l = a * a + b * b - 2 * a * b * cos(M_PI / 180 * dif_theta);
    //cout << cos(M_PI / 180 * dif_theta) << endl;
    double res = sqrt(l);
    
    cout << setprecision(10) << res << endl;

    return 0;
}

Measured memory_bytes: 4224
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	nextInt()

	slice := make([]string, n)
	for i := 0; i < n; i++ {
		slice[i] = nextLine()
	}

	sort.Sort(sort.StringSlice(slice))

	str := strings.Join(slice, "")
	fmt.Println(str)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
using Graph = vector<vector<int>>;
 
#define pi 3.1415926535

vector<bool> seen;
int c = 0;
void dfs(const Graph &G, int v){

  seen[v] = true;
  for(auto next_v : G[v]){
    if(seen[next_v]){
      continue;
    }
    c++;

    dfs(G, next_v);
  }
}

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

  Graph G(n);
  for (int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }

  int max = 0;
  seen.assign(n, false);

  for(int v = 0; v < n; v++){
    if(seen[v]){
      continue;
    } 
    
    c = 1;
    
    dfs(G, v);

    if(c > max){
      max = c;
    }
  }

  cout << max << endl;

  return 0; 
}

Measured memory_bytes: 23492
($h,$w)=glob<>;
@a=map[/./sg],<>;

for$i(0..$h-1){
    for$j(0..$w-1){        
        if ($a[$i][$j]eq"\#"){
            $H[$i]=1;
            $W[$j]=1;
            }
    }
}

for$i(0..$h-1){
    next if($H[$i]!=1);
    for$j(0..$w-1){
        print $a[$i][$j] if($W[$j]);
    }
    print"\n";
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
  int n, k;
  char s[11];
  scanf("%d", &n);
  scanf("%s", s);
  scanf("%d", &k);
  for (int i = 0; i < n; i++) {
    if (s[i] != s[k-1])
      s[i] = '*';
  }
  printf("%s\n", s);
}

Measured memory_bytes: 128
#pragma GCC optimize ("O2") // "Ofast" for REAL FAST
// #pragma GCC optimization ("unroll-loops")

// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#include <bits/stdc++.h>
#define DEBUG 1

using namespace std;

#define rep(i, a, b) for (i = (a); i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) (x).begin (), (x).end ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair <int, int> pii;
#define f first
#define s second
#define mp(x, y) make_pair (x, y)

typedef vector <int> vi;
#define pb(x) push_back (x)

#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  1e+6+7; // UPDATE

int main ()
{
    FASTIO;
    int i, j;
    scanf ("%d %*d %d %*d", &i, &j);
    printf ("%d\n", i != j ? 1 : 0);

    return 0;
}


Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let () =
  let a = scanf " %s" (fun s -> s) in
  let b = scanf " %s" (fun s -> s) in
  let ab = sprintf "%s%s" a b in
  let v = sscanf ab "%f" (fun v -> v) in
  let v_int = int_of_float v in
  let v_int' = let vh = int_of_float @@ sqrt v in vh * vh in
  printf "%s\n" (if v_int' = v_int then "Yes" else "No")


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int a, b, c;
int main() {
	cin >> a >> b >> c;
	if (a <= c && c <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define   LF      '\n'
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;

i64 a[1000100];

i64 f(i64 n) {
  if (n & 1) {
    return 3*n + 1;
  } else {
    return n/2;
  }
}

signed main()
{
  set<i64> U;

  int ans = 0;
  cin >> a[1];
  U.insert(a[1]);

  for (int i = 2; i <= 1000005; ++i) {
    a[i] = f(a[i-1]);

    if (U.count(a[i])) {
      ans = i;
      break;
    } else {
      U.insert(a[i]);
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int c,d,e;
  c=A+B;
  d=A-B;
  e=A*B;
  int ans;
  ans=max(max(c,d),e);
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static Map<Integer,Integer> map = new HashMap<>();
	static Set<Integer> set = new HashSet<>();
	static int count = 0;
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			map.put(i + 1, sc.nextInt());
		}
		solve(1);
	}
	static void solve(int i) {
		if(i == 2) {
			System.out.println(count);
			return;
		} else if(set.contains(i)){
			System.out.println(-1);
			return;
		}
		set.add(i);
		count++;
		int next = map.get(i);
		solve(next);
	}
}

Measured memory_bytes: 87972
import sys
sys.setrecursionlimit(10**7)
def dfs(v,c):
  for i,w in enumerate(e[v]):
    e[w].discard(v)
    c=c*dfs(w,k-i+~(v>0))%(10**9+7)
  return c
n,k,*t=map(int,open(0).read().split())
e=eval('set(),'*n)
for a,b in zip(t[::2],t[1::2]):
  e[a-1].add(b-1)
  e[b-1].add(a-1)
print(dfs(0,k))

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

int main() {
    char c; cin >> c;
    c++;
    cout << c << endl;
}

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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];

	vector<vector<int> > ans(h, vector<int> (w, -1));
	int cur = 0;

	auto solve1 = [&](int a, int b, int c, int d){
		vector<int> bp;
		bp.push_back(0);
		for(int i = a; i <= b; i++){
			for(int j = c; j <= d; j++){
				if(s[i][j] == '#') bp.push_back(i+1);
			}
		}
		bp.back() = b+1;
		for(int _ = 0; _ + 1 < (int)bp.size(); _++){
			cur++;
			for(int i = bp[_]; i < bp[_+1]; i++){
				for(int j = c; j <= d; j++){
					ans[i][j] = cur;
				}
			}
		}
	};
	vector<int> bp;
	bp.push_back(0);
	for(int j = 0; j < w; j++){
		bool has = false;
		for(int i = 0; i < h; i++){
			if(s[i][j] == '#') has = true;
		}
		if(has) bp.push_back(j+1);
	}
	bp.back() = w;
	for(int i = 0; i + 1 < (int)bp.size(); i++){
		solve1(0, h-1, bp[i], bp[i+1] - 1);
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << ans[i][j] << ' ';
		}
		cout << '\n';
	}
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int H,W;
int C[111][111];
int ans[111][111];
typedef pair<int,int> P;
typedef pair<int,P>PP;
priority_queue<PP,vector<PP>, greater<PP> >que;
int dx[4]={0,0,1,1};
int dy[4]={1,1,0,0};
bool check(int x,int y){
	if(x<0)return false;
	if(y<0)return false;
	if(x>=H)return false;
	if(y>=W)return false;
	return true;
}
int main(){
	cin>>H>>W;
	REP(i,H){
		string s;
		cin>>s;
		REP(j,W){
			if(s[j]=='#'){
				C[i][j]=1;
			}else{
				C[i][j]=0;
			}
		}
	}
	REP(i,H){
		REP(j,W){
			ans[i][j]=1e6;
		}
	}
	//ans[0][0]=C[0][0];
	que.push(PP(C[0][0],P(0,0)));
	while(que.empty()==false){
		PP p =que.top();
		que.pop();
		P pos=p.second;
		if(ans[pos.first][pos.second]<=p.first)continue;
		ans[pos.first][pos.second]=p.first;
		REP(i,4){
			int xx=pos.first+dx[i];
			int yy=pos.second+dy[i];
			if(check(xx,yy)==true){
				if(C[pos.first][pos.second]==0&&C[xx][yy]==1){
					que.push(PP(p.first+1,P(xx,yy)));
					//ans[xx][yy]=min(ans[xx][yy],p.first+1);
				}else{
					que.push(PP(p.first,P(xx,yy)));
					//ans[xx][yy]=min(ans[xx][yy],p.first);
				}
			}
		}
	}
/*	REP(i,H){
		REP(j,W){
			cout<<ans[i][j]<<" "; 
		}
		cout<<endl;
	}*/
	cout<<ans[H-1][W-1]<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  bool ok=false;
  ll c=0;
  for(ll i=0;i<n;i++){
    ll a,b;
    cin >> a >> b;
    if(a==b)c++;
    else c=0;
    if(c==3)ok=1;
  }

  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  var arr: Array[Int] = Array(-1, -1, -1)

  for(x <- 1 to 3) {
    val inputInt: Int = sc.nextInt
    arr(x - 1) = inputInt
  }

  println(arr(2) + " " + arr(0) + " " + arr(1))
}

Measured memory_bytes: 25936
// Aizu Vol-1 0135: Clock Short Hand and Long Hand
// 2017.8.3

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

int main()
{
	int i, n;
	int h, m, H, M, a, a2;

	gets(buf), n = atoi(buf);
	for (i = 0; i < n; i++) {
		gets(p = buf);
		//while (isspace(*p)) p++;
		h = (*p - '0') * 10 + (*(p+1) - '0');
		p += 3;		// hh:
		m = (*p - '0') * 10 + (*(p+1) - '0');
		M = (6 * m) << 1;
		H = (30 * h + (m >> 1)) << 1;
		if (m & 1) H++;
		if ((a = H - M) < 0) a = -a;
		a2 = 720 - a;
		if (a2 < a) a = a2;
//		printf("h %02d, m %02d, H %d, M %d, a %d, a/2 %d\n", h, m, H, M, a, a/2);
		if (a < 60) puts("alert");
		else if (a >= 180 && a <= 360) puts("safe");
		else puts("warning");
	}
	return 0;
}

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

int a[11][5];

int main() {
    int64_t n, K;
    cin >> n >> K;

    a[0][0] = (1 + 2 + 3 + 8 + 9 + 10 + 15 + 16 + 17) % 11;
    for (int i = 1; i < 5; i++) {
        a[0][i] = (a[0][i - 1] + 9) % 11;
    }
    for (int i = 0; i < 11; i++) {
        for (int j = 0; j < 5; j++) {
            a[i + 1][j] = (a[i][j] + 8) % 11;
        }
    }

    n -= 2;
    int64_t ans = 0;
    for (int i = 0; i < 11; i++) {
        for (int j = 0; j < 5; j++) {
            if (a[i][j] == K) ans += n / 11;
        }
    }
    n %= 11;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            if (a[i][j] == K) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 200005;
struct Node {
    int w, sz, sw;
    Node *f, *ch[2];
    Node(int w=0, Node *f=0) : 
	w(w), f(f) { ch[0]=ch[1]=0;sw=0;sz=1; }
    bool rc() { if(f) return f->ch[1]==this; }
    void flip() { swap(ch[0], ch[1]); sw ^= 1; }
    void down() {
	if(sw) {
	    if(ch[0]) ch[0]->flip();
	    if(ch[1]) ch[1]->flip();
	    sw = 0; 
	}
    }
    void up() {
	sz = 1;
	if(ch[0]) sz += ch[0]->sz;
	if(ch[1]) sz += ch[1]->sz;
    }
} *s;
void lk(Node *x, Node *y, int c) {
    if(x) x->f = y;
    if(y) y->ch[c] = x;
}
void rot(Node *x) {
    Node *y = x->f; int c = x->rc();
    x->down(); y->down();
    lk(x, y->f, y->rc());
    lk(x->ch[c^1], y, c);
    lk(y, x, c^1);
    y->up(); x->up();
    if(!x->f) s = x;
}
void Splay(Node *x, Node *to=0) {
    while(x->f!=to) {
	Node *y = x->f;
	if(y->f!=to) x->rc()==y->rc() ? rot(y) : rot(x);
	rot(x);
    }
}
Node *build(int l, int r, Node *f=0) {
    if(l>r) return 0;
    int mid = (l+r)>>1;
    Node *x = new Node(mid, f);
    x->ch[0] = build(l, mid-1, x);
    x->ch[1] = build(mid+1, r, x);
    x->up(); return x;
}
Node *kth(int k, Node *to=0, Node *x=s) {
    int size = 1; x->down(); // warn
    if(x->ch[0]) size += x->ch[0]->sz;
    if(k==size) return Splay(x, to), x;
    if(k<size) return kth(k, to, x->ch[0]);
    return kth(k-size, to, x->ch[1]);
}
int a[maxn];
void print(Node *x=s) {
    if(!x) return;
    x->down();
    print(x->ch[0]);
    printf("%d ", a[x->w]);
    print(x->ch[1]);
}
int main() {
    int N;
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) 
	scanf("%d", a + i);
    s = build(0, N+1); 
    for(int i=1,l,r; i<=N; ++i) {
	l = 1, r = i;
	kth(l); kth(r+2, s);
	s->ch[1]->ch[0]->flip();
    }
    kth(1); kth(N+2, s);
    print(s->ch[1]->ch[0]); puts("");
    return 0;
}


Measured memory_bytes: 13952
z=[]
inp=list(map(int,input().split()))
n=inp[0]
k=inp[1]
for i in range(k):
    inp=list(map(int,input().split()))
    z.append(inp)
z.sort()
cum=[0]*(n+1)
cum[1]=1
for i in range(2,n+1):
    ans=0
    for j in range(len(z)):
        if i-z[j][1]>=1:
            ans+=cum[i-z[j][0]]-cum[i-z[j][1]-1]
        elif i-z[j][0]>=1 and i-z[j][1]<1:
            ans+=cum[i-z[j][0]]
        else:
            break
    cum[i]=cum[i-1]+ans
    cum[i]=cum[i]%998244353
print ((cum[-1]-cum[-2])%998244353)

Measured memory_bytes: 16816
from fractions import gcd

def main():
    def fmin(m):
        return X * m + D * m *(m - 1)//2
    def fmax(m):
        return X * m + D * m * (2 * N - m - 1) // 2
    N, X, D = map(int, input().split())
    if D == 0:
        if X == 0:
            print(1)
        else:
            print(N + 1)
        exit(0)
    if D < 0:
        X, D = -X, -D
    if X == 0:
        print(fmax(N) // D + 1)
    else:
        ans = 0
        g = gcd(-X, D)
        loop = D // g
        for d in range(N + 1):
            dmax = fmax(d)
            dmin = fmin(d)
            if d < loop:
                ans += (dmax - dmin) // D + 1
            else:
                pmax = fmax(d - loop)
                pmin = fmin(d - loop)
                if pmax < dmax and pmin <= dmin:
                    mmin = max(dmin, pmax + D)
                    ans += (dmax - mmin) // D + 1
                elif pmax >= dmax and pmin > dmin:
                    mmax = min(dmax, pmin - D)
                    ans += (mmax - dmin) // D + 1
                elif pmax < dmax and pmin > dmin:
                    ans += (dmax - pmax) // D + (pmin - dmin) // D
        print(ans)

if __name__ == '__main__':
    main()

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

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

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> S(H);
  rep(i,H){cin>>S.at(i);}

  vector<vector<int>> up(H,vector<int>(W)), down(H,vector<int>(W)),left(H,vector<int>(W)),right(H,vector<int>(W));
  rep(i,H){
    rep(j,W){
      if(j==0){
        if(S.at(i).at(j)=='#'){
          left.at(i).at(j)=0;
        }
        else{
          left.at(i).at(j)=1;
        }
        if(S.at(i).at(W-1-j)=='#'){
          right.at(i).at(W-1-j)=0;
        }
        else{
          right.at(i).at(W-1-j)=1;
        }
      }
      else{
        if(S.at(i).at(j)=='#'){
          left.at(i).at(j)=0;
        }
        else{
          left.at(i).at(j)=left.at(i).at(j-1)+1;
        }
        if(S.at(i).at(W-1-j)=='#'){
          right.at(i).at(W-1-j)=0;
        }
        else{
          right.at(i).at(W-1-j)=right.at(i).at(W-j)+1;
        }
      }
      }
    }

    rep(i,H){
      rep(j,W){
        if(i==0){
          if(S.at(i).at(j)=='#'){
            up.at(i).at(j)=0;
          }
          else{
            up.at(i).at(j)=1;
          }
          if(S.at(H-1-i).at(j)=='#'){
            down.at(H-1-i).at(j)=0;
          }
          else{
            down.at(H-1-i).at(j)=1;
          }
        }
        else{
          if(S.at(i).at(j)=='#'){
            up.at(i).at(j)=0;
          }
          else{
            up.at(i).at(j)=up.at(i-1).at(j)+1;
          }
          if(S.at(H-1-i).at(j)=='#'){
            down.at(H-1-i).at(j)=0;
          }
          else{
            down.at(H-1-i).at(j)=down.at(H-i).at(j)+1;
          }
        }
        }
      }
  
  int ans=0;
      rep(i,H){
        rep(j,W){
          if(S.at(i).at(j)=='.'){
          ans=max(ans,up.at(i).at(j)+down.at(i).at(j)+left.at(i).at(j)+right.at(i).at(j)-3);
        }
      }
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 67200
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[15][15], ans[5555][15], c[22];
int main(){
    int n, m, x;
    while(cin>>n>>m>>x){
        for(int i=0; i<n; ++i){
            scanf("%d",c+i);
            for(int j=0; j<m; ++j){
            	scanf("%d",&a[i][j]);
            }
        }
        int tmp, res=1e9;
        for(int i=1; i<(1<<n); ++i){
        	int sm=0;
        	for(int j=0; j<n; ++j){
        		if(i&(1<<j)){
        			tmp=j;
        			sm+=c[j];
        		}
        	}
        	bool l=1;
        	for(int j=0; j<m; ++j){
        		ans[i][j]=ans[i-(1<<tmp)][j]+a[tmp][j];
        		if(ans[i][j]<x){
        			l=0;
        		}
        	}
        	if(l){
        		// for(int j=0; j<m; ++j){
        		// 	cout<<ans[i][j]<<" ";
        		// }
        		// cout<<sm<<endl;
        		res=min(res, sm);
        	}
        }
        if(res==1e9){
        	cout<<-1<<endl;
        }
        else{
        	cout<<res<<endl;
        }
    }
  return 0;
}




Measured memory_bytes: 4012
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
	int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
  Array.Sort(nums);
  Array.Reverse(nums);
	Console.WriteLine(nums[0]*10+nums[1]+nums[2]);//WriteLineをWriteとすると、改行なしで出力。
	}
}

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

int main(void) {
	char  S,tmp=0x00;
	int   i,N,cnt=0;

	scanf("%d",&N);
	scanf("%c",&S);//改行捨てる

	for(i=0;i<N;i++) {
		scanf("%c",&S);
		if(tmp==S) continue;
	    tmp=S;cnt++;
	}
printf("%d",cnt);
return 0;
}


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

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


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
count = 0
result = 0
for n in range(N):
    if A[n] % 2 == 0:
        An = A[n]
        count += 1
        if An % 3 == 0 or An % 5 == 0:
            result += 1
if count == result:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  string s;
  while (cin >> N >> s) {
    vector<int> p0(N, -1), n0(N, N);
    for (int i = 0; i < N; i++) {
      if (i - 1 >= 0) p0[i] = p0[i - 1];
      if (s[i] == '0') p0[i] = i;
    }
    for (int i = N - 1; i >= 0; i--) {
      if (i + 1 < N) n0[i] = n0[i + 1];
      if (s[i] == '0') n0[i] = i;
    }
    vector<int> dp(N + 1, 0);
    for (int i = 0; i < N; i++) {
      dp[i + 1] = max(dp[i + 1], dp[i]);
      int p = p0[i];
      if (p < i && p - 1 >= 0 && s[p - 1] == '1') {
        dp[i + 1] = max(dp[i + 1], dp[p - 1] + i - p);
      }
      int n = n0[i];
      if (i < n && n + 1 < N && s[n + 1] == '1') {
        dp[n + 2] = max(dp[n + 2], dp[i] + n - i);
      }
    }
    cout << dp[N] << endl;
  }
  return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    unordered_map<int, int> problems;

    bool f = true;

    int N; cin >>N;
    rep(i, N) {
        int D; cin >>D;
        problems[D]++;
    }

    int M; cin >>M;
    rep(i, M) {
        int T; cin >> T;
        if (problems[T] == 0) {
            f = false;
            break;
        }
        problems[T]--;
    }

    YES(f);
}


Measured memory_bytes: 8520
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  if (N%K != 0) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n;
int cache[N];
string s;
vector<string> v={"dream", "dreamer", "erase", "eraser"};

int dp(int idx)
{
	if(idx==n)
		return 1;
	int &ans=cache[idx];
	if(ans!=-1)
		return ans;
	ans=0;
	for(auto &it:v)
	{
		int sz=it.size();
		int newidx=idx + sz;
		if(newidx>n)
			continue;
		if(s.substr(idx, sz)!=it)
			continue;
		ans|=dp(newidx);
	}
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>s;
	n=s.size();
	int ans=dp(0);
	if(ans)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


Measured memory_bytes: 3152
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, s, h = 0, t = 0, now, ans = 1000000;
  scanf("%lld%lld", &n, &s);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  now = a[0];
  while( 1 ) {
    if(now < s) {
      if(t == n - 1) break;
      t++;
      now += a[t];
    } else {
      if(t - h + 1 < ans) ans = t - h + 1;
      now -= a[h];
      h++;
    }
  }
  if(ans == 1000000) printf("0\n");
  else printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3516
import numpy as np
box_size = list(map(int, input().split())) 
fill_num = list(map(int, input().split())) 
 
box = np.array([[1]*box_size[1]]*box_size[0])
for r in range(fill_num[0]):
    box[r,:] = 0
for c in range(fill_num[1]):
    box[:,c] = 0
print(np.sum(box))

Measured memory_bytes: 13492
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    const char *Possible = "Possible";
    const char *Impossible = "Impossible";

    int A, B;
    if (scanf("%d%d", &A, &B) < 2) return 0;

    if (A % 3 == 0) printf("%s\n", Possible);
    else if (B % 3 == 0) printf("%s\n", Possible);
    else if ((A + B) % 3 == 0) printf("%s\n", Possible);
    else printf("%s\n", Impossible);

    return 0;
}


Measured memory_bytes: 128
input()
nums = [int(x) for x in input().split()]

div_count = 0
while True:
  includesOdd = False in [x % 2 == 0 for x in nums]
  if includesOdd:
    break
  nums = [x / 2 for x in nums]
  div_count += 1
print(div_count)

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

#define ll long long
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

int main() {
	int n, i, j;
	cin >> n;
	ll dp[n], a[n];
	fo(i, n) cin >> a[i], dp[i] = a[i];
	Fo(i, 1, n) fo(j, (n - i)) dp[j] = max(a[i + j] - dp[j], a[j] - dp[j + 1]);
	cout << dp[0];
	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

ll mod = 1e9+7;
ll dp[110][5][5][5];

int main() {
    int n; cin >> n;
    memset(dp, 0, sizeof(dp));
    dp[0][0][0][0] = 1;
    rep(i,n) rep(j,5) rep(k,5) rep(l,5) repf(m,1,5) {
        // dp[i][j][k][l]...[m]
        // 1A, 2C, 3G, 4T
        if (k==1 && l==3 && m==2) continue;
        if (k==1 && l==2 && m==3) continue;
        if (k==3 && l==1 && m==2) continue;
        if (j==1 && l==3 && m==2) continue;
        if (j==1 && k==3 && m==2) continue;
        (dp[i+1][k][l][m] += dp[i][j][k][l]) %= mod;
    }
    ll ans = 0;
    rep(i,5) rep(j,5) rep(k,5) {
        (ans += dp[n][i][j][k]) %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int w=stdIn.nextInt();
		int h=stdIn.nextInt();
		int x=stdIn.nextInt();
		int y=stdIn.nextInt();
		int r=stdIn.nextInt();
		if(0<=x-r&&x+r<=w&&0<=y-r&&y+r<=h){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, 0, n) {
    cin >> p[i];
  }

  int ans = 0;

  rep(i, 1, n -1) {
    int MAX, MIN;
    MAX = max(p[i - 1], p[i + 1]);
    MIN = min(p[i - 1], p[i + 1]);
    if (MIN <= p[i] && p[i] <= MAX) {
      ans+=1;
    }
  }
  cout << ans << endl;
};


Measured memory_bytes: 256
S=input()
ans=0
for i in range(2**(len(S)-1)):#どこに+を入れるのか、隙間はlen(s)-1であるからこうなっている
    tmp=S[0]#tmpという配列に+を含めて、evalで計算する方針
    for j in range(len(S)-1):
        if (i>>j)&1:tmp+="+"#iビット目が1であれば+を追加
        tmp+=S[j+1]#更に次の文字を追加、j+1なのはもともと0を加えていたため
    ans+=eval(tmp)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy";
    }else if(s=="Cloudy"){
        cout<<"Rainy";
    }else{
        cout<<"Sunny";
    }
    return 0;
}


Measured memory_bytes: 256
def p(h,w):
    try:
        if h >= 0 and h<= H and w >= 0 and w <= W:
            S[h][w] += 1
    except:
        None

H,W = map(int,input().split())
S = [[0 if i == "." else "#" for i in input()] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            p(i+1, j)
            p(i+1, j+1)
            p(i+1, j-1)
            p(i-1, j)
            p(i-1, j+1)
            p(i-1, j-1)
            p(i, j+1)
            p(i, j-1)
            '''
            for k in S:
                a = list(map(str, k))
                print("".join(a))
            print()
            '''
        else:
            None
for k in S:
    a = list(map(str,k))
    print("".join(a))

Measured memory_bytes: 3064
open System
open System.Collections
open System.Collections.Generic
open System.IO
open System.Text
open System.Text.RegularExpressions
open Microsoft.FSharp.Reflection

let read() = Console.ReadLine()
let readsInt() = read().Split() |> Array.map int

[<EntryPoint>]
let main _ = 
    let l1 = readsInt() 
    let H = l1.[0] 
    let W = l1.[1] 
    let D = l1.[2] 
    
    let xIdx = Array.zeroCreate (H*W)
    let yIdx = Array.zeroCreate (H*W)
    for i in 0..H-1 do
        let mutable j = 0
        readsInt() |> Array.iter (fun a ->
            xIdx.[a-1] <- i
            yIdx.[a-1] <- j
            j <- j + 1)

    let dp = Array.zeroCreate (H*W)
    for i in D..(H*W-1) do
        dp.[i] <- dp.[i-D] 
                + abs (xIdx.[i-D]-xIdx.[i]) 
                + abs (yIdx.[i-D]-yIdx.[i])

    let Q = read() |> int
    for i in 0..Q-1 do
        let t = readsInt()
        printfn "%i" <| dp.[t.[1]-1]-dp.[t.[0]-1]
        
    0



Measured memory_bytes: 17964
N = int(input())
ls = [i+1 for i in range(N)]

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))
    return table
ii = 0
for i in ls:
    if i % 2== 0:
        continue
    else:
        if len(divisor(i)) == 8:
            ii += 1
print(ii)

Measured memory_bytes: 62120
import math
from itertools import permutations

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

ret = 0
cnt = 0
for i in permutations(xy):
    for j in range(N-1):
        x = (i[j][0] - i[j+1][0]) ** 2
        y = (i[j][1] - i[j+1][1]) ** 2
        ret += math.sqrt(x+y)
    cnt += 1
print(ret/cnt)



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

int main(){
    int N;cin>>N;
    vector<ll> a(N),b(N),c(N);
    for(int i=0;i<N;i++)cin>>a.at(i);
    for(int i=0;i<N;i++)cin>>b.at(i);
    for(int i=0;i<N;i++)cin>>c.at(i);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll p,q;
    ll ans=0;
    for(int i=0;i<N;i++){
        auto itr=lower_bound(a.begin(),a.end(),b.at(i));
        p=itr-a.begin();
        itr=upper_bound(c.begin(),c.end(),b.at(i));
        q=c.end()-itr;
        ans+=p*q;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    sort(all(A));
    vector<ll> D(A.at(N-1)+1);
    rep(i, N){
      ll c = A.at(i);
      while (c <= A.at(N-1)){
        D.at(c)++;
        c += A.at(i);
      }
    }
    ll ans = 0;
    rep(i, N){
      if(D.at(A.at(i)) == 1){
        ans++;
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12704
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
        c: usize,
        d: usize,
        e: usize,
    }
    let mut v = vec![a, b, c, d, e];
    v.sort();
    println!("{}", 4 + (n as f64 / v[0] as f64).ceil() as usize);
}


Measured memory_bytes: 4352
# include<iostream>
# include <math.h>

using namespace std;

int main(){
    int k,a,b;
    cin >> k >> a >> b;
  	int l = (b/k)*k;
    if (a <= l){
        cout << "OK\n";
    }
    else{
        cout << "NG\n";
    }

    return 0;
}

Measured memory_bytes: 3596
module A
  sub main(byval args() as string)
    dim s,t,u,arr() as string
    dim a,b as integer
    arr=split(console.readline())
    s=arr(0):t=arr(1)
    arr=split(console.readline())
    a=arr(0):b=arr(1)
    u=console.readline()
    console.writeline(if(u=s, _
          (a-1) & " " & b , _
          a  & " " & (b-1) ))
  end sub
end module

Measured memory_bytes: 20304
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int w=0,e=0,N=0;
	char S[500000];

	scanf("%d",&N);
	scanf("%s",S);

	int i;
	int min = N;

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

		if(S[i]=='W'){w++;}
		else{e++;}

	}

	int Lw=0,Re=e;

	for(i=0;i<N;i++){
		
		if(S[i]=='W'){
			
			if(Lw+Re<min){
				min = Lw + Re;
			}
			
			Lw++;}
		
		else{
			Re--;
			
			if(Lw+Re<min){
				min = Lw + Re;
			
			}
		}
		
	}
	
	printf("%d", min);

	return 0;
}


Measured memory_bytes: 512