akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> a(3 * N);
    rep(i, 3 * N) cin >> a[i];
    
    sort(a.rbegin(), a.rend());
    long long ans = 0;
    rep(i, N) {
        ans += a[2 * i + 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
n = int(input())
a = list(map(int, input().split()))
mapa = {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}
el = 0
for i in range(n):
    if a[i] < 400:
        mapa[1] += 1
    elif a[i] < 800:
        mapa[2] += 1
    elif a[i] < 1200:
        mapa[3] += 1
    elif a[i] < 1600:
        mapa[4] += 1
    elif a[i] < 2000:
        mapa[5] += 1
    elif a[i] < 2400:
        mapa[6] += 1
    elif a[i] < 2800:
        mapa[7] += 1
    elif a[i] < 3200:
        mapa[8] += 1
    else:
        el += 1
count = 0
for i in mapa:
    if mapa[i] > 0:
        count += 1
if count > 0:
    print(str(count) + ' ' + str(count + el))
else:
    print('1 ' + str(el))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

const int mx=200005;

bool is_prime[mx];
vector<int> prime;

void makeprime(int n){
    is_prime[0]=is_prime[1]=1;
    for(int i=2;i<=n;i++){
        if(!is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j]=1;
            }
        }
    }
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    makeprime(mx);
    while(1){
        int n,p; cin >> n >> p;
        if(n==-1&&p==-1)break;
        vector<int> a;
        for(int i=n+1;i<mx;i++){
            if(!is_prime[i]){
                a.push_back(i);
            }
            if(a.size()==p)break;
        }
        vector<int> v;
        for(int i=0;i<p;i++){
            for(int j=i;j<p;j++){
                v.push_back(a[i]+a[j]);
            }
        }
        sort(v.begin(),v.end());
        printf("%d\n",v[p-1]);
    }
}


