akhauriyash/Code-Regression huggingface dataset:
using System;

namespace GridRepeating2 {
    class Program {
        static bool CanDraw(char[,] grid, int H, int W) {

            for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                    if (grid[i, j] == '#') {
                        if (i - 1 < 0 || grid[i - 1, j] == '#') continue;
                        if (i + 1 >= H || grid[i + 1, j] == '#') continue;
                        if (j - 1 < 0 || grid[i, j - 1] == '#') continue;
                        if (j + 1 >= W || grid[i, j + 1] == '#') continue;
                        return false;
                    }
                }
            }
            return true;
        }

        static void Main(string[] args) {

            var split = Console.ReadLine().Split(' ');
            int H = int.Parse(split[0]);
            int W = int.Parse(split[1]);

            char[,] grid = new char[H,W];
            for(int i = 0; i < H; ++i) {
                string line = Console.ReadLine();
                for(int j = 0; j < W; ++j) {
                    grid[i, j] = line[j];
                }
            }

            Console.WriteLine(CanDraw(grid, H, W) ? "Yes" : "No");
            Console.ReadLine();
        }
    }
}


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

int main(){
	int N,X;
	cin >> N >> X;
	int key = 0;
	int ans = 0;
	for(int i=0;i<N;i++){
			int l;
			cin >> l;
			if(key <= X) ans++;
			key += l;
	}
	if(key <= X) ans++;
	cout << ans << endl;

}

Measured memory_bytes: 256
N,M = map(int, input().split())
K = [0]*M
S = [None]*M
for j in range(M):
    lis = list(map(int, input().split()))
    K[j] = lis.pop(0)
    S[j] = lis
    
P = list(map(int, input().split()))

count = 0
for b in range(2**N):
    onoff = [b>>i & 1 for i in range(N)]
    flag = True
    for m in range(M):
        slist = S[m]
        ON = 0
        for s in slist:
            ON += onoff[s-1]
        if ON % 2 != P[m]:
            flag = False
            break
    if flag:
        count += 1

print(count)

Measured memory_bytes: 9132
#include <iostream>

using namespace std;

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

	if ((a == b && a != c) || ( b == c && a != c) || (a == c && a != b)) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    bool f = false;
    for(int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        if(a&1) f = true;
    }
    cout << (f?"first":"second") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int a, b;
  cin >> a >> b;
  if ((b % a) == 0){
    cout << a + b << endl;
  }
  else{
    cout << b - a << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  VV<> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v, --u, --v;
    if (a[u] > a[v]) g[u].push_back(v);
    if (a[u] < a[v]) g[v].push_back(u);
  }
  V<> res(n, -1);
  for (int _ = 0; _ < n; ++_) {
    for (int v = 0; v < n; ++v) if (res[v] == -1) {
      int x = 0, y = 0;
      for (int w : g[v]) {
        x += res[w] == 0;
        y += res[w] == 1;
      }
      if (x) {
        res[v] = 1;
        break;
      }
      if (y == (int) g[v].size()) {
        res[v] = 0;
        break;
      }
    }
  }
  bool f = true;
  for (int v = 0; v < n; ++v) if (res[v]) {
    if (!f) cout << ' ';
    f = false;
    cout << v + 1;
  }
  if (!f) cout << '\n';
}

Measured memory_bytes: 512
#include<stdio.h>
static const int N=100;
static const int INFTY = (1<<21);
int main(){
  int G[N][N],n,i,j,u,k,v,a=0;
  if(a == 0){
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      G[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      G[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if( j )
	printf(" ");
      printf("%d",G[i][j]);
    }
    printf("\n");
  }
  return 0;
}
}



Measured memory_bytes: 2052
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt(), k = sc.nextInt();
        int[] a = sc.nextArray(n);
        for(int i = k;i < n;i++) {
            if (a[i] > a[i - k]) {
                pw.println("Yes");
            } else {
                pw.println("No");
            }
        }
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 56532
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int ufr[225816],ufp[225816];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufp[i] = i;
		ufr[i] = 1;
	}
}

int ufind(int x){
	if(x == ufp[x]){
		return x;
	}
	return ufp[x] = ufind(ufp[x]);
}

void unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x == y){
		return;
	}
	if(ufr[x] < ufr[y]){
		std::swap(x,y);
	}
	ufp[y] = x;
	ufr[x] += ufr[y];
}

int main(void){
	int n,q,i,t,u,v;
	std::cin >> n >> q;
	ufinit(n);
	for(i=0; i<q; ++i){
		std::cin >> t >> u >> v;
		if(t){
			std::cout << (ufind(u)==ufind(v)) << std::endl;
		}else{
			unionf(u,v);
		}
	}
	return 0;
}


