akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  ll n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;

  if(a >= n && b >= n && c >= n && d >= n && e >= n) {
    cout << 5 << endl;
    return 0;
  }

  ll minNum = a;
  minNum = min(minNum, b);
  minNum = min(minNum, c);
  minNum = min(minNum, d);
  minNum = min(minNum, e);

  ull ans = (n + (minNum - 1)) / minNum;
  ans += 4;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b)
{
  return *(int*)b - *(int*)a;
}

int main(){
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i=0; i<n; i++)
  {
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), compare_int);
  int Alice = 0;
  int Bob = 0;
  for (int i=0; i<n; i++)
  {
    if (i%2==0) {
      Alice += a[i];
    } else {
      Bob += a[i];
    }
  }
    
  printf("%d\n", Alice-Bob);

  return 0;
}

Measured memory_bytes: 128
import time
ts=time.time()
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
from itertools import permutations,groupby
import sys
import bisect
import string
import random
alp=string.ascii_lowercase
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

n=I()
a=LI()
def solve(a,x):
    if a[0]*x>0:
        p=a[0]
        m=0
    else:
        p=x
        m=abs(a[0]-x)
    for i in range(1,n):
        t=-1 if p>0 else 1
        if (a[i]+p)*t>0:
            p+=a[i]
        else:
            m+=abs(a[i]+p-t)
            p+=a[i]+t*abs(a[i]+p-t)
    return m

print(min(solve(a,1),solve(a,-1)))

Measured memory_bytes: 63724
# 括弧が開いている数を左からカウント
# "("が0の状態で")"が来たらopen状態は変えずにその数をカウント・・・A
# 最終的にかっこが開いている数をカウント・・・B
# Aの数だけ"("を左端に追加
# Bの数だけ")"を右端に追加

import sys
readline = sys.stdin.readline

N = int(readline())
S = readline().rstrip()

open = 0
a = 0
for i in range(len(S)):
  if S[i] == "(":
    open += 1
  else:
    if open == 0:
      a += 1
    else:
      open -= 1

print(a * "(" + S + ")" * open)


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

if __name__ == '__main__':
    N,M,X = map(int,input().split())
    C = [0] * N
    A = list(int(i) for i in input().split())
 
    for i in range(N):
        if i in A:
            C[i] = 1

    cost = min(sum(C[X:N]),sum(C[0:X]))
    
    print(cost)

Measured memory_bytes: 3064
require 'pp'

class Solution
  def initialize
    @n, @c, @k = gets.chomp.split.map(&:to_i)
    t = []
    @n.times do
      t << gets.to_i
    end
    @a = t.sort.reverse.each_with_index.map { | x, i| [x, i] }
    @s = 0
  end

  def ok?(i)
    k = @a[@s][0] - @a[i][0]
    c = @a[i][1] - @s + 1
    return false if k > @k
    return false if c > @c
    true
  end

  def solve
    result = 0

    while @s < @n
      l = @s
      u = @n
      m = (l + u) / 2

      20.times do
        if ok?(m)
          l = m
        else
          u = m
        end
        m = (l + u) / 2
      end

      @s = m + 1
      result += 1
    end
    puts result
  end
end

solution = Solution.new
solution.solve


Measured memory_bytes: 8664
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long[] a=new long[n];
        long mul=1;
        boolean con=true;
        for(int i=0;i<n;i++){
            a[i]=sc.nextLong();
        }
        long num=1000000000000000000l;
        for(int i=0;i<n;i++){
            long ini=mul;
            mul*=a[i];
            if(mul<ini || mul>num){
                con=false;
            }
            if(a[i]==0){
                mul=0;
                con=true;
            }
        }
        if(con) System.out.println(mul);
        else System.out.println("-1");
    }
}

Measured memory_bytes: 61172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<int> water;
    for (int i = 0; i < 31; i++) { //iは操作2の回数
        if(i * B * 100 > F){
            break;
        }
        for (int j = 0; j < 31; j++) {
            if((i * B + j * A) * 100 > F){
                break;
            }
            water.push_back(i * B + j * A);
        }
    }
    sort(ALL(water));
    water.erase(unique(ALL(water)), water.end());
    int N = water.size();
    int ansW, ansS;
    ansW = water[1]; ansS = 0;
    float max_density = 0.0;
    int max_S;
    int ms;

    for (int i = 1; i < N; i++) {
        // water[i] * E と F - 100 * water[i]以下で作れるSの最大値を求める
        max_S = min(water[i] * E, F - 100 * water[i]);

        ms = 0;
        for (int i = 0; i < 1501; i++) {
            if(i * D > max_S){
                break;
            }
            ms = max(ms, i * D + (max_S - i * D) / C * C);
        }

        if( (float)100.0 * ms / (water[i] * 100.0 + ms) > max_density){
            max_density = (float)100.0 * ms / (water[i] * 100.0 + ms);
            ansW = water[i];
            ansS = ms;
        }

    }

    printf("%d %d\n", ansW * 100 + ansS, ansS);


}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);

    pair<int, int> bc[m];
    for (int i = 0; i < m; ++i) {
        int b, c;
        cin >> b >> c;
        bc[i] = {-c, b};
    }
    sort(bc, bc + m);

    int idx = 0;
    for (int i = 0; i < n;) {
        while (a[i] < -bc[idx].first && bc[idx].second) {
            a[i] = -bc[idx].first;
            bc[idx].second--;
            i++;
        }
        if (bc[idx].second) {
            break;
        }
        idx++;
    }

    long long int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1408