Measured memory_bytes: 3524
#include<iostream>
using namespace std;
int main() {
	int i, j, H, W;
	while (1) {
		cin >> H >> W;

		if (H == 0&&W==0) { break; }

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main()
{
    string a;
    string b;
    int s=0;
    cin>>a;
    cin>>b;
   
   if(a[0]==b[0])
   s=s+1;
   if(a[1]==b[1])
   s=s+1;
   if(a[2]==b[2])
   s=s+1;
   
   
   cout<<s;
   
    

    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int64_t> a(n);
  for (auto&& e : a) cin >> e;
  int cnt(0);
  int64_t m(1000000000);
  int64_t ans(0);
  for (int i = 0; i < n; i++) {
    if (a[i] < 0) {
      ans -= a[i];
      cnt++;
      m = min(m, -1 * a[i]);
    } else {
      ans += a[i];
      m = min(m, a[i]);
    }
  }
  if (cnt % 2 != 0) {
    ans -= m * 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
H, W = map(int, input().split())
graph = []
for _ in range(H):
    graph.append(input())

dist = [[0 for _ in range(W)] for _ in range(H)]

que = [[0, 0]]
distance = 0
while len(que) > 0:
    h, w = que.pop(0)
    if h == H - 1 and w == W - 1:
        distance = dist[h][w]
        break
    for a, b in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
        ht, wt = h + a, w + b
        if 0 <= ht < H and 0 <= wt < W and graph[ht][wt] == "." and dist[ht][wt] == 0:
            dist[ht][wt] = dist[h][w] + 1
            que.append([ht, wt])

if distance == 0:
    print(-1)
    exit()

total = W * H - 1
for g in graph:
    total -= g.count("#")
print(total - distance)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>

int main()
{
int n;
std::string s;
std::string t;
std::cin >> n >> s >> t;
int len = n * 2;
int flag = 0;
for(int i = 0; i < n; i++){
    flag = 0;
    if(s[i] == t[0]){
        for(int j = 0; j < n - i; j++){
            if(s[i + j] != t[j]){
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            len = i + n;
            break;
        }
    }
}
std::cout << len << std::endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  int A,B;
  char op;
  cin >> A >> op >> B;
  if (op == '+'){
    cout << A  + B << '\n';
  }
  if (op == '-'){
    cout << A  - B << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
# クソコードすぎる
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N==1:
    if K%2==1:
        print(A[0])
    exit()
L = [-1] * (2*10**5+2)  # aを入れてindexを返す
Plus = [0]*N  # indexを入れて1か0
Next = [0]*N  # indexを入れてindex
for i, a in enumerate(A):
    l = L[a]
    if l==-1:
        L[a] = i
    else:
        Next[l] = i+1
        L[a] = i

if l!=-1:
    Next[l] = 0
    Plus[l] = 1
#print(Next)

for i, a in enumerate(A):
    l = L[a]  # あなたはどこから来たの
    if i <= l:
        Next[l] = i+1
        Plus[l] += 1
        L[a] = -1


#
# print(Next)
# print(Plus)

loop = Plus[0]
i = Next[0]
while i!=0:
    i_next = Next[i]
    if i_next==N:
        loop += 1
        i_next = 0
    #if i_next <= i:
    #    loop += 1
    loop += Plus[i]

    i = i_next
#
# print(loop)

TrueNext = Next.copy()
for i in range(N-1,-1,-1):
    p = Plus[i]
    if p==0:
        nn = TrueNext[i]
        if nn==N:
            nn = 0
        TrueNext[i] = TrueNext[nn]
#
# print(TrueNext)

k = K % loop
if k==0:
    exit()

start = 0
i=0
while i<k-1:
    if start==N:
        start=0
        i+=1
    if i==K-1:
        break
    start = TrueNext[start]
    i+=1
# print(start)

ans = []#[A[start]]
S = [0] * (2*10**5+2)
#S[ans[0]] = 1
for a in A[start:]:
    #print(a, ans)
    if S[a]==0:
        ans.append(a)
        S[a] = 1
    else:
        while S[a] != 0:
            a_ = ans.pop()
            S[a_] = 0
print(*ans)


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

using namespace std;

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<vector<int>> a(n,vector<int>(m));
    vector<int> b(m);
    
    rep(i,m) cin>>b[i];
    rep(i,n) rep(j,m) cin>>a[i][j];
    
    int cnt=0;
    rep(i,n){
        int sum=c;
        rep(j,m){
            sum+=a[i][j]*b[j];
        }
        if(sum>0) cnt++;
    }
    
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3560
public class Main {
	public static void main(String[] args){
		int a,b,c;

		for(a=1;a<10;a++){
			for(b=1;b<10;b++){
				c = a * b;
				System.out.println(a +"x"+ b+"="+c);
			}
		}
	}

}


Measured memory_bytes: 24176
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define bug puts("--------------")
const int N = 1e5 + 10;
using namespace std;
int dp[120][120];
int a[120];	
int k;
int dfs(int pos,int sta,int lead,int limit){
	if(pos == -1) return sta == k;
	if(!lead&&!limit&&dp[pos][sta]!=-1) return dp[pos][sta];
	int up = limit?a[pos]:9;
	int tmp = 0;
	for(int i = 0;i <= up;++i){
		if(lead&&i == 0) tmp += dfs(pos - 1,sta,lead,limit&&i == a[pos]);
		else tmp += dfs(pos-1,sta + (i == 0?0:1),lead&&i == 0,limit&&i == a[pos]);
	}
	if(!limit&&!lead) dp[pos][sta] = tmp;
	return tmp;
}
int main(){
	string s;
	cin >> s;

	cin >> k;
	int l = s.size();
	int pos = 0;
	memset(dp,-1,sizeof dp);
	for(int i = l-1;i >= 0;-- i){
		a[pos++] = s[i] - '0';
	}
	cout<<dfs(pos-1,0,1,1);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>

using namespace std;

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

string A, B, C;
bool flag = false;
char t;

void turn() {

    switch (t) {
    case 'a':
        if (A.empty()) {
            cout << 'A' << endl;
            flag = true;
            break;
        }
        t = A[0];
        A.erase(0, 1);
        return;

    case'b':
        if (B.empty()) {
            cout << 'B' << endl;
            flag = true;
            break;
        }
        t = B[0];
        B.erase(0, 1);
        return;

    case'c':
        if (C.empty()) {
            cout << 'C' << endl;
            flag = true;
            break;
        }
        t = C[0];
        C.erase(0, 1);
        return;
    }
    return;
}

int main() {

    cin >> A >> B >> C;
    
    t = A[0];
    A.erase(0, 1);
    while (true) {
        if (flag)break;
        turn();
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    long gcd = gcd(A, B);
    System.out.println(A / gcd * B);
  }

  static long gcd(long i, long j) {
    if (i > j) return gcd(j, i);
    while (i > 0) {
      long r = j % i;
      j = i;
      i = r;
    }
    return j;
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[1000],n,m,k,h=0,b;
	scanf("%d",&n);
	for(k=1;k<=n;k++)
	{
		scanf("%d",&a[k]);
	}
	if(n>=3)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				b=abs(a[i]-a[j]);
				if(b>h)
				{
					h=b;
				}
			}
		}
		printf("%d",h);
	}
	else
	{
		if(a[1]>=a[2])
		{
			m=a[1]-a[2];
		}
		else if(a[2]>a[1])
		{
			m=a[2]-a[1];
		}
		printf("%d",m);
	}
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ



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

  for (int i = 1; i < n; i++){
    if (i != 1){
      dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }else{
      dp[i] = dp[i-1]+abs(h[i-1]-h[i]);
    }
  }

  cout << dp[n-1] << '\n';
  return 0;
}

Measured memory_bytes: 3952
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
long long sum;
int a[1005];
int i;
int main()
{
	int n;
	scanf("%d",&n);
	for (i=1;i<=2*n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+2*n+1);
	for (i=1;i<=n;i++){
		sum=sum+a[i*2-1];
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N - 1)]

tree = [[] for _ in range(N)]

for i in range(N - 1):
    tree[A[i] - 1].append(i + 1)

order = [0]
visited = [0 for _ in range(N)]
visited[0] = 1
stack = [0]

while stack:
    node = stack.pop()
    for adj in tree[node]:
        order.append(adj)
        stack.append(adj)

depth = [0 for _ in range(N)]

for node in order[::-1]:
    subdep = []
    for adj in tree[node]:
        subdep.append(depth[adj])
    subdep.sort()
    for s in subdep:
        depth[node] = max(depth[node] + 1, s + 1)

print(depth[0])

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) cin >> s[i];

	vector<int> di = { 1,0,-1,0 };
	vector<int> dj = { 0,1,0,-1 };

	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') continue;
			vector<vector<int>> dist(h, vector<int>(w, INT_MAX));
			queue<pair<int, int>> q;
			auto update = [&](int i, int j, int x) {
				if (dist[i][j] != INT_MAX) return;
				dist[i][j] = x;
				q.push(make_pair(i, j));
			};
			update(i, j, 0);
			while (!q.empty()) {
				int i = q.front().first;
				int j = q.front().second;
				q.pop();
				for (int dir = 0; dir < 4; dir++) {
					int ni = i + di[dir];
					int nj = j + dj[dir];
					if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
					if (s[ni][nj] == '#') continue;
					update(ni, nj, dist[i][j] + 1);
				}
			}
			for (int k = 0; k < h; k++) {
				for (int l = 0; l < w; l++) {
					if (dist[k][l] == INT_MAX) continue;
					ans = max(ans, dist[k][l]);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int maxn = 1e5 + 500;
int main() {
	ll a, b, c, x, y;
	while (~scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y)) {
		ll ans = x*a + y*b;
		ll MIN = min(x, y);
		ll MAX = max(x, y);
		ans = min(ans, 2 * MIN*c + (x - MIN)*a + (y - MIN)*b);
		ans = min(ans, 2 * MAX*c);
		cout << ans << endl;
	}
	return 0; 
}



Measured memory_bytes: 256
N, K = list(map(int, input().split(' ')))

table = {l for l in range(1, N + 1)}
have = set()

for i in range(K):
    d = int(input())
    nums = list(map(int, input().split(' ')))
    have = have | set(nums)

ans = len(table - have)

print(ans)

Measured memory_bytes: 67928
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define ceil(a,b) (((a)+(b)-1)/(b))
#define dist(a,b) max((a)-(b),(b)-(a))
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}



int main(){
  int n,k; cin >>n >>k;
  int m=n;
  double ans=0,p=1;
  while(k){
    if(n>=k){
      ans+=(n-k+1)*p;
      n=k-1;
    }
    p/=2.0;
    if(k<=1) break;
    k=ceil(k,2);
    if(df)print(k);
  }
  printf("%.15lf\n",ans/m);
}





Measured memory_bytes: 3712
#include<stdio.h>
int main(){
 int n,k;
 scanf("%d%d",&n,&k);
 int a[k][n],d[k],b[n];
 int i,j;
  
 for(i=0;i<n;i++)
   b[i]=0;
 
 for(i=0;i<k;i++){
  scanf("%d ",&d[i]);
  for(j=0;j<d[i];j++){
   scanf("%d",&a[i][j]);
   b[a[i][j]-1]++;
  // printf("%d %d\n",a[i][j],b[a[i][j]-1]);
  }
 }
 
 int ans=0;
  for(j=0;j<n;j++){
//   printf("%d %d\n",j,b[j]);
   if(b[j]==0)ans++;}
 
     
 printf("%d\n",ans);
  
  
return 0;}

Measured memory_bytes: 1740
int main(void){
   int N,i;
   int a=0;
   char s[100];
   scanf("%d",&N);
   for(i=0;i<N;i++){
        scanf("%s",&s[i]);
        if(s[i]=='Y'){
            a=1;
        }
    }
        if(a==1){
            printf("Four");
    }
        else{
            printf("Three");
    }
  }
  

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bellman_ford(N: int, edges: list, src: int) -> list:
    """ ベルマンフォード(頂点数, 辺集合(0-indexed), 始点) """

    # 頂点[ある始点からの最短距離] (経路自体を知りたい時はここに前の頂点も持たせる)
    res = [INF] * N
    res[src] = 0
    # 各辺によるコストの置き換えを頂点数N-1回繰り返す
    for _ in range(N-1):
        for u, v, cost in edges:
            if res[v] > res[u] + cost:
                res[v] = res[u] + cost
    tmp = res[:]
    # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする
    for _ in range(N-1):
        for u, v, cost in edges:
            if res[v] > res[u] + cost:
                res[v] = res[u] + cost
    for i in range(N):
        if tmp[i] != res[i]:
            res[i] = -INF
    return res

N, M = MAP()
edges = []
for i in range(M):
    a, b, c = MAP()
    a -= 1; b -= 1
    edges.append((a, b, -c))

res = bellman_ford(N, edges, 0)

if res[N-1] != -INF:
    print(-res[N-1])
else:
    print('inf')


Measured memory_bytes: 3444
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int fie[5000][5000];
int main(){

    long long int A,B,C,D;
    cin>>A>>B>>C>>D;
    /*
    fie[A][B][0]={1};
    for(int i=A;i<=C;i++){
        for(int j=B;j<=D;j++){
            for(int k=0;k<2;k++){
                //if(i==A&&j==B&&k==0)continue;
                if(k==0){
                    fie[i+1][j][1]+=fie[i][j][k]*j;
                    fie[i][j+1][0]+=fie[i][j][k]*(i-1);
                    fie[i][j+1][1]+=fie[i][j][k];
                }
                if(k==1){
                    fie[i+1][j][1]+=fie[i][j][k]*j;
                    fie[i][j+1][1]+=fie[i][j][k]*(i-1);
                    fie[i][j+1][2]+=fie[i][j][k];
                }
                if(k==0){
                    fie[i+1][j][1]+=fie[i][j][k]*j;
                    fie[i][j+1][2]+=fie[i][j][k]*(j-1);
                    fie[i][j+1][2]+=fie[i][j][k];
                }
            }
        }
    }
    cout<<fie[C][D][0]+fie[C][D][1]+fie[C][D][2]<<endl;
    */

    fie[A][B]=1;
    for(long long int i=A;i<=C;i++){
        for(long long int j=B;j<=D;j++){
            if(i==A&&j==B)continue;
            fie[i][j]=(fie[i-1][j]*j+fie[i][j-1]*i-(i-1)*(j-1)*fie[i-1][j-1])%998244353;
            //printf("fie[%d][%d]=[%lld]+[%lld]-[%d]=[%d]\n",i,j,fie[i-1][j]*j,fie[i][j-1]*i,(i-A)*(j-B),fie[i][j]);
            //printf("hoge");
            fie[i][j]=(fie[i][j]+(long long int)998244353)%(long long int)998244353;
        }
    }

    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            //printf("[%lld]",fie[i][j]);
        }
        //cout<<endl;
    }

    cout<<fie[C][D]<<endl;

    /*
    long long int ans=1;
    while(1){
        if(A<C&&B<D){
            ans*=A*B+A+B;
            A++;
            B++;
            ans%=998244353;
        }
        else if(A<C){
            A++;
            ans*=B;
            ans%=998244353;
        }
        else if(B<D){
            B++;
            ans*=A;
            ans%=998244353;
        }
        else{
            break;
        }
    }
    cout<<ans<<endl;
*/
    return 0;
}


Measured memory_bytes: 85824
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	char ch = 0;
	for (int i = 0; i < N; ++i) {
		if (S[i] != ch) {
			ch = S[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  print
   . maximum
   . map sum
   . group
   . map trans01 =<< getLine

trans01 c
  |(or . map (==c)) "ACGT" = 1
  |otherwise               = 0

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


template<class T>
void show_1d_vector(const vector<T> &v){
    for(auto v1: v) {
        cout << v1 << " ";
    }
    cout << endl;
}

vector<vector<int>> graph;
vector<int> ans;

int bfs(int n, int st){
    vector<int> visited(n,-1);
    queue<int> q;
    int start = st;
    q.push(start);
    visited[start] = 0;
    int ret = 0;
    while(!q.empty()){
        int now = q.front();
        q.pop();

        for(int i = 0; i < graph[now].size(); i++){
            int next = graph[now][i];
            if(visited[next] == -1){
                q.push(next);
                visited[next] = visited[now] + 1;
            }
        }
    }
    for(int i = 0; i < n; i++){
        ans[visited[i]]++;
    }
}


int main(){
    int n , x, y;
    cin >> n >> x >> y;
    x--; y--;
    graph.resize(n);
    ans.resize(n);

    for(int i = 0; i < n; i++){
        ans [i] = 0;
    }
    for(int i = 0; i < n-1; i++){
        graph[i].push_back(i+1);
        graph[i+1].push_back(i);
    }
    graph[x].push_back(y);
    graph[y].push_back(x);

    for(int i = 0; i < n; i++){
        bfs(n, i);
    }
    for(int i = 1; i < n; i++){
        cout << ans[i]/2 << endl;

    }

    return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25
/*
input case
output case
*/

string S;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    bool n = false,w = false,s = false,e = false;
    rep(i,S.size()){
        if (S[i] == 'N'){
            n = true;
        }else if (S[i] == 'W'){
            w = true;
        }else if (S[i] == 'S'){
            s = true;
        }else if (S[i] == 'E'){
            e = true;
        }
    }

    if ((w and e) or (!w and !e)){
        if ((n and s) or (!n and !s)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++ 
signed main() {
	int ma=1,x;
	cin>>x;
	for(int i=2;i<x;i++){
		int k=i*i;
		for(int j=2;k<=x;j++){
			ma=max(ma,(int)pow(i,j));
			k*=i;
		}
	}
	cout<<ma<<endl;
}


Measured memory_bytes: 256
N,T= gets.split.map(&:to_i)

costmin = 10**9

N.times do
  c,t = gets.split.map(&:to_i)

  if t <= T && costmin > c
    costmin = c
  end
end

if costmin < 10**9
  puts costmin
else
  puts "TLE"
end


Measured memory_bytes: 3836
#include <bits/stdc++.h> 
using namespace std; 
#define int int64_t
int a, b;

int32_t main() 
{ 
    	ios_base::sync_with_stdio(0);   cin.tie(0);     cout.tie(0);
    	cin >> a >> b;
    	cout << (b % a ? b - a : a + b);
	return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

struct node
{
	int key;
	node* lc, * rc;
};

node* root = 0;

void insert(int x)
{
	node* pre = root;        //设当前节点为根，以根为起点
	node* temp = pre;        //用来保存当前节点的临时指针

	node* in = (node*)malloc(sizeof(node));
	in->key = x;
	in->lc = 0;     
	in->rc = 0;     

	while (pre != 0)
	{
		temp = pre;
		if (in->key < pre->key)
			pre = pre->lc;
		else
			pre = pre->rc;
	}
	pre = temp;

	if (pre == 0)
		root = in;
	else
	{
		if (in->key < pre->key)
			pre->lc = in;
		else
			pre->rc = in;
	}
}

void Inorder(node* r)
{
	if (r->lc != 0)
		Inorder(r->lc);

	cout << " " << r->key;

	if (r->rc != 0)
		Inorder(r->rc);
}

void Preorder(node* r)
{
	cout << " " << r->key;

	if (r->lc != 0)
		Preorder(r->lc);
	if (r->rc != 0)
		Preorder(r->rc);
}

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

	int n, x;
	string p;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p;

		if (p == "insert")
		{
			cin >> x;
			insert(x);
		}
		else
		{
			Inorder(root);
			cout << endl;
			Preorder(root);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 18788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll h,n,a,sum=0;cin>>h>>n;
  rep(i,n) {
    cin>>a;
    sum+=a;
  }
  if(h<=sum) print("Yes");else print("No");
  return 0;
}

Measured memory_bytes: 256
n = int(input())-1
b =list(map(int, input().split()))
a = [0] * (n+1)

a[0] = b[0]
a[n] = b[n-1]

i=1
while i < n:
    a[i] = min(b[i-1],b[i])
    i = i +1

print(sum(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MT make_tuple
#define PB push_back
typedef long long ll;

int N, L, a[100100];

int main () {
        cin >> N >> L;
        fo(i, 0, N) cin >> a[i];
        fo(i, 0, N-1) {
                if (a[i] + a[i+1] >= L) {
                        puts("Possible");
                        fo(x, 0, i) printf("%d\n", 1+x);
                        for (int x = N-2; x >= i+1; x--) printf("%d\n", 1+x);
                        printf("%d\n", 1+i);
                        return 0;
                }
        }
        puts("Impossible");
        return 0;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main() {
    string line; cin >> line;

    int r, b; r = b = 0;
    for(int i = 0; i < line.size(); i++) {
        if (line[i] == '0') r++;
        else b++;
    }

    cout << min(r, b) * 2 << endl;
}


Measured memory_bytes: 512
n=int(input())
ans=dict()
for i in range(n):
  d=list(input())
  d.sort()
  s="".join(d)
  if not(s in ans):
    ans[s]=1
  else:
    ans[s]+=1
anss=0
for i in ans:
  anss+=((ans[i]*(ans[i]-1))//2)
print(anss)

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

char c[8][12];

int p;

int find(){
    int i = 0;
    while( c[i/8][i%8] == '0' ) i++;
    return i;
}

bool ex1(int d, int r){
    return c[p/8+d][p%8+r] == '1';
}

int main(){
    char dummy[4];
    while( true ){
        int i = 0;
        while( i < 8 && scanf("%s", c[i]) != EOF ){
            i++;
        }
        if( i < 8 ) break;
        p = find();
        if( ex1(0,1) && ex1(1,0) ){
             if( ex1(1,1) ) puts("A");
             else puts("G");
        }else if( ex1(2,0) ) puts("B");
        else if( ex1(0,2) ) puts("C");
        else if( ex1(1,0) ){
            if( ex1(1,1) ) puts("F");
            else puts("D");
        }else puts("E");
        fgets(dummy, 4, stdin);
    }
    return 0;
}

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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 1e5 + 5;
using namespace std;
vector<set<int>> v(26);

int main() {
    IO;
    int n, t;
    string s;
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i) {
        v[s[i] - 'a'].insert(i);
    }
    while (t--) {
        int type, i, l, r, cnt = 0;
        cin >> type;
        if (type == 1) {
            char c;
            cin >> i >> c;
            i--;
            v[s[i] - 'a'].erase(i);
            s[i] = c;
            v[s[i] - 'a'].insert(i);
        } else {
            cin >> l >> r;
            l--, r--;
            for (int i = 0; i < 26; ++i) {

                // Finding the first element
                // which is greater than or equal to L
                auto first = v[i].lower_bound(l);
                // Check if first pointer exists
                // and is less than or equal to R
                if (first != v[i].end() && *first <= r) {
                    cnt++;
                }
            }
            cout << cnt << endl;

        }

    }


}


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

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  for (ll i = 1; i * i <= n; ++i) {
    if ((n - i) % i == 0) {
      if ((n - i) / i > i) {
        sum += (n - i) / i;
      }
    }
  }
  cout << sum << '\n';
}


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

int main() {
  int a;
  cin>>a;
  if(a<=111){
    cout<<111<<endl;
  }
  else if(a<=222){
    cout<<222<<endl;
  }
  else if(a<=333){
    cout<<333<<endl;
  }
  else if(a<=444){
    cout<<444<<endl;
  }
  else if(a<=555){
    cout<<555<<endl;
  }
  else if(a<=666){
    cout<<666<<endl;
  }
  else if(a<=777){
    cout<<777<<endl;
  }
  else if(a<=888){
    cout<<888<<endl;
  }
  else{
    cout<<999<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 100;
const int dx[2]={+1,+0};
const int dy[2]={+0,+1};
struct box{
	int x,y,z;
};
bool vis[maxn][maxn][maxn];
int32_t main(){
	IOS
	memset(vis,0,sizeof(vis));
	int n,m;cin>>n>>m;
	vector<string>s(n);
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	queue<box>q;
	if( s[0][0] == '.' ){
		vis[0][0][0]=1;
		q.push({0,0,0});
	}else{
		vis[0][0][1]=1;
		q.push({0,0,1});
	}
	while( q.size() ){
		int x = q.front().x ;
		int y = q.front().y ;
		int z = q.front().z ;
		q.pop();
		for(int k=0;k<2;k++){
			int x1 = x + dx[k];
			int y1 = y + dy[k];
			if( x1 < n && y1 < m ){
				int z1 =  s[x][y] == '#' ? z : s[x1][y1] == '.' ? z : z +1;
				if( z1 < maxn && !vis[x1][y1][z1] ){
					vis[x1][y1][z1]=1;
					q.push({x1,y1,z1});
				}
			}
		}
	}
	for(int i=0;i<maxn;i++){
		if( vis[n-1][m-1][i] ){
			cout << i << endl;
			return 0;
		}
	}
	
	
}
 
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 4716
#include <iostream>
#include <array>
#include <cmath>

constexpr int MAX = 1000;

int main()
{
    while (true) {
        int students_num;
        std::cin >> students_num;

        if (students_num == 0) {
            break;
        }

        std::array <int, MAX> points;
        for (int i = 0; i < students_num; i++) {
            std::cin >> points.at(i);
        }

        double ave = 0;
        for (int i = 0; i < students_num; i++) {
            ave += points.at(i);
        }
        ave /= students_num;

        double variance = 0;
        for (int i = 0; i < students_num; i++) {
            variance += pow(points.at(i) - ave, 2);
        }
        variance /= students_num;

        double deviation = sqrt(variance);

        std::cout << std::fixed << deviation << std::endl;
    }

    return 0;
}

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

const int N = 2e3 + 10;

int n , x , y , ans[N];

int dis(int u , int v){
	return min(v - u , abs(x - u) + abs(y - v) + 1);
}

int main(){
	scanf("%d %d %d" , &n , &x , &y);
	for(int u = 1; u <= n; u++)
		for(int v = u + 1; v <= n; v++)
			ans[dis(u , v)]++;
	for(int i = 1; i < n; i++)
		printf("%d\n" , ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a<3200)
    cout<<"red";
    else
    cout<<s;
	return 0;
}

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

int main() {
  array<int, 30> foods;
  int n, m, k, temp;
  cin >> n >> m;
  for (int i=0; i<30; i++) {
    foods[i] = 0;
  }
  for (int i=0; i<n; i++) {
    cin >> k;
    for (int i=0; i<k; i++) {
      cin >> temp;
      foods[temp-1]++;
    }
  }
  int count = 0;
  for (auto i : foods) if (i==n) count++;
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	int ans = 0;
	rep(i, 0, s.size()-1) {
		if (s[i] != s[i + 1])++ans;
	}
	cout << ans << "\n";

	return 0;
}


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

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

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

    cout << c << ' ' << a << ' ' << b << endl;

    return 0;
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int n;
    cin >> n;
    cout << n * 32 << endl;
    return 0;
}

Measured memory_bytes: 3176
#include<cstdio>
#include<cmath>
using namespace std;
int map[100000];
const int mod = 1000000000 + 7;
//快速幂取模 
int pow_mod(int a, int n, int m)
{
	if(n == 0)
		return 1;
	int x = pow_mod(a, n/2, m);
	long long ans = (long long)x*x % mod;
	if(n % 2) ans = ans * a %m;
	return int(ans);
	
}

int  main()
{
	int m;
	scanf("%d",&m);
	int diff;
	bool flag = 1;
	int ans = 0;
	int n = m;
	if( n % 2) // jishu
	{
		while(n--)
		{
			scanf("%d", &diff);
			map[diff] ++;
		}
		if(map[0] != 1)
		{
			flag = 0;
		}
		for(int i = 2; flag && i < m; i+=2)
		{
			if( map[i]!= 2) 
			{
				flag = 0;
			}
		}
		if(flag)
			ans = pow_mod(2,m/2,mod);
	}
	else   //oushu
	{
		while(n--)
		{
			scanf("%d", &diff);
			map[diff]++;
		}
		if(map[0] != 0)
		{
			flag = 0;
		}
		for(int i = 1; flag && i <m; i+=2)
		{
			if(map[i]!= 2) 
			{
				flag = 0;
			}
		}
		if(flag)
			ans =pow_mod(2,m/2,mod);
		
	}
	printf("%d\n", ans);
	
	
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int X = sc.nextInt();
        String a = null;
        
        if(X<= K*500){
            a = "Yes";
        } else {
            a = "No";
        }
        System.out.println(a);
    }
}


Measured memory_bytes: 35400
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int N, M;

int visited[10];
int connected[10][10];

int ans;

void dfs(int now, int depth);

int main() {
	scanf("%d %d", &N, &M);
	int i;

	for (i = 0; i < M; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		connected[a][b] = 1;
		connected[b][a] = 1;
	}
	dfs(1, 1);
	printf("%d\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}
void dfs(int now, int depth) {

	if (depth >= N) {//全ての頂点を訪問済み
		ans++; //答えを1増やす
		return;
	}

	visited[now] = 1;//頂点nowを訪問済みとする

	int i;
	for (i = 1; i <= N; i++) {//全ての頂点を探索
		if (connected[now][i] == 1 && visited[i] == 0) {//頂点iは頂点now:に隣接しているかつ未訪問
			visited[i] = 1;//頂点iを訪問済みとする
			dfs(i, depth + 1);//dfs(i, depth+1)
			visited[i] = 0;//移動したので情報リセットのため、頂点iを未訪問とする
		}
	}
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X,K,Q;
ll A,B,C,D;
set<ll> S;
ll ans;
int main(){
    cin>>A>>B>>C>>D;
    M=C/B;if(C%B!=0)M++;
    N=A/D;if(A%D!=0)N++;DEB(M)DEB(N)END
    cout<<(M<=N?"Yes":"No")<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <set>

using namespace std;

int main() {
  long long N, L[2]{};
  cin >> N;
  set<int> S;
  while (cin >> N) {
    if (!S.insert(N).second) {
      S.erase(N);
      if (N > L[0]) L[1] = L[0], L[0] = N;
      else if (N > L[1]) L[1] = N;
    }
  }
  cout << L[0] * L[1] << endl;
}


Measured memory_bytes: 8212
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
 
    using namespace std;
    using namespace __gnu_pbds;
 
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define int long long 
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
 
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
 
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
 
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
 
/*.....................................................................................................................*/
 
    const ll mod=(ll)1e9+ 7;
 
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
 
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
 
    //A.erase(unique(A.begin(),A.end()),A.end());
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll  man  =   (int)200005   ,  inf   =   1e18;
 
 
/*......................................................................................................................*/



signed main()
{
    fast;
    int n,m;
    cin>>n>>m;
    vector<vector<char>>s(n,vector<char>(m));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>s[i][j];
        }
    }
    vector<vector<int>>dp(n,vector<int>(m,0));
    dp[0][0]=1;
    for(int i=1;i<n;i++)
    {
        if(s[i][0]=='.')dp[i][0]=1;
        else break;
    }
    for(int i=1;i<m;i++)
    {
        if(s[0][i]=='.')dp[0][i]=1;
        else break;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(s[i][j]=='.')
            {
                (dp[i][j]=dp[i-1][j]+dp[i][j-1])%=mod;
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;
}   

Measured memory_bytes: 12076
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll nums[100009];

void no(){
    cout1("NO")
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin>>N;
    
    ll sum=0;
    rep(i,N) cin>>nums[i];
    rep(i,N) sum+=nums[i];
    nums[N]=nums[0];
    
    if(sum%(N*(N+1)/2)) no();
    int K=sum/(N*(N+1)/2);
    
    rep(i,N){
        ll dif=nums[i+1]-nums[i]-K;
        if(dif>0||dif%N) no();
    }
    cout1("YES")
}

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

using namespace std;

int main( void )
{
	int n, s;
	short map[20000];
	while(cin >> n >> s, n | s) {
		for(int i=0; i < n; ++i) cin >> map[i];
		sort(map, map+n);
		int count = 0;
		for(int i=0; i < n; ++i) {
			int low = i+1, hi = n;
			while(low < hi) {
				int mid = (low + hi) / 2;
				if(map[i] + map[mid] > s) hi = mid;
				else					 low = mid+1;
			}
			count += n - low;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 896
n = int(input())
h = list(map(int, input().split()))

dp = [float('inf')]*n

dp[0] = 0
dp[1] = dp[0]+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: 52208