Measured memory_bytes: 5088
n = int(input())
ans = [0] * 3

for i in range(n):
    t1 = list(map(int, input().split()))
    t2 = [0] * 3
    for i in range(3):
        for j in range(3):
            if i != j:
                t2[j] = max(t2[j], ans[i] + t1[j])
    ans = t2
print(max(ans))

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

int main(){
  int x;
  cin >> x;
  if(x<100){
    cout << 0 << endl;
  }else if(x<106){
    cout << 1 << endl;
  }else if(x<200){
    cout << 0 << endl;
  }else if(x<211){
    cout << 1 << endl;
  }else if(x<300){
    cout << 0 << endl;
  }else if(x<316){
    cout << 1 << endl;
  }else if(x<400){
    cout << 0 << endl;
  }else if(x<421){
    cout << 1 << endl;
  }else if(x<500){
    cout << 0 << endl;
  }else if(x<526){
    cout << 1 << endl;
  }else if(x<600){
    cout << 0 << endl;
  }else if(x<631){
    cout << 1 << endl;
  }else if(x<700){
    cout << 0 << endl;
  }else if(x<736){
    cout << 1 << endl;
  }else if(x<800){
    cout << 0 << endl;
  }else if(x<841){
    cout << 1 << endl;
  }else if(x<900){
    cout << 0 << endl;
  }else if(x<946){
    cout << 1 << endl;
  }else if(x<1000){
    cout << 0 << endl;
  }else if(x<1051){
    cout << 1 << endl;
  }else if(x<1100){
    cout << 0 << endl;
  }else if(x<1156){
    cout << 1 << endl;
  }else if(x<1200){
    cout << 0 << endl;
  }else if(x<1261){
    cout << 1 << endl;
  }else if(x<1300){
    cout << 0 << endl;
  }else if(x<1366){
    cout << 1 << endl;
  }else if(x<1400){
    cout << 0 << endl;
  }else if(x<1471){
    cout << 1 << endl;
  }else if(x<1500){
    cout << 0 << endl;
  }else if(x<1576){
    cout << 1 << endl;
  }else if(x<1600){
    cout << 0 << endl;
  }else if(x<1681){
    cout << 1 << endl;
  }else if(x<1700){
    cout << 0 << endl;
  }else if(x<1786){
    cout << 1 << endl;
  }else if(x<1800){
    cout << 0 << endl;
  }else if(x<1891){
    cout << 1 << endl;
  }else if(x<1900){
    cout << 0 << endl;
  }else if(x<1996){
    cout << 1 << endl;
  }else if(x<2000){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, M;
    cin >> N;
    vector<int> T(N);
    rep(i, N) cin >> T.at(i);
    cin >> M;
    
    rep(i, M) {
        int P, X;
        cin >> P >> X;
        vector<int> tmp = T;
        tmp.at(P - 1) = X;
        cout << accumulate(all(tmp), 0) << endl;
    }
}

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

const10000 = 90000
const100   = 900
const1     = 9

if 100000 == N:
    print(90909)
elif 10000 <= N:
    div10000, mod10000 = divmod(N,10000)
    res = const100 + const1 + (div10000-1)*10000 + mod10000 + 1
    print(res)
elif 1000 <= N:
    print(909)
elif 100 <= N:
    div100, mod100 = divmod(N,100)
    res = const1 + (min(10,div100)-1)*100 + mod100 + 1
    print(res)
elif 10 <= N:
    print(const1)
else:
    print(N)


Measured memory_bytes: 3064
N = int(input())
# = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
answer = A[0]

if A.count(0) > 0:
    print(0)
    exit()

for i in range(1, N):
    answer = answer*A[i]
    if answer > 10**18:
        print(-1)
        exit()
else:
    print(answer)


Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
template<class T> void read(T& x)
{
	char c = getchar(); T p = 1, n = 0;
	while(c < '0' || c > '9') {if(c == '-') p = -1; c = getchar();}
	while(c >= '0' && c <= '9'){n = n * 10 + c - '0'; c = getchar();}
	x = p * n;
}
template<class T,class U>void read(T&x,U&y){read(x),read(y);}
template<class T,class U,class V>void read(T&x,U&y,V&z){read(x),read(y),read(z);}
const int maxn = 5e3 + 5;
int C[maxn][maxn], f[maxn][maxn];
int power(int a, int b, int p){int r = 1;for(; b;b >>= 1, a = 1ll * a * a % p)if(b & 1)r = 1ll * r * a % p; return r;}
int main()
{
	int n, m; read(n, m);
	C[0][0] = 1;
	for(int i = 1; i <= n; C[i][0] = 1, ++i) for(int j = 1; j <= i; ++j) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % m;
	f[0][0] = 1;
	for(int i = 1; i <= n; f[i][0] = 1, ++i) for(int j = 1; j <= i; ++j)
		f[i][j] = (f[i - 1][j - 1] + 1ll * f[i - 1][j] * (j + 1) % m) % m;
	int sum = 0;
	for(int i = 0, q = 1; i <= n; ++i, q = m - q)
	{
		int ret = 0, p = power(2, n - i, m);
		for(int j = 0; j <= i; ++j)
			(ret += 1ll * f[i][j] * power(p, j, m) % m) %= m;
		ret = 1ll * ret * power(2, power(2, n - i, m - 1), m) % m;
		ret = 1ll * ret * C[n][i] % m;
		ret = 1ll * ret * q % m;
		(sum += ret) %= m;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 119552
# -*- coding: utf-8 -*-
from bisect import bisect_left

N = int (input())
L = list(map(int, input().split()))
L.sort()

count = 0

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        count += bisect_left(L,L[i]+L[j]) - j - 1
        
print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

int main() {
  int a,b;
  cin>>a>>b;
  if(a>9||b>9){
    cout<<-1;
    return 0;
  }
  cout<<a*b;
}

Measured memory_bytes: 256
h, w, d = map(int, input().split())
a = []
dict = {}
for i in range(h):
	b = list(map(int, input().split()))
	for j in range(w):
		dict[b[j]] = [i,j]

dist = [0 for i in range(h*w)]
for i in range(1,h*w-d+1):
	dist[i-1] = abs(dict[i+d][1]-dict[i][1]) + abs(dict[i+d][0]-dict[i][0])

for i in range(h*w-d-1,-1,-1):
	dist[i] += dist[i+d]

q = int(input())
for i in range(q):
	l, r = map(int, input().split())
	ans = dist[l-1] - dist[r-1]
	print (ans)


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

void dpA(){
    int n;
    cin >> n;
    auto h = vector<ll>(n,0);
    for(ll i =0;i<n;i++) cin >> h[i];

    auto dp = vector<ll>(n+2,1e9);
    
    dp[0] = 0;
    dp[1] = 0;
    for(ll i=1;i<n;i++){
        if(i>=2) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])); 
        else if(i>=1) dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
    }
    cout << dp[n-1];
}