s = list(map(len, input().split("T")))
*x, = map(int,input().split())
x[0] -= s[0]
s = s[1:]

moveX, moveY = [], []
for i in range(len(s)):
    if i%2 == 0:
        moveY.append(s[i])
    else:
        moveX.append(s[i])
X = [x[0]]
Y = [x[1]]
for x in moveX:
    X_ = []
    for cx in X:
        X_.append(cx+x)
        X_.append(cx-x)
    X = list(set(X_))
for y in moveY:
    Y_ = []
    for cy in Y:
        Y_.append(cy+y)
        Y_.append(cy-y)
    Y = list(set(Y_))
print(["No","Yes"][0 in X and 0 in Y])


Measured memory_bytes: 4040
// AOJ 2021: Princess in Danger
// 2017.12.11 bal4u@uu

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

#define MAX 10000
typedef struct { int t, node; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x07070707

typedef struct { int to[70], t[70]; } TBL;
TBL tbl[10200];
int len[10200];
char f[101];
int dist[10200];

void dijkstra(int start)
{
	int i, s, t, e, d;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	dist[start] = 0;
	enq(start, 0);
	while (qsize) {
		s = que[0].node, t = que[0].t; deq();
		if (dist[s] < t) continue;
		for (i = 0; i < len[s]; i++) {
			e = tbl[s].to[i], d = dist[s] + tbl[s].t[i];
			if (d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
}

char buf[400], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}


int main()
{
	int n, m, l, k, a, h, i, j, ans;
	int x, y, t, u, v, u2, v2, m1;

	while (fgets(p=buf, 60, stdin) && *p != '0') {
		n = getint(), m = getint(), l = getint();
		k = getint(), a = getint(), h = getint();
		m1 = m+1;

		memset(f, 0, sizeof(f));
		f[a] = f[h] = 1;
		if (l > 0) {
			fgets(p=buf, sizeof(buf), stdin);
			while (l--) f[getint()] = 1;
		}

		memset(len, 0, sizeof(len));
		while (k--) {
			fgets(p=buf, 20, stdin);
			x = getint()*m1, y = getint()*m1, t = getint();
			for (j = t; j <= m; j++) {
				u  = x + j, v  = y + j;
				u2 = u - t, v2 = v - t;
				i = len[u]++, tbl[u].to[i] = v2, tbl[u].t[i] = t;
				i = len[v]++, tbl[v].to[i] = u2, tbl[v].t[i] = t;
			}
		}
		for (u = 0, i = 0; i < n; i++, u += m1) {
			if (!f[i]) continue;
			for (j = 0; j < m; j++) {
				v = u+j, v2 = v+1;
				t = len[v]++, tbl[v].to[t] = v2, tbl[v].t[t] = 1;
			}
		}

		dijkstra(a*m1+m);

		ans = INF; m1 *= h;
		for (i = 0; i <= m; i++) if (dist[m1+i] < ans) ans = dist[m1+i];
		if (ans == INF) puts("Help!");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 7388
s=list(input().replace('',' ').split())
cnt=0
ans=[0]*len(s)
for i in range(len(s)):
  if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
    cnt+=1
    ans[i]=cnt
  else:
    cnt=0
print(max(ans))

Measured memory_bytes: 3060
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    int A, B;
    cin >> A >> B;

    if (A < 10 && B < 10)
    {
        cout << A * B << endl;
    }
    else
    {
        cout << "-1" << endl;
    }

    return 0;
}

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

e = []
i = 1
while i * i <= n:
    if n % i == 0:
        e.append([str(i),str(n//i)])
    i += 1

ans = 10**9
for i in range(len(e)):
    ans = min(max(len(e[i][1]),len(e[i][0])),ans)
print(ans)

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

int main() {
  string s;
  cin>>s;
  int x=0;
  int p=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='S'){
      x++;
    }
    else{
      if(x>0){
        p++;
        x--;
      }
    }
  }
  cout<<s.size()-2*p<<endl;
}

Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    let mut xyz = vec![vec![0, 0, 0]];
    for (i, &a_i) in a.iter().enumerate() {
        let mut xyz_next = xyz[i].clone();
        xyz_next.sort_by_key(|&v| -v);
        for v in xyz_next.iter_mut() {
            if *v == a_i {
                *v += 1;
                break;
            }
        }
        xyz.push(xyz_next);
    }
    let mut count = 1_usize;
    for (&a_i, xyz_i) in a.iter().zip(xyz.iter()) {
        count *= xyz_i.iter().filter(|&&v| v == a_i).count();
        count %= 1_000_000_007;
    }
    let ans = count;
    println!("{}", ans);
}


Measured memory_bytes: 8864
def solve():
  ans = 0
  N, Q = map(int, input().split())
  S = input()
  plus = [0]*N
  for i in range(1,N):
    plus[i] = plus[i-1]
    if S[i-1:i+1]=='AC':
      plus[i]+=1
  ans = [0]*Q
  for i in range(Q):
    x,y = map(int, input().split())
    ans[i] = plus[y-1]-plus[x-1]
  return ans
print(*solve(),sep='\n')

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

#define MOD 1e9+7
#define ll long long int

int main(void){
	ll x,y;
	cin>>x>>y;
	int ans = 0;
	for(int i=0;x<=y;i++){
		x*=2;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
        string s, t;
        cin >> s >> t;
        int ans = t.size();
        for (int start = 0; start <= s.size() - t.size(); start++) {
                int diff = 0;
                rep(i,t.size()) {
                        if (t[i] != s[start+i]) {
                                diff++;
                        }
                }
                ans = min(ans, diff);
        }
        cout << ans << endl;
}

Measured memory_bytes: 3628
n = input()
n = int(n)

an = input().split()
an = [int(a) for a in an]

two = 0
four = 0
odd = 0

for a in an:
    if a % 2 != 0:
        odd += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1

if odd + four == n and odd-1 == four:
    print("Yes")
elif odd <= four:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include<stdio.h>

int main(void)
{ 
    int h,m,s,S;
    scanf("%d",&S);
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    printf("%d:%d:%d\n",h,m,s);

    return 0;
}


Measured memory_bytes: 2040
s = str(input())
s = list(s)
S1 = int(s[0]+s[1])
S2 = int(s[2]+s[3])

def mon(x):
    if x <= 12 and 1<=x:
        return True
    else:
        return False
    
if mon(S1) and mon(S2):
    print("AMBIGUOUS")
elif mon(S1) and not mon(S2):
    print("MMYY")
elif not mon(S1) and mon(S2):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))
dp = [0 for i in range(n)]
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
  dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),\
              dp[i-2] + abs(h[i]-h[i-2]))
print(dp[n-1])


Measured memory_bytes: 13980
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int n,k,d,a,i,j,x[110];
  scanf("%d %d\n",&n,&k);
  for(i=0;i<=n;i++){
    x[i]=0;
  }
  for(i=0;i<k;i++){
    scanf("%d\n",&d);
    for(j=0;j<d;j++){
      scanf("%d ",&a);
      x[a]=1;
    }
  }
  int ans=0;
  for(i=1;i<=n;i++){
    if(x[i]==0){
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

int main(){
    string s;
    int n,x = 0;
    cin >> n >> s;
    int ma = 0;
    for (int i = 0;i < n;i++){
        if (s[i] == 'I'){
            x++;
        }
        else if (s[i] == 'D'){
            x--;
        }
        ma = max(x,ma);
    }
    cout << ma << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int A,B;
  cin>>A>>B;
  if(A>=13) cout<<B<<endl;
  else if(A>=6) cout<<B/2<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <iostream>
typedef long long ll;
using namespace std;
char sz[15];
ll dp[15];
ll num[15];
int len;
int main(){
    scanf("%s",sz+1);
    len=(int)strlen(sz+1);
    dp[0]=0,dp[1]=sz[1]-'0';
    num[0]=1,num[1]=1;
    for(int i=2;i<=len;i++){
        for(int j=0;j<i;j++){
            num[i]+=num[j];
            ll nums=0;
            for(int k=j+1;k<=i;k++) nums=nums*10+sz[k]-'0';
            dp[i]+=(nums*num[j]+dp[j]);
        }
    }
    printf("%lld\n",dp[len]);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define re register
#define int long long
using namespace std;
int n,m,k;
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
	t=(t<<3)+(t<<1)+v-48;
	v=getchar();}
	return t;
}
signed main(){
n=read();
while(n--){
	m=read();
	if(!(m&1)){
		if(m%3==0)continue;
		if(m%5==0)continue;
		puts("DENIED");
		return 0;
	}
}
puts("APPROVED");
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val (n, m) = line.split(" ").map {it.toLong()}

    val line2 = readLine()!!.trim()
    val ary: List<Long> = line2.split(" ").map {it.toLong()}.take(m.toInt())

    val remain = n - ary.sum()
    val answer = if (remain < 0) {
        -1L
    } else {
        remain
    }

    println("${answer}")
}

Measured memory_bytes: 39628
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n' 

int n,m;
vector<int> adj[701];
int vis[701][701];
int col[701];
int pp[3];
void dfs(int no,int cc=1){
	col[no]=cc;
	pp[cc-1]+=1;
	for(auto j:adj[no]){
		if(col[j]==0){
			dfs(j,3-cc);
		}
	}
}
int dp[701][701];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int aa,bb;
		cin>>aa>>bb;
		aa--;
		bb--;
		vis[aa][bb]=1;
		vis[bb][aa]=1;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(vis[i][j]==0){
				adj[i].pb(j);
			}
		}
	}




	int cur=0;
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		if(col[i]==0){
			pp[0]=0;
			pp[1]=0;
			dfs(i);
			for(int j=pp[0];j<=n;j++){
				dp[cur+1][j]|=dp[cur][j-pp[0]];
			}
			for(int j=pp[1];j<=n;j++){
				dp[cur+1][j]|=dp[cur][j-pp[1]];
			}


			cur++;
		}
	}
		for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(vis[i][j]==1 or i==j){
				continue;
			}

			if(col[i]==col[j]){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	for(int i=n/2;i>=0;i--){
		if(dp[cur][i]==1){
			int ans=0;
			if(i>0){
				ans+=(i*(i-1))/2;

			}
			int j=n-i;
			if(j>0){
				ans+=(j*(j-1))/2;
			}
			cout<<ans<<endl;
			return 0;
		}
	}





	return 0;
}

Measured memory_bytes: 7504
N = int(input())
As = list(map(int, input().split()))

num_count = {}
count_comb = {}
num_ans = {}
sum_combs = 0

def comb2(n):
    if n not in count_comb:
        count_comb[n] = (n * (n - 1)) // 2
    return count_comb[n]

def ans(ex_num):
    ex_count = num_count[ex_num]
    return sum_combs + comb2(ex_count - 1) - comb2(ex_count)
    # if ex_num in num_ans:
    #     return num_ans[ex_num]

    # result = 0
    # for n, c in num_count.items():
    #     if n == ex_num:
    #         result += comb2(c - 1)
    #     else:
    #         result += comb2(c)
    # num_ans[ex_num] = result
    # return result


for a in As:
    if a not in num_count:
        num_count[a] = 0
    num_count[a] += 1

for _, c in num_count.items():
    sum_combs += comb2(c)

for a in As:
    print(ans(a))


Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using LLpair = pair<LL, LL>;

//#define DEBUG

int main() {
  LL a, b, c, k;
  cin >> a >> b >> c >> k;

  LL sum;
  if (a >= k) {
    sum = k;
  } else if (a + b >= k) {
    sum = a;
  } else {
    sum = a - (k - a - b);
  }
  cout << sum << endl;

  #ifdef DEBUG
    cout << a << endl;
    cout << b << endl;
    cout << c << endl;
    cout << k << endl;
  #endif
}