int main(){
    dpA();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
typedef long long ll;

int R, C, r, c, a[550];
bool swp;

int main () {
	scanf("%d %d %d %d", &R, &C, &r, &c);
	if (R%r == 0 && C%c == 0) {
		puts("No");
		return 0;
	}

	if (R%r) swap(R,C), swap(r,c), swp = true;

	assert(C%c);
	//C%c != 0

	int tot = 0;
	fo(i, 0, C) {
		if (i % c == c-1) a[i] = -600*(c-1)-1;
		else a[i] = 600;
		tot += a[i];
	}

	assert(tot > 0);

puts("Yes");
	if (swp) {
		//fprintf(stderr, "swp\n");
		fo(i, 0, C) {
			fo(j, 0, R) printf("%d ", a[i]);
			puts("");
		}
	} else {
		//fprintf(stderr, "non swp\n");
		fo(i, 0, R) {
			fo(j, 0, C) printf("%d ", a[j]);
			puts("");
		}
	}

	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<complex>
typedef long long int llint;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int n;
	cin >> n;
	char s[3][110];
	rep(i, 3) {
		cin >> s[i];
	}
	int ans = 0;
	rep(i, n) {
		if (s[0][i] == s[1][i]) {
			if (s[1][i] == s[2][i]) {
				continue;
			}
			else {
				ans++;
			}
		}
		else {
			if (s[0][i] == s[2][i]) {
				ans++;
			}
			else {
				if (s[1][i] == s[2][i]) {
					ans++;
				}
				else {
					ans += 2;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
#include <cctype>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;

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

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  int dates[] = {31,29,31,30,31,    30,31,31,30,31, 30,31};
  while(true){
    int m, d;
    cin >> m >> d;
    if(m==0 && d==0)
      break;

    int days=3;
    REP(i,m-1)
      days += dates[i];
    days+=d-1;

    string str="";
    switch(days%7){
    case 0:str = "Monday"; break;
    case 1:str = "Tuesday";break;
    case 2:str = "Wednesday";break;
    case 3:str = "Thursday";break;
    case 4:str="Friday";break;
    case 5:str="Saturday";break;
    case 6:str="Sunday";break;
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
using ll = long long;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    deque<int> d;

    for (int i = 0; i < N; i++)
    {
        int pos = lower_bound(d.begin(), d.end(), A[i]) - d.begin();
        if(pos == 0){
            d.push_front(A[i]);
        } else {
            d[pos-1] = A[i];
        }
    }

    int ans = d.size();

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


Measured memory_bytes: 4040
#include<iostream>
#include<string.h>
using namespace std;

int dp[17][17];

int main(){
	int a, b,n,ki,kj;
	while (cin >> a >> b, a != 0 && b != 0) {
		cin >> n;
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; i++) {
			cin >> ki >> kj;
			dp[ki][kj] = -1;
		}
		dp[1][1] = 1;
		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {
				if (dp[i][j] != -1 && dp[i][j - 1] != -1) {
					dp[i][j] += dp[i][j - 1];
				}
				if (dp[i][j] != -1 && dp[i - 1][j] != -1) {
					dp[i][j] += dp[i - 1][j];
				}
			}
		}
		cout << dp[a][b] << endl;
	}

	return 0;
}


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

int main()
{
    int a[100];
    for(int i=1;i<=3;i++) cin>>a[i];
    sort(a+1,a+4);
    cout<<a[1]<<" "<<a[2]<<" "<<a[3];
    cout<<endl;
}



Measured memory_bytes: 3168
h,m,s;
d(t){printf("%02d:%02d:%02d\n",t/3600,t%3600/60,t%60);}
main()
{
	for(;scanf("%d%d%d",&h,&m,&s)&&h!=-1;d(s),d(s*3))
		s=7200-h*3600-m*60-s;
	return 0;
}

Measured memory_bytes: 612
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        double o=0;
      	double a=sc.nextDouble();
        double b=sc.nextDouble();
        double x=sc.nextDouble();
        double y=sc.nextDouble();
        double d=6*y-(30*x+y/2);
        double cosin=Math.cos(Math.toRadians(d));
        o=Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*cosin);
      System.out.println(o);
    }
    
}

Measured memory_bytes: 37536
#include<iostream>
#include<cstdio>
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0)puts("Positive");
    else if(b>=0)puts("Zero");
    else if((a&1)^(b&1))puts("Positive");
    else puts("Negative");
    return 0;
}

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

bool is_prime(int n) {
  for(int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
vector<bool> sieve(int n) {
  vector<bool> vec(n+1, true);
  vec[0] = false;
  vec[1] = false;
  for(int i = 2; i*i <= n; i++) {
    if (is_prime(i)) {
      int x = i*2;
      while(x <= n) {
        vec[x] = false;
        x += i;
      }
    }
  }
  return vec;
}
  
int main()
{
  int n;
  cin >> n;
  map<int, int> mp;
  vector<bool> ps = sieve(n);
  ll r = 1e9+7;
  for (int i = 2; i <= n; i++) {
    int x = i;
    rep(j, (int)ps.size()) {
      if (ps[j]) {
        while(x % j == 0) {
          x /= j;
          mp[j]++;
        }
      }
    }
  }
  ll ans = 1;
  for (auto m = mp.begin(); m != mp.end(); m++) {
    ans *= (m->second + 1);
    ans %= r;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using int64 = long long;

pair< int, vector< int > > norm(vector< int > C) {
  vector< int > D(C), ret(C);
  int same = 1;
  for(int i = 0; i < 3; i++) {
    rotate(begin(C), begin(C) + 1, end(C));
    same += C == D;
    ret = min(ret, C);
  }
  return {same, ret};
}


int main() {

  int N;
  vector< int > C[400];
  map< vector< int >, int > same;
  map< vector< int >, int > mp;
  cin >> N;
  for(int i = 0; i < N; i++) {
    C[i].resize(4);
    for(int j = 0; j < 4; j++) cin >> C[i][j];
    auto ret = norm(C[i]);
    same[ret.second] = ret.first;
    C[i] = ret.second;
    ++mp[C[i]];
  }

  // とりあえず上下を決めるんですが
  int64 ret = 0;
  for(int i = 0; i < N; i++) {
    --mp[C[i]];
    for(int j = 0; j < i; j++) {
      --mp[C[j]];
      for(int k = 0; k < 4; k++) {
        rotate(begin(C[j]), begin(C[j]) + 1, end(C[j]));
        vector< int > lu(norm({C[i][1], C[i][0], C[j][1], C[j][0]}).second);
        vector< int > zh(norm({C[i][2], C[i][1], C[j][0], C[j][3]}).second);
        vector< int > il(norm({C[i][3], C[i][2], C[j][3], C[j][2]}).second);
        vector< int > ed(norm({C[i][0], C[i][3], C[j][2], C[j][1]}).second);
        if(mp.count(lu) && mp.count(zh) && mp.count(il) && mp.count(ed)) {
          int64 add = 1;
          add *= same[lu] * mp[lu];
          --mp[lu];
          add *= same[zh] * mp[zh];
          --mp[zh];
          add *= same[il] * mp[il];
          --mp[il];
          add *= same[ed] * mp[ed];
          ret += add;
          ++mp[il];
          ++mp[zh];
          ++mp[lu];
        }
      }
      ++mp[C[j]];
    }
    ++mp[C[i]];
  }
  cout << ret / 3 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

using namespace std;

typedef uint64_t ulint;
typedef int64_t lint;
bool flagdebug = false;

int main(){
    flagdebug = true; 
    const lint BITS = 63;
    const lint MOD = 1000000007;
    lint n;
    cin >> n;
    vector<ulint> a(n);
    vector<ulint> b0(BITS,0);
    vector<ulint> b1(BITS,0);
    rep0(i, n){
        cin >> a[i];
        rep0(j, BITS){
            if(a[i] & ((ulint)1 << j)){
                b1[j] ++;
            }else{
                b0[j] ++;
            }
        }
    }
    ulint ans = 0;
    rep0(j,BITS){
        ans += ((((ulint)1 << j)%MOD) * (b0[j] % MOD)) % MOD * (b1[j] % MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}



int main() {
	ll A, B, C;

	cin >> A >> B >> C;

	cout << max(C - (A - B), 0) << endl;

	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
c1, c2, c4 = 0, 0, 0
for b in a:
    if b%4 == 0:
        c4 += 1
    elif b%2 == 0:
        c2 += 1
    else:
        c1 += 1
if c4 >= c1 or (c1-c4 <= 1 and c2 == 0):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    using namespace std;
    int n, m;
    long long sum = 0;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }

    sort(a.begin(), a.end(), greater<int>());

    if(a[m - 1] * 4 * m >= sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,a=0;
  cin>>n;
  int b=n;
  while(b){
      a+=b%10;
      b=b/10;
  }
  if(n%a==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
       return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

partial_s = []
for i in range(len(S)-len(T)+1):
    partial_s.append(S[i:i+len(T)])
to_replace_idxs = []

for idx, sub_s in enumerate(partial_s):
    for i in range(len(sub_s)):
        flag = 1
        if sub_s[i] != T[i]:
            if sub_s[i] != "?":
                flag = 0
                break
    if flag:
        to_replace_idxs.append(idx)

tmp_ans = []
if not to_replace_idxs:
    print("UNRESTORABLE")
else:
    for to_replace_idx in to_replace_idxs:
        tmp_string = S
        tmp_string = list(tmp_string)
        for i in range(to_replace_idx, to_replace_idx+len(T)):
            tmp_string[i] = T[i-to_replace_idx]
            
        tmp_string = "".join(tmp_string)
        tmp_string = tmp_string.replace("?", "a")
        tmp_ans.append(tmp_string)
    print(min(tmp_ans))

Measured memory_bytes: 62048
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};

class Flower{
public:
    int height;
    int beauty;

};

void solve(){

    ll n;
    cin>>n;

    vector<Flower> arr(n);

    rep(i,n){
        cin>>arr[i].height;
    }

    rep(i,n){
        cin>>arr[i].beauty;
    }    

    vector<ll>dp(n);

    dp[0]=arr[0].beauty;
    map<ll,ll> meaning;
    meaning[arr[0].height]=arr[0].beauty;

    repA(i,1,n-1){
        dp[i]=arr[i].beauty;
        auto it = meaning.lower_bound(arr[i].height+1);
        if(it!=meaning.begin()){
            it--;
            dp[i]+=it->second;
        }
        meaning[arr[i].height]=dp[i];
        it = meaning.upper_bound(arr[i].height);
        while(it!=meaning.end() && dp[i]>=it->second){
            auto temp = it;
            temp++;
            meaning.erase(it);
            it=temp;
        }
    }

    ll ans = 0;

    rep(i,n)
    ans=max(ans,dp[i]);

    db1(ans);

}


int main(){ 
int t=1;
//cin>>t;
while(t--){
 solve();
}
  return 0; 
}





Measured memory_bytes: 15872
#include<cstdio>
using namespace std;
#define N 100500
struct edge{int t,next;}ed[N*2];
int head[N],cnt=1,in[N],n,m,ct,mx,fg,a,b,vis[N];
void adde(int f,int t){ed[++cnt]=(edge){t,head[f]};head[f]=cnt;ed[++cnt]=(edge){f,head[t]};head[t]=cnt;in[f]++;in[t]++;}
void dfs(int u,int id)
{
	vis[u]=1;
	if(u==b)fg=1,vis[u]=0;
	if(u==a&&id)return;
	for(int i=head[u];i;i=ed[i].next)
	if(i!=id&&i!=(id^1)&&!vis[ed[i].t])dfs(ed[i].t,i);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&a,&b),adde(a,b);a=-1;
	for(int i=1;i<=n;i++)if(in[i]&1){printf("No\n");return 0;}else if(mx<in[i])mx=in[i];
	if(mx>4){printf("Yes\n");return 0;}
	for(int i=1;i<=n;i++)if(in[i]==4){ct++;if(a==-1)a=i;else b=i;}
	if(ct>2){printf("Yes\n");return 0;}
	if(ct==2)
	for(int i=head[a];i;i=ed[i].next)
	if(!vis[ed[i].t])
	{
		fg=0;
		dfs(ed[i].t,1);
		if(!fg){printf("Yes\n");return 0;}
	}
	printf("No\n");
}

Measured memory_bytes: 4480
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(x) {
    // ????????????????????????
   console.log(Math.pow(x,3));

  })(parseInt(inputs[0], 10)); // ??°?????????

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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



int main() {
  string s;
  cin >> s;
  cin >> s;
  cout << 'A' << s.at(0) << 'C' << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iterator>
#include<set>
#define rep(i,n) for(i=0;i<n;i++);
#define endl "\n"
#define ll long long
#define N 200050
using namespace std;
 int a[N];
int main()
{
    long long int d,i,n,m,p=0,q=0,r=0,s=0,l;

    int j,k;

    cin>>n;

    for(i=1; i<=100; i++)
    {

        for(j=1; j<=100; j++)
        {
            for(k=1; k<=100; k++)
            {int c=(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);

                if(c<=n)
                    a[c]++;


            }
        }

    }

    for(i=1; i<=n; i++)
        cout<<a[i]<<'\n';
}

















Measured memory_bytes: 3588
p = [[] for _ in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    p[a-1].append(b-1)
    p[b-1].append(a-1)

if [] in p:
    print('NO')
    exit()

if all([len(x) < 3 for x in p]):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
using namespace std;

int main(){
	int m,n,count,number;
	cin >>n>>m;
	int M[m]={};
    int food[m]={};
	count=0;
	number=0;
	for(int i=0;i<n;i++){
      	number=0;
		cin>>number;
        M[m] = {};
      for(int j=0;j<number;j++){
			cin >> M[j];
		}
	  for(int k=0;k<number;k++){
		food[M[k]-1] = food[M[k]-1]+1;
	  }
    }
	for(int l=0;l<m;l++){
		if(food[l]==n){
			count++;
	}
    }
	cout << count;
	return 0;
}


Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

if x > (a ** 2) * b / 2:
	arg = (2 * b / a) - (2 * x / (a ** 3))
else:
	arg = (a * (b ** 2)) / (2 * x)

print(math.atan(arg) / math.pi * 180)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;


const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = 3.14159265358979323846;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	ll n, l, a[100010];
	cin >> n >> l;
	vector<ll>ans;
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
	}
	for (int i = 1;i < n;i++) {
		if (a[i] + a[i + 1] >= l) {
			cout << "Possible" << endl;
			ans.eb(i);
			for (int j = i - 1;j > 0;j--) ans.eb(j);
			for (int j = i + 1;j < n;j++)ans.eb(j);
			for (int j = ans.size()-1;j >= 0;j--) {
				cout << ans[j] << endl;
			}
			return 0;
		}
	}
	cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500;
int main(){
	int m; cin >> m;
	long long sum = 0, cnt = 0;
	for(int i = 0; i < m; i++){
		long long d, c; cin >> d >> c;
		sum += d * c;
		cnt += c;
	}
	cout << (sum - 1) / 9 + cnt - 1 << endl;
	return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str s; cin >> s;
  fin(s[0] == s[2]?"Yes":"No")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
// code.begin();
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back 
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define my_time ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define endl "\n"
#define MOD 1000000007
const long long int INF=1e18;
#define mod 1000000007
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
//find_by_order(x)
//order_of_key(x)  


int power(int x,unsigned int y)
{
    int res=1;
    
    while(y>0)
    {
        // if y is odd multiply with result
        if(y&1)
        res=res*x;
        
        y=y>>1; // y=y/2;
        x=x*x;
        
    }
    return res;
}

int gcd(int a,int b)
{
    if(b==0)
    return a;
    
    return gcd(b,a%b);
}

ll  max3(ll  a, ll  b, ll c)
{
    return max(c, max(a, b));
}
int min3(int a, int  b, int  c)
{
    return min(a, min(b, c));
}

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int logg(int  a)
{
    int  x = 0;
    while (a > 1)
    {
        x++;
        a /= 2;
    }
    return x;
}


int modinv(int x)
{
    return powermod(x, mod - 2, mod);
}



int  main(){
	my_time;

int t;
t=1;
//cin>>t;int test=0;
while(t--)
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
      int dp[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        dp[i]=INT_MAX;
        }
    if(n==1)
    {
        cout<<0<<endl;
        continue;
    }
    
  
    dp[0]=0;

    for(int i=1;i<n;i++)
    {
        for(int l=1;l<=k;l++)
        {
        //    cout<<dp[i]<<endl;
            if(i-l>=0)
        dp[i]=min(dp[i],dp[i-l]+abs(arr[i]-arr[i-l]));
        
      //  cout<<dp[i]<<endl;
       // cout<<dp[i]<<endl;
        }
    }
    
    
    cout<<dp[n-1]<<endl;
    
    
    
    
    
    
}
    return 0;
}


//code.end();





Measured memory_bytes: 4332
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    s = []
    t = []
    for _ in range(n):
        a,b = input().rstrip().split()
        s.append(a)
        t.append(int(b))
    x = input().rstrip()
    y = s.index(x)
    print(sum(t[y+1:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main(){
  int n;
  cin >> n;
  int res = n/3;
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int N;
double dp[310][310][310];

double rec(int i, int j, int k)
{
    if(dp[i][j][k] != 0)return dp[i][j][k];
    //すべて0ならこれ以上操作する必要がないので、0を返す
    if(i == 0 && j == 0 && k == 0)return 0.0;


    //期待値dp
    //dp[i][j][k]: 残り1がi枚、残り2がj枚、残り3がk枚に達するまでの回数期待値
//    dp[i][j][k] =  (i * dp[i+1][j-1][k] + j * dp[i][j+1][k-1] + k * dp[i][j][k+1]) /
//               //--------------------------------------------------------
//                    (i + j + k) * N;
//    dp[i][j][k] += 1.0;

    double res = 0.0;
    if(i > 0)res += rec(i-1, j, k) * i;
    if(j > 0)res += rec(i+1, j-1, k) * j;
    if(k > 0)res += rec(i, j+1, k-1) * k;
    res += N;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;

}


int main() {

    cin >> N;

    vector <ll> cnt(3, 0);
    REP(i,N)
    {
        int a;
        cin >> a;
        --a;
        ++cnt[a];
    }


    //期待値dp
    //dp[i][j][k]: 残り1がi枚、残り2がj枚、残り3がk枚に達するまでの回数期待値
    //残り0の皿を当てることもある
    REP(i, 310)
    {
        REP(j, 310)
        {
            REP(k, 310)
            {
                dp[i][j][k] = 0.0;
            }
        }
    }

    dp[cnt[0]][cnt[1]][cnt[2]] = 0.0;


    double res = rec(cnt[0],cnt[1],cnt[2]);

    printf("%.12f\n",res);



    return 0;
}


Measured memory_bytes: 233088
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

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

int h, w;
lint L;

void solve(){
    char c[h][w];
    int sx, sy, sd;
    rep(i, h)rep(j, w){
        scanf(" %c", &c[i][j]);
        if(c[i][j] != '.' && c[i][j] != '#'){
            sx = i; sy = j;
            if(c[i][j] == 'E') sd = 0;
            if(c[i][j] == 'S') sd = 1;
            if(c[i][j] == 'W') sd = 2;
            if(c[i][j] == 'N') sd = 3;
        }
    }

    pair<pii, int> nxt[60][h][w][4]; // 2^k steps, (x, y, dir)
    rep(x, h)rep(y, w)rep(dir, 4){
        nxt[0][x][y][dir] = {{x, y}, dir};
        for(int nd = dir; nd != dir + 4; ++nd){
            int nx = x + dx[nd % 4], ny = y + dy[nd % 4];
            if(0<=nx && nx<h && 0<=ny && ny<w && c[nx][ny] != '#'){
                nxt[0][x][y][dir] = {{nx, ny}, nd % 4};
                break;
            }
        }
    }
    For(k, 1, 60)rep(x, h)rep(y, w)rep(dir, 4){
        auto p = nxt[k-1][x][y][dir];
        int nx = p.fi.fi, ny = p.fi.se, nd = p.se;
        nxt[k][x][y][dir] = nxt[k-1][nx][ny][nd];
    }

    rep(k, 60)if(L>>k & 1){
        auto p = nxt[k][sx][sy][sd];
        sx = p.fi.fi; sy = p.fi.se; sd = p.se;
    }

    char cd;
    if(sd == 0) cd = 'E';
    if(sd == 1) cd = 'S';
    if(sd == 2) cd = 'W';
    if(sd == 3) cd = 'N';
    printf("%d %d %c\n", sx+1, sy+1, cd);
}

int main(){
    while(scanf("%d%d%lld", &h, &w, &L) && h){
        solve();
    }
}


Measured memory_bytes: 31332
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = 0;
  if (2*c==a && 2*d==b) ans = 1;
  printf("%.10f %d\n", (a*b)*0.5, ans);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=1e5+10;
int n,a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=n;i>1;i--)
		if(a[i]<a[i-1])a[i-1]--;
	for(int i=2;i<=n;i++)
		if(a[i]<a[i-1])
		{
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

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

int main() {
  int n, a, y, z;
  cin >> n;
    y = 0;
  z = 30;
  while (n > 0 ){
    cin >> a;
    y = 0;    
    while( a % 2 == 0){
          a = a / 2;
          y++;}
     if ( z > y){z = y;} 
    n = n - 1;
  }
  cout << z << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    string S;
    cin >> S;
    if(S[2]==S[3] && S[4]==S[5]){
        cout << "Yes" << endl;  
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;  //time
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  if (tail + 1 == LEN){
    tail = 0;
  }else{
    tail++;
  }
}

P dequeue(){
  P x = Q[head];
  if (head + 1 == LEN){
    head = 0;
  }else{
    head++;
  }
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail=i;
  u.t = 0;
  while (head!=tail){
    if (Q[head].t > q){ 
      Q[head].t -= q; 
      u.t += q;
      enqueue(dequeue());
    }
    else{
      u.t += Q[head].t;
      strcpy(u.name, Q[head].name);
      dequeue();
      printf("%s %d\n",u.name, u.t);
    }
  }
  
  return 0;
}

Measured memory_bytes: 10768
N = int(input())
A = list(map(int, input().split()))
all_sum = sum(A)

part_sum = 0

for i, a in enumerate(A):
    part_sum += a
    if part_sum >= all_sum // 2:
        price = part_sum - (all_sum - part_sum)
        break
part_sum = 0

for i, a in enumerate(reversed(A)):
    part_sum += a
    if part_sum >= all_sum // 2:
        price = min(price, part_sum - (all_sum - part_sum))
        break
print(price)

Measured memory_bytes: 88016
#include <iostream>
     
    int main(void){
      int N;
      std::cin >> N;
      
      int a[N+1];
     
      for(int i=1; i<=N; i++){
        std::cin >> a[i];
      }
     
      int count = 0;
      for(int i=1; i<=N; i++){
        if(a[a[i]] == i) count++;
      }
     
      std::cout << count/2 << std::endl;
      return 0;
    }

Measured memory_bytes: 768
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int N = int.Parse(Console.ReadLine());//配列Aの個数
      　var An = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();//配列An
      	int Q = int.Parse(Console.ReadLine());//試行回数Q
		
		//int count = 0;
		//int count = An.Count(n => n == X);//AnのなかのXの個数
 
        var countArray = new long[100001]; //配列Anに1~100000が何個あるのかの配列(参照した)
      	for (int i = 0; i < An.Length; i++)
            {
                countArray[An[i]]++;
            }
       	
      	var sum = An.Sum();//配列の合計値(初期Sum)

		for(int i = 1; i <= Q ; i++)
            {
                var BnCn = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var B = BnCn[0];
                var C = BnCn[1];
          
          
                sum += (C - B) *  countArray[B];//sum計算 初期sum+(C-B)×(Bの個数)
                countArray[C] += countArray[B];//Cの数をBの数分増やす
                countArray[B] = 0;//Bの数を0に
                Console.WriteLine(sum.ToString());
            }
    }
}

Measured memory_bytes: 51168
#include<stdio.h>
int main()
{
 int i,c;
 char moji;
 int counter[26]={};

 for(i=0;scanf("%c",&moji)!=EOF;i++){
                        
                        if(isalpha(moji)) {
                                           c=tolower(moji)-'a';
                                           counter[c]++;
                                          }
                        }
 for(i=0;i<26;i++){
                   printf("%c : %d\n",i+'a',counter[i]);
                   }
 return 0;

}



Measured memory_bytes: 2104
n,m,x,y=map(int,input().split())
xlist=list(map(int,input().split()))
ylist=list(map(int,input().split()))
xlist.sort()
ylist.sort()
if xlist[-1]<ylist[0] and xlist[-1]>x and ylist[0]<=y:
    print('No War')
else:
    print('War')







Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;


int main() {
  int a,b;
  cin >> a >> b;
  int ans = INF;
  REP(i,11110) {
    if(floor(i*0.08) == a && floor(i*0.1) == b) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
}

Measured memory_bytes: 256