Measured memory_bytes: 3636
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 1000010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

char s[N];

int main()
{
	ll n,a=0,b=0,c=0,d=0;
	scanf("%s",s);
	n=strlen(s);
	REP(i,n)
	{
		if (s[i]=='N') a=1;
		if (s[i]=='S') b=1;
		if (s[i]=='W') c=1;
		if (s[i]=='E') d=1;
	}
	if (c!=d||a!=b) printf("No\n");
	else printf("Yes\n");
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

const ll mod = 1e9+7;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i) cin >> a[i];

    multiset<int> se;

    for(int i=0; i<n; ++i){
        auto itr = se.lower_bound(a[i]);
        if(itr == se.begin()) se.insert(a[i]);
        else{
            --itr;
            se.erase(itr);
            se.insert(a[i]);
        }
    }
    
    cout << se.size() << endl;

    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  string s;
  cin >> n >> s;
  auto z_algorithm = [&](string s) {
    vector<int> res(s.size());
    res[0] = s.size();
    int i = 1, j = 0;
    while(i < s.size()) {
      while(i+j < s.size() && s[j] == s[i+j]) ++j;
      res[i] = j;
      if(j == 0) {++i; continue;}
      int k = 1;
      while(i+k < s.size() && k+res[k] < j) res[i+k] = res[k], ++k;
      i += k; j -= k;
    }
    return res;
  };

  int ans = 0;
  rep(i, n) {
    string t = s.substr(i, n-i);
    auto vec = z_algorithm(t);
    rep(j, vec.size()) chmax(ans, min(j, vec[j]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N,M;
  cin >> N >> M;
  if(N%2==1){
    for(int i=0;i<M;i++){
      cout << i+1 << ' ' << N-i << endl;
    }
  }else{
    for(int i=0;i<min(M,N/4);i++){
      cout << i+1 << ' ' << N-i << endl;
    }
    if(M>N/4){
      for(int i=0;i<M-(N/4);i++){
        cout << (N/4)+2+i << ' ' << N-(N/4)-i << endl;
      }
    }
  }
  
}

Measured memory_bytes: 3588
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

inline void run(int H, int W) {
    char str[110];
    int b[110][110];
    for (int i = 0; i < H; ++ i) {
        scanf("%s", str);
        for (int j = 0; j < W; ++ j) {
            b[i][j] = (str[j] == '#' ? 1 : 0);
        }
    }
    bool h[110], w[110];
    memset(h, 0, sizeof(h));
    memset(w, 0, sizeof(w));
    for (int i = 0; i < H; ++ i) {
        for (int j = 0; j < W; ++ j) {
            if (b[i][j] == 1) {
                h[i] = 1;
                break;
            }
        }
    }

    for (int i = 0; i < W; ++ i) {
        for (int j = 0; j < H; ++ j) {
            if (b[j][i] == 1) {
                w[i] = 1;
                break;
            }
        }
    }

    for (int i = 0; i < H; ++ i) {
        if (h[i] == false) continue;
        for (int j = 0; j < W; ++ j) {
            if (w[j] == false) continue;
            cout << (b[i][j] == 1 ? '#' : '.');
        }
        cout << endl;
    }
}

int main() {
    int H, W;
    while (cin >> H >> W) {
        run(H, W);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N;
    cin >> N;
    ll dp[MAX];
    ll i, j;
    for(i=0; i<=N; i++) {
        dp[i]=INF;
    }
    
    dp[0]=0;
    
    for(j=0; j<=N; j++) {
        for(i=1; j+i<=N; i*=6) {
            dp[j+i]=min(dp[j+i], dp[j]+1);
        }
        
        for(i=1; j+i<=N; i*=9) {
            dp[j+i]=min(dp[j+i], dp[j]+1);
        }
        
    }
    
    pr(dp[N]);
    
}

























Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
	char c[22];
	int i,j;
	scanf("%s",c);
	for(i=0;c[i]!='\0';i++);
	for(j=0;j<i;j++){
		printf("%c",c[i-j-1]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[1111111], c, g[20];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	g[0] = 1; c = 0;
	while(true) {
		g[c + 1] = g[c] * 3 + 1;
		if(g[++c] >= n) break;
	}
	int ret = 0;
	for(int i = c - 1; i >= 0; i--) {
		for(int j = g[i]; j < n; j++) {
			int v = a[j], w = j - g[i];
			while(w >= 0 && a[w] > v) {
				a[w + g[i]] = a[w];
				w -= g[i];
				ret++;
			}
			a[w + g[i]] = v;
		}
	}
	cout << c << endl;
	for(int i = c - 1; i >= 0; i--) {
		if(i) cout << g[i] << ' ';
		else cout << g[i] << endl;
	}
	cout << ret << endl;
	for(int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

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

int main()
{
    string s;
    ci >> s;

    rep(i, 4) if(s[i] == '2') cnt++;

    co << cnt << en;
  
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a[102],k=0,l=0,cnt=0,x,n;
    map<int,int>m;
    string s,s1;
    cin>>i>>j;
     x=i-j*2;
     if(x<=0){cout<<"0\n";}
     else {cout<<x<<endl;}



}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int main(){
	double x1, y1, x2, y2, x3, y3, xp, yp, a, b, c;
	
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp)
	{
		a = (x2 - x1)*(yp - y1) - (y2 - y1)*(xp - x1);
		b = (x3 - x2)*(yp - y2) - (y3 - y2)*(xp - x2);
		c = (x1 - x3)*(yp - y3) - (y1 - y3)*(xp - x3);
		if ((a>0 && b>0 && c>0) || (a<0 && b<0 && c<0))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (s.equals("Cloudy")) {
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
        sc.close();
    }
}


Measured memory_bytes: 35572
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

static int n;

double calc(int day, int win)
{
	static const int cut = 30;
	static double memo[100001][cut];
	
	if(day == 0)
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < cut; ++j)
				memo[i][j] = -1;
	
	double ret = 0;
	double per = 1.0 / (1 << win);
	
	if(n == day || win >= cut)
		return 0;
		
	if(memo[day][win] != -1)
		return memo[day][win];
	
	ret += (calc(day + 1, win + 1) + 1) * per;
	ret += calc(day + 1, 0) * (1 - per);
	
	return memo[day][win] = ret;
}

int main()
{
	while(true) {
		
		scanf("%d", &n);
		
		if(n == 0)
			break;
		
		printf("%f\n", calc(0, 0));
	}
	
	return 0;
}

Measured memory_bytes: 0
/**************
*	Shell Sort
*************/

#include <cstdio>
#include <vector>	//??£?¨?
#include <algorithm>
using namespace std;
typedef vector<int> TList;	//??????????????????

void insertionSort(TList& A, int g, int& cnt ){

	for(unsigned int i=g ; i<(A.size()); i++){
		int v = A[i];
		int j = i-g;
		while(j>=0 && A[j]>v){
			A[j+g] = A[j];
			j = j-g;
			cnt++;
		}
		A[j+g] =v;
	}
	return ;
}
//---------------------------------------------------------
void shellSort(TList& A, TList& G, int& cnt){

	for(unsigned int i=0; i<(G.size()); i++){
		insertionSort(A, G[i], cnt);
	}

	return;
}
//--<<???????????¢??°>>-------------------------------------------------------
int main(){

	//??????????¨????
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	//??\???
	int n;
	scanf("%d\n",&n);
//	cin >> n;
	vector<int> A;
	A.resize(n);
	for(unsigned int i=0; i< A.size(); i++){
	//	cin >> A[i];
		scanf("%d\n", &A[i]);
	}
	
	//??????
	TList G;
//	G.reserve(100);//????????????????´???°???????????£??????????????¨????????????
	int sum = 1;
	while(sum <= n){
	    G.push_back(sum);
		sum = sum * 3 + 1;
	}
	reverse(G.begin(), G.end());

	int cnt = 0;
	shellSort(A, G, cnt);

	//??????
//	cout << G.size() << endl;
	printf("%d\n", G.size());
	for(unsigned int i=0; i<(G.size()); i++){
		printf("%d", G[i]);
//		cout << G[i];
		if(i!=(G.size()-1)){
//			cout <<" " ;
			printf(" ");
		}
	}
//	cout << endl;
	printf("\n");
	printf("%d\n", cnt);
//	cout << cnt << endl;
	for(int i=0; i< n; i++){
//		cout << A[i]<< endl;
		printf("%d\n", A[i]);
	}
	return 0;
}
//-----------------------------------------------

Measured memory_bytes: 6304
#include<iostream>
using namespace std;
int p[200000];
int main() {

	int n, k;
	cin >> n >> k;
	int i;
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}
	int max = 0;
	int sum = 0;
	for (i = 0; i < k; i++) {
		sum = sum + p[i];
	}
	max = sum;
	for (i = k; i < n; i++) {
		sum = sum + p[i] - p[i - k];
		if (sum > max)max = sum;
	}
	//cout << max + k << endl;
	double f = (double)(((double)max +(double) k) / 2);
	printf("%.10f\n", f);
	//cout << (max + k) / 2 << endl;
	return 0;

}

Measured memory_bytes: 4536
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1528
n,m,l = [int(i) for i in input().split()]
a = [[0 for i in range(m)] for j in range(n)]
b = [[0 for i in range(l)] for j in range(m)]
for i in range(n):
	a[i] = [int(j) for j in input().split()]
for i in range(m):
	b[i] = [int(j) for j in input().split()]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
	for j in range(l):
		for k in range(m):
			c[i][j] += a[i][k] * b[k][j]
for i in range(n):
	for j in range(l-1):
		print(c[i][j],end=' ')
	print(c[i][l-1])

Measured memory_bytes: 9048
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
from sys import stdin

input = stdin.readline

def solve():
    N = int(input())
    dice = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]

    for (a,b),(c,d),(e,f) in zip(dice,dice[1:],dice[2:]):
        if a==b and c==d and e==f:
            print('Yes')
            return
    print('No')



if __name__ == '__main__':
    solve()

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


def get_input() -> tuple:
    """
    標準入力の取得

    Returns:\n
        tuple: 標準入力
    """
    K = int(input())
    S = input()

    return K, S


def main(K: int, S: str) -> None:
    """
    求解処理.

    Args:\n
        K (int): 整数（1 <= K <= 100）
        S (str): 英子文字からなる文字列（1 <= |S| <= 100）
    """
    """
    文字列の長さで場合分け.
    """
    result = str()
    if len(S) <= K:
        result = S
    else:
        result = S[:K] + "..."

    # 結果出力
    print(result)


if __name__ == "__main__":
    K, S = get_input()
    main(K, S)


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

count = {"AC":0,"WA":0,"TLE":0,"RE":0}

for roop in range(N):
    judge = input()
    if judge == "AC":
        count["AC"] += 1
    elif judge == "WA":
        count["WA"] += 1
    elif judge == "TLE":
        count["TLE"] += 1
    elif judge == "RE":
        count["RE"] += 1
for roop2 in count.keys():
    print(roop2 + " x " + str(count[roop2]))
    

Measured memory_bytes: 9212
C=input()

ABC=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

ABC_len=len(ABC)

for i in range(ABC_len):
  if C==ABC[i]:
    print(ABC[i+1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
int X;
  cin>>X;
  if(X==0)
    cout<<1<<endl;
  else if(0<X&&X<100)
    cout<<0<<endl;
  else if(100<=X && X<=105)
    cout<<1<<endl;
  else{
  vector<bool>j(X+1,false);
    for(int i=100;i<=105;i++)
      j.at(i)=true;
    for(int x=106;x<=X;x++){
      j.at(x)=(j.at(x-100) ||
               j.at(x-101)||
               j.at(x-102)||
               j.at(x-103) ||
               j.at(x-104) ||
               j.at(x-105) 
                );
    }if(j.at(X))
      cout<<1<<endl;
    else
      cout<<0<<endl;
  
  
  }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();
		if(S.equals(U)){
			A--;
		}else if(T.equals(U)){
			B--;
		}
		System.out.println(A + " " + B);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include <functional>

using namespace std;
int main() {
	int n,t,sum,bef;
	sum = 0;
	bef = 0;
	cin >> n >> t;
	int cnt = n;
	for (n; n > 0; n--) {
		int a;
		cin >> a;
		sum += (a - bef < t) ? a- bef : t;
		bef = a;
	}
	sum += t;
	cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

#define gc getchar()
struct Reader {
	template <class T> inline operator T() {
		T w; char c, p = 0;
		for(; !isdigit(c = gc); c == '-' && (p = 1));
		for(w = c & 15; isdigit(c = gc); w = w * 10 + (c & 15));
		return p ? -w : w;
	}
}rd;

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;

const int N(1e5 + 5), P(1e9 + 7);
inline void inc(int &x, int y) { if ((x += y) >= P) x -= P; }

int n;
std::vector<int> g[N]; 

int f[2][N];
void dfs(int x, int fa) {
	f[1][x] = f[0][x] = 1;
	for(int y : g[x]) if (y != fa) {
		dfs(y, x);
		f[1][x] = 1ll * f[1][x] * f[0][y] % P;
		f[0][x] = 1ll * f[0][x] * (f[0][y] + f[1][y]) % P;
	}
		
}
int main() {
	n = rd;
	REP(i, 2, n) {
		int x = rd, y = rd;
		g[x].push_back(y), g[y].push_back(x);
	}
	dfs(1, 0);
	inc(f[0][1], f[1][1]);
	std::cout << f[0][1];
	return 0;
}



Measured memory_bytes: 13440
import collections
n = int(input())
li = []
for k in range(2, n+1):
  for i in range(2, int(k**0.5)+1):
    while k % i == 0:
      k //= i
      li.append(i)
  if k != 1:
    li.append(k)
c = collections.Counter(li)
ans = 1
for k, v in c.items():
  ans *= (v+1)
print(ans%(10**9+7))
    

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;

	ll both = min(x, y); x -= both, y -= both;
	ll cost = 0;

	cost += min(a + b, 2 * c) * both;
	cost += min(a, 2 * c) * x;
	cost += min(b, 2 * c) * y;

	cout << cost << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        if(m==0) {
            long[] dp = new long[n+1];
            dp[0] = 1;
            dp[1] = 1;

            for(int i = 2; i<n+1; i++) {
                dp[i] = (dp[i-1]+dp[i-2])%1000000007;
            }
            System.out.println(dp[n]);
            return;
        }


        long[] a = new long[m];
        long[] dp = new long[n+1];



        for(int i = 0; i<m; i++) {
            a[i] = sc.nextInt();
            dp[(int)a[i]] = -1;
        }
        dp[0] = 1;
        dp[1] = (a[0]==1)?0:1;

        for(int i = 2; i<n+1; i++) {
            if(dp[i]==-1) dp[i] = 0;
            else dp[i] = (dp[i-1]+dp[i-2])%1000000007;
        }
        System.out.println(dp[n]);

    }
}

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

static const int N=100;
int p[N+1];
vector<int> v;
int main(){
    int ans=0;
    int a;
    for(int i=0;i<3;i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(), v.end(), greater<int>() );
    ans+=abs(v[1]-v[0]);
    ans+=abs(v[2]-v[1]);
    cout<<ans<<endl;
   
   return 0;
}

Measured memory_bytes: 256
#1-index
from sys import stdin
from itertools import permutations
N,M,R = [int(x) for x in stdin.readline().rstrip().split()]
r = [int(x) for x in stdin.readline().rstrip().split()]
cost = [[10**9]*(N+1) for i in range(N+1)]

for i in range(M):
    A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
    cost[A][B] = C
    cost[B][A] = C
    
for k in range(N+1):
    for i in range(N+1):
        for j in range(N+1):
            cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j])
            cost[j][i] = min(cost[j][i],cost[k][i]+cost[j][k])

ans = 10**9+7

for l in permutations(r):
    ans_tmp = 0
    for m in range(R-1):
        tmp1,tmp2 = l[m],l[m+1]
        ans_tmp += cost[tmp1][tmp2]
    ans = min(ans,ans_tmp)
    
print(ans)
    

Measured memory_bytes: 43868
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


int main() {
    ll h; cin >> h;
    ll cnt = 0;
    while (h>1) {
        h /= 2;
        cnt++;
    }

    ll ans = 0;
    for (ll i=0; i<=cnt; i++) {
        ans += pow(2,i);
    }
    cout << ans << endl;
}  

Measured memory_bytes: 4076
IDENTIFICATION DIVISION.
PROGRAM-ID. 143B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP   PIC X(200).
01 N     PIC 9(2).
01 D-TBL.
   03 D  PIC 9(3) OCCURS 50. 
01 I     PIC 9(2).
01 J     PIC 9(2).
01 P1    PIC 9(3).
01 P2    PIC 9(3).
01 GK    PIC 9(8).
01 OUT   PIC Z(7)9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
*>
  ACCEPT INP.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
*> 
    MOVE INP(P1:P2 - P1) TO D(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  MOVE 0 TO GK
  PERFORM VARYING I FROM 1 BY 1 UNTIL I >= N
    COMPUTE J = I + 1
    PERFORM VARYING J FROM J BY 1 UNTIL J > N
      COMPUTE GK = GK + D(I) * D(J)
    END-PERFORM
  END-PERFORM.
*>
  MOVE GK TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 636
#include<iostream>
#include<queue>
#include<vector>
#include<cmath>
#include<complex>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define mk make_pair
#define fs first
#define sc second
#define pb push_back
using namespace std;

typedef double D;
typedef complex<D> P;
typedef pair<D,int> Edge;
typedef pair<Edge, pair<int,int> > state;

const D PI = acos(-1);
const D EPS = 1e-8;

inline D dis(D x1, D y1, D x2, D y2){
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

inline D dot(P x, P y){ return real(conj(x)*y); }

inline D base(P a,P b,P c){ return dot(b-a,c-b)/abs(b-a)/abs(c-b);}
inline D arg(P a, P b, P c){ return acos(dot(b-a,c-b)/abs(b-a)/abs(c-b)); }

int n;
D r,s;
P p[21];
D d[21][21];
vector<Edge> g[21][21];
D lensum[21][21][10001];

int main(){ 
  cin >> n >> r >> s;
  s *= PI/180;
  rep(i,n)cin >> p[i].real() >> p[i].imag();
  rep(i,n){
    d[i+1][i+1] = 0;
    for(int j=i+1;j<n;j++){
      d[i+1][j+1] = d[j+1][i+1] = abs(p[i]-p[j]);
    }
  }
  
  rep(i,n){
    if(i)g[0][1].pb(Edge(d[1][i+1],i+1));
  }

  rep(i,n){
    rep(j,n){
      if(i==j)continue;
      rep(k,n){
	if(j==k || i==k)continue;
	D seta = arg(p[i],p[j],p[k]);
	if(abs(base(p[i],p[j],p[k])-1.0)<EPS)seta = 0.0;
	else if(abs(base(p[i],p[j],p[k])+1.0)<EPS)seta = PI;
	if(seta < s + EPS){
	  g[i+1][j+1].pb(Edge(d[j+1][k+1],k+1));
	}
      }
    }
  }

  rep(i,n+1)rep(j,n+1)rep(k,10001)lensum[i][j][k] = 1e10;
  lensum[0][1][0] = 0;
  priority_queue<state,vector<state>,greater<state> > q;
  q.push(mk(mk(0,0),mk(0,1)));

  int ans = 0;
  while(q.size()){
    state tmp = q.top(); q.pop();
    D len = tmp.fs.fs;
    int carrot = tmp.fs.sc+1, prv = tmp.sc.fs, cur = tmp.sc.sc;

    rep(i,g[prv][cur].size()){
      D cost = g[prv][cur][i].fs;
      int nxt = g[prv][cur][i].sc;
      if(len + cost > r + EPS)continue;
      if(lensum[cur][nxt][carrot] > len + cost + EPS){
	lensum[cur][nxt][carrot] = len + cost;
	q.push(mk(mk(len+cost,carrot),mk(cur,nxt)));
	ans = max(ans,carrot);
      }
    }
  }	
  cout << ans << endl;
}

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

int main() {
  int N, sum=0, l=1, i;
  cin >> N;
  vector<int> b(N);
  
  for(int i=0; i<N; i++) {
    cin >> b.at(i);
  }
  
  for(i=0; i<N; i++) {
    sum++;
    l = b.at(l-1);
    if(l==2)
      break;
  }
  
  if(i==N)
    cout << -1 << endl;
  else
    cout << sum << endl;
}

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

int main(){
	string s;
	cin >> s;
	if(s == string("SUN")) cout << 7 << endl; 
	if(s == string("MON")) cout << 6 << endl; 
	if(s == string("TUE")) cout << 5 << endl; 
	if(s == string("WED")) cout << 4 << endl; 
	if(s == string("THU")) cout << 3 << endl; 
	if(s == string("FRI")) cout << 2 << endl; 
	if(s == string("SAT")) cout << 1 << endl; 
	return 0;
}


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

int main(){
    ll d,t,s;
    cin>>d>>t>>s;
    
    if(d<=t*s)cout<<"Yes";
    else cout<<"No";
    
   
    
    }



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p;
    if (p != i) {
      cnt++;
    }
  }
  
  string ans = "NO";
  if (cnt == 0 || cnt == 2) {
    ans = "YES";
  }
  
  cout << ans << endl;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

ll A, B, H, M;

int main(void) {
    cin >> A >> B >> H >> M;

    long double hh = (360 / 12) * H + (M / 60.0l * 30);
    long double mm = (360 / 60) * M;

    long double ax = cosl(hh / 360.0l * M_PIl * 2) * A;
    long double ay = sinl(hh / 360.0l * M_PIl * 2) * A;

    long double bx = cosl(mm / 360.0l * M_PIl * 2) * B;
    long double by = sinl(mm / 360.0l * M_PIl * 2) * B;

    // for (int i = 0; i < 360; i +=  30) {
    //     cout << fixed << setprecision(3) << i << '\t' << sinl(i / 360.0l * 2 * M_PIl) << '\t' << cosl(i / 360.0l * 2 *M_PIl) << endl;
    // }

    cout << fixed << setprecision(12) << sqrtl(powl(bx - ax, 2) + powl(by - ay, 2)) << endl;

    return 0;
}

Measured memory_bytes: 4112