akhauriyash/Code-Regression huggingface dataset:
#入力
H, W, K = map(int, input().split())
MOD = 10 ** 9 + 7

transition = [[0] * (W+1) for _ in range(W+1)]

#2進数の01で横棒の配置を識別
for b in range(2 ** (W - 1)):
    b = bin(b)[2:].zfill(W - 1)
    #1が連続する場合、横棒のルールに違反するためスキップ
    ok = True
    for i in range(W - 2):
        if b[i] == "1" and b[i + 1] == "1":
            ok = False
    if ok:
        #p:遷移先のindex
        p = list(range(W))
        for i in range(W - 1):
            # 横棒が無い場合、縦棒kから縦棒kに遷移
            # 横棒がある場合、縦棒k-縦棒k+1間を遷移 -> p[i],p[i+1]の入れ替えで表現
            if b[i] == "1":
                p[i], p[i + 1] = p[i + 1], p[i]
        #遷移パターン数をカウント
        for i in range(W):
            transition[i][p[i]] += 1

#DPループ
dp = [[0] * (W + 1) for _ in range(H + 1)]
#初期値:0行目で縦棒1にいるパターン数は1
dp[0][0] = 1
#dpの添え字1のループ
for y in range(H):
    #dpの添え字2のループ
    for i in range(W):
        #下記の式の和を取るループ
        for x in range(W):
            #y+1行目に縦棒iにいるパターン数 = Σx (y行目に縦棒xにいるパターン数 * 縦棒xから縦棒iに移動するパターン数)
            dp[y + 1][i] += dp[y][x] * transition[x][i]
            dp[y + 1][i] %= MOD

#出力
print(dp[H][K - 1])

Measured memory_bytes: 3192
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	n := len(s)
	a := make([]int, n)
	li, ri := 0, 0
	for i := 0; i < n; i++ {
		lc := s[i]
		rc := s[n-i-1]
		if lc == 'L' {
			a[i] = li
			li++
		} else {
			li = 0
		}
		if rc == 'R' {
			a[n-i-1] = ri
			ri++
		} else {
			ri = 0
		}
	}

	ans := make([]int, n)
	for i := 0; i < n; i++ {
		b := a[i]
		if b%2 == 1 {
			b++
		}
		if s[i] == 'R' {
			ans[i+b]++
		} else {
			ans[i-b]++
		}
	}

	for i, v := range ans {
		if i < len(ans)-1 {
			fmt.Printf("%d ", v)
		} else {
			fmt.Println(v)
		}
	}
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int>v;
	for(int i=0;i<n-1;i++){
		int x;
		cin >> x;
		v.push_back(x);
	}
	int ans = 0;
	if(n==2) {
		ans = v[0]*2;
	}
	else{
		 int s = v.size();
		 v.push_back(v[s-1]);// cout << " df" << v[s-1] << endl;
		ans += v[0] + v[v.size()-1];
		for(int i=1;i<v.size()-1;i++){
            ans += min(v[i] , v[i-1]);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
	string str;
	string ans;
	cin >> str;
	ans = str;
	for (int i = 0; i < str.size(); i++){
		ans[i] = str[str.size() - i - 1];
	}
	cout << ans << endl;

}

Measured memory_bytes: 1176
import java.util.*;

class Main{

    int[] par, rank;

    void init(int n){
	par = new int[n]; rank = new int[n];
	for(int i=0; i<n; i++){
	    par[i] = i;
	    rank[i] = 0;
	}
    }

    int find(int x){
	if(par[x]==x) return x;
	else return par[x] = find(par[x]);
    }

    void unite(int x, int y){
	x = find(x); y = find(y);
	if(x==y) return;

	if(rank[x] < rank[y]) par[x] = y;
	else{
	    par[y] = x;
	    if(rank[x]==rank[y]) rank[x]++;
	}
    }

    boolean same(int x, int y){
	return find(x) == find(y);
    }

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt(), m = sc.nextInt();
	    if(n==0 && m==0) break;

	    int[][] edge = new int[m][3];
	    for(int i=0; i<m; i++){
		for(int j=0; j<3; j++){
		    edge[i][j] = sc.nextInt();
		    if(j!=2) edge[i][j]--;
		}
	    }

	    Arrays.sort(edge, new Comparator<int[]>(){
		    public int compare(int[] a, int[] b){
			return a[2] - b[2];
		    }
		});

	    int INF = Integer.MAX_VALUE/2;
	    int min = INF;
	    for(int i=0; i<m; i++){
		int cnt = 0;
		int max = 0;
		init(n);
		for(int j=i; j<m; j++){
		    if(same(edge[j][0], edge[j][1])) continue;
		    unite(edge[j][0], edge[j][1]);
		    max = edge[j][2] - edge[i][2];
		    cnt++;
		    if(cnt==n-1) break;
		}
		if(cnt==n-1) min = Math.min(min, max);
	    }
	    if(min==INF) System.out.println(-1);
	    else System.out.println(min);
	}
    }

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

Measured memory_bytes: 76648
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		string s;
		getline(cin, s);
		string from = "Hoshino";
		string to = "Hoshina";
		auto pos = s.find(from);
		while(pos != string::npos) {
			s.replace(pos, from.size(), to);
			pos = s.find(from, pos + to.size());
		}
		cout << s << endl;
	}
}

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

const int64_t MOD = 1000000007;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;


// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
      v[k][j] %= MOD;
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;


signed main() {
  ll n,m;
  cin >> n >> m;
 
  int a[m] = {};
  for(int i=0;i<m;i++){
    cin >> a[i];
    a[i]--;
  }
  
  // if i broken
  // dp[i] = 0;
  // else
  // dp[i+1] = dp[i] + dp[i-1];
  //
  ll dp[n+1] = {};
  dp[0] = 1;
  int j = 0;
  for(int i=0;i<n;i++){
    if(j<m && a[j]==i){
      dp[i+1] = 0;
      j++;
    }
    else{
      dp[i+1] += dp[i];
      if(i>=1) dp[i+1] += dp[i-1];
      dp[i+1] %= MOD;
      //cout << i << ":" << dp[i+1] << endl;
    }
  }
  cout << dp[n] << endl;
  return 0;
}



Measured memory_bytes: 4796
while True:
    h, w = [int(i) for i in input().split(' ')]
    if h ==0 and w ==0:
        break
    for i in range(h):
        row = ''
        for j in range(w):
            if i == 0 or i == h - 1:
                row = row + '#'
            else:
                if j == 0 or j == w -1:
                    row = row + '#'
                else:
                    row = row + '.'
        print(row)
    print('')


Measured memory_bytes: 5616
N = int(input())
A = list(map(int, input().split()))
sa = sum(A)
ans, min_diff = N, sa
for i in range(N - 1, -1, -1):
    d = abs(A[i] * N - sa)
    if d <= min_diff:
        ans = i
        min_diff = d
print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
const long double PI = (acos(-1));

long double f(long double a, long double b, long double x) {
  long double res;
  if (a * a * b / 2.0 <= x){
    res = atan(2.0 * ((a * a * b - x) / (a * a * a)));
  } else {
    res = atan(a * b * b / (2 * x));
  }

  return res * 180.0 / PI;
}

int main() {
  long double a, b, x;
  cin >> a >> b >> x;
  cout << fixed << setprecision(10) << f(a,b,x) << endl;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	private static int N;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			N = sc.nextInt();
			if (N == 0) {
				sc.close();
				break;
			}

			long[] sat = new long[N];// 満足度
			@SuppressWarnings("unchecked")
			ArrayList<Integer[]>[] guys = new ArrayList[N];
			for (int i = 0; i < guys.length; i++) {
				guys[i] = new ArrayList<Integer[]>();
				int M = sc.nextInt();
				sat[i] = sc.nextLong();
				for (int j = 0; j < M; j++) {
					int S = sc.nextInt();
					int E = sc.nextInt();
					Integer[] put = { S, E };
					guys[i].add(put);
				}
			}
			int[] time = new int[24];
			System.out.println(dfs(0, 0, time, guys, sat));
		}

	}

	static long dfs(int guy, long maxsat, int[] time,
			ArrayList<Integer[]>[] guys, long[] sat) {
		long ans = 0;
		// guyまで入れた時のsatとtime
		if (guy == N) {
			return maxsat;
		}

		// guyを入れられるか
		int[] clone = time.clone();
		for (Integer[] integers : guys[guy]) {
			int S = integers[0];
			int E = integers[1];
			clone[S]++;
			clone[E]--;
		}
		boolean appliable = true;
		int test = 0;
		for (int i = 0; i < clone.length; i++) {
			test += clone[i];
			if (test < 0 || test > 1) {
				appliable = false;
				break;
			}
		}
		if (appliable) {
			ans = dfs(guy + 1, maxsat + sat[guy], clone, guys, sat);
		}
		long notapply = dfs(guy + 1, maxsat, time.clone(), guys, sat);

		return Math.max(ans, notapply);

	}
}

Measured memory_bytes: 69276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  
  for (int i = 0; i < N; i++) {
    if (x * 2 < x + K) {
      x *= 2;
    }
    else {
      x += K;
    }
  }
  
  cout << x << endl;
  
}

Measured memory_bytes: 256
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE
#define inf 0x3f3f3f3f
#define mod
#define maxm
#define maxn 200
int a[maxn], b[maxn], c[maxn], d[maxn], e[maxn], f[maxn];
int g[maxn][maxn];
int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	// ios::sync_with_stdio(false);
	int n, m;
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i], &b[i]);
		c[i] = a[i];
		d[i] = b[i];
	}
	sort(c, c + n);
	sort(d, d + n);
	for (int i = 0; i < n; i++) {
		e[i] = lower_bound(c, c + n, a[i]) - c + 1;
		f[i] = lower_bound(d, d + n, b[i]) - d + 1;
		g[e[i]][f[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			g[i][j] = g[i][j] + g[i - 1][j] + g[i][j - 1] - 
						g[i - 1][j - 1];
		}
	}
	long long ans = 0x7fffffffffffffffll;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = i; k <= n; k++) {
				for (int p = j; p <= n; p++) {
					if (g[k][p] - g[i - 1][p] - 
						g[k][j - 1] + g[i - 1][j - 1] >= m) {
						ans = min(ans, 1ll * (c[k - 1] - c[i - 1]) * 
								(d[p - 1] - d[j - 1]));	
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
N = int(input())
S = input()

total = 0

for i in range(1000):
    query = str(i)
    query = "0"*(3-len(query)) + query

    current_query = query[0]
    current_query_index = 0
    for s in S:
        if s == current_query:
            current_query_index += 1
            if current_query_index == 3:
                break
            current_query = query[current_query_index]
    if current_query_index == 3:
        total += 1

print(total)

Measured memory_bytes: 3064
import java.util.HashSet;
import java.util.Scanner;

/**
 * TITLE : Distinct or Not
 * URL : https://atcoder.jp/contests/abc154/tasks/abc154_c
 */
public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashSet<Integer> numberSet = new HashSet<Integer>();
		// N -1する必要があるかないか気をつけろ！
		for (int i = 0; i < N; i++) {
			if (!numberSet.add(sc.nextInt())) {
				System.out.println("NO");
				sc.close();
				return;
			}
		}
		System.out.println("YES");
		sc.close();
	}
}

Measured memory_bytes: 100640
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
#define pi acos(-1)
using namespace std;
int main()

{
    FastRead
    ll int t,j,i,n;
    //cin>>t;
    //f(j=0;j<t;j++)
    //{
    cin>>n;
    ll int a[n],c=0,mn;
    f(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    f(i=0; i<n; i++)
    {
        if(i==0)
            mn=a[i];
        else
        {
            if(a[i]<mn)
            {
                c++;
                mn=a[i];
            }
        }

    }
    cout<<c+1<<endl;;

    //}
    return 0;
}

Measured memory_bytes: 5180
// AOJ 1131 "Unit Fraction Partition" (ICPC国内予選 2004 Problem C)
import java.util.Scanner;

public class Main {
    static int p;
    static int q;
    static int a;
    static int n;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            p = sc.nextInt();
            q = sc.nextInt();
            a = sc.nextInt();
            n = sc.nextInt();
            if (p == 0) {
                break;
            }
            
            int ans = dfs(0, 1, n, 1);
            System.out.println(ans);
        }
    }
    
    public static int dfs(int c, int m, int num, int mother) {
        //System.out.println(c + "/" + m + " " + num + " " + mother);
        if (isEqual(p, q, c, m)) {
            //System.out.println(c + "/" + m + " " + num + " " + mother + " !");
            return 1;
        }
        if (mother * m > a || num <= 0 || m > a || isBigger(p, q, c, m)) {
            return 0;
        }
        
        int ans = 0;
        // 1/motherを使う場合
        ans += dfs(c * mother + m, m * mother, num - 1, mother);
        
        // 1/motherを使わない場合
        ans += dfs(c, m, num, mother + 1);
        
        
        return ans;
    }
    
    public static boolean isEqual(int c1, int m1, int c2, int m2) {
        return c1 * m2 == c2 * m1;
    }
    
    public static boolean isBigger(int c1, int m1, int c2, int m2) {
        return c1 * m2 < c2 * m1;
    }
}

Measured memory_bytes: 23976
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x) cout << " >> " << #x << " "<<x<<endl;
void Solve_Case()
{
   int N;
   cin >> N;
   vector< pair<int,int> > v(N+1);
   int x;
   for(int i=1;i<=N;i++)
    cin >> x , v[i].first = x , v[i].second = i;
   sort(v.begin(),v.end());
   for(int i=1;i<=N;i++)
    cout << v[i].second << " ";

}
signed main()
{
    int TestCases=1;

    while(TestCases--)
    {
        Solve_Case();
    }
	return 0;
}


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

#define endl "\n"

typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll DIM = 100007;
const ll INF = 1000000007;
ll n,m,k;
ll a,b,c;
ll v[DIM],w[DIM],ans[200][DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(ll i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for(ll j=1;j<=k;j++){
    for(ll i=1;i<=n;i++){
        if(j<w[i])ans[i][j]=ans[i-1][j];else ans[i][j]=max(ans[i-1][j],ans[i-1][j-w[i]]+v[i]);

    }

    }
    cout<<ans[n][k];
    return 0;
}


Measured memory_bytes: 81408
n = int(input())
a = sorted([int(x) for x in input().split()])
b = sorted([int(x) for x in input().split()])
c = sorted([int(x) for x in input().split()])

res = 0
res_b = 0
cnt = 0
i, j = 0, 0
for c_ in c:
    while i <= n-1 and c_ > b[i]:
        while j <= n-1 and b[i] > a[j]:
            cnt += 1
            j += 1
        res_b += cnt
        i += 1
    res += res_b

print(res)

Measured memory_bytes: 22452
#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>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

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}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m,X,Y,max_v = INT_MIN,min_v = INT_MAX;
  cin >> n >> m >> X >> Y;
  vector<int> x(n),y(m);

  for (int i = 0; i < n; i++){
    cin >> x[i];
    chmax(max_v,x[i]);
  }
  
  for (int i = 0; i < m; i++){
    cin >> y[i];
    chmin(min_v,y[i]);
  }
  
  for (int i = X+1; i <= Y; i++){
    if (i > max_v && i <= min_v){
      cout << "No War\n";
      return 0;
    }
  }
  
  cout << "War\n";
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int a[130]; 
int main() {
	int n, x;
	cin >> n >> x;
	rep(i,n) cin >> a[i];
	sort(a,a+n);

	int ans = 0;
	rep(i,n) {
		if (i < n-1) {
			if (x >= a[i]) {
				ans++;
				x -= a[i];
			}
		} else {
			if (x == a[i]) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
	int N,k;
	cin>>N>>k;
	int d[10];
	for(int i=0;i<k;i++)
		cin>>d[i];
	int n=N;
	int flag;
	int h=N;
	while(1)
	{
		flag=1;
		while(n)
		{
			int r=n%10;
			for(int i=0;i<k;i++)
			{
				if(d[i]==r)
				{
					flag=0;
					break;
				}
			}
			n=n/10;
			if(flag==0)
			{
				break;
			}
		}
		if(flag==1)
		{
			cout<<h<<endl;
			break;
		}
		else{
			h++;
			n=h;
		}
	}
return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	w := getNextInt(scanner)
	h := getNextInt(scanner)
	x := getNextInt(scanner)
	y := getNextInt(scanner)

	fmt.Fprintf(writer, "%f ", float64(w)*float64(h)/2.0)
	if x*2 == w && y*2 == h {
		fmt.Fprintln(writer, 1)
	} else {
		fmt.Fprintln(writer, 0)
	}

	writer.Flush()
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;
#define ll long long
int main(void){

    ll num1, num2;
    scanf("%lld%lld", &num1, &num2);
    ll mid = (num1+num2)>>1;
    if(abs(num1 - mid)==abs(num2 - mid)){
        cout << mid;
    } else {
        cout <<"IMPOSSIBLE\n";
    }
    return 0;
}

Measured memory_bytes: 256
L,R=map(int,input().split())
mod=2019
if L%mod >= R%mod or R-L >= mod:
  print(0)
else:
  a=mod
  for i in range(L%mod,R%mod):
    for j in range(i+1,R%mod+1):
      a=min((i*j)%mod,a)
  print(a)

Measured memory_bytes: 9128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    ll M; cin >> M;
    vector<int> status(N,-1);
    vector<vector<ll>> G(N);
    vector<ll> H(N);
    for(auto& in:H) cin >> in;
    for(int i = 0; i < M;i++){
        ll A,B; cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    
    for(int i = 0; i < N;i++){
        if(status[i] != -1) continue;
        
        status[i] = 1;
        for(auto next:G[i]){
            if(H[i] > H[next]){
                status[next] = 0;
            }else{
                status[i] = 0;
                break;
            }
        }
        if(status[i] == 1) res++;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 10300
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000
vector<pair<int,int>> ans;
vector<int> parity;
struct unionfind{
	vector<int> data;
	vector<int> size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
			size.push_back(1);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return false;
		if(size[x]>size[y])swap(x,y);
		data[x]=y;
		size[y]+=size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};

void dfs(vector<vector<int>> &E,int now,int p){
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==p)continue;
		dfs(E,to,now);
	}
	if(p!=-1){
		if(parity[now]==1){
			ans.emplace_back(now,p);
			parity[now] ^= 1;
		}
		else{
			ans.emplace_back(p,now);
			parity[p] ^= 1;
		}
	}
}

int main(){
	
	int N,M;
	cin>>N>>M;
	parity.resize(N,0);
	
	unionfind uf(N);
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<M;i++){
		int A,B;
		cin>>A>>B;
		A--;B--;
		if(uf.unite(A,B)){
			E[A].push_back(B);
			E[B].push_back(A);
		}
		else{
			ans.emplace_back(A,B);
			parity[A] ^= 1;
		}
	}
	
	dfs(E,0,-1);
	
	if(parity[0]==1)cout<<-1<<endl;
	else{
		for(int i=0;i<ans.size();i++)cout<<ans[i].first+1<<' '<<ans[i].second+1<<endl;
	}
	
	return 0;
}

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


int main()
{
 

    int a,b,c;
    cin >> a >> b >> c;

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

    return 0;    

}


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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli func(lli x1,lli x2,lli y1,lli y2){
	return abs(x1-x2)+abs(y1-y2);
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){

	COMinit();

	lli n,m;
	cin>>n>>m;
	lli k;
	cin>>k;

	lli ans=0;

	/*xの距離がiの数をansに足し合わせる*/
	REP(i,0,m)ans = (ans+n*n%MOD*(m-i)%MOD*i%MOD)%MOD;
	REP(i,0,n)ans = (ans+m*m%MOD*(n-i)%MOD*i%MOD)%MOD;

	cout<<ans*COM(n*m-2,k-2)%MOD<<endl;
	

	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

const int N = 2001;

vector<int> edges[N];

int dist[N][N];

int main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	for (int i = 1; i <= n; ++i) {
		queue<int> q;
		q.push(i);
		while (!q.empty()) {
			int cur = q.front();
			q.pop();
			for (int j = 0; j < edges[cur].size(); ++j) {
				int next = edges[cur][j];
				if (next != i && !dist[i][next]) {
					dist[i][next] = dist[i][cur] + 1;
					q.push(next);
				}
			}
		}
	}
	int ans = 1e9;
	if (k % 2) {
		for (int u = 1; u <= n; ++u) {
			for (int j = 0; j < edges[u].size(); ++j) {
				int v = edges[u][j];
				int cnt = 0;
				for (int w = 1; w <= n; ++w) {
					if (dist[u][w] > (k - 1) / 2 && dist[v][w] > (k - 1) / 2) {
						++cnt;
					}
				}
				ans = min(ans, cnt);
			}
		}
	} else {
		for (int i = 1; i <= n; ++i) {
			int cnt = 0;
			for (int j = 1; j <= n; ++j) {
				if (dist[i][j] > k / 2) {
					++cnt;
				}
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}


int main(void){
    string s; cin >> s;
	vector<int> a,z;
	rep(i,s.size()){
		if (s[i]=='A'){
			a.push_back(i);
		}
		if (s[i] == 'Z'){
			z.push_back(i);
		}
	}
	cout << *max_element(all(z))-*min_element(all(a))+1 << endl;
}


Measured memory_bytes: 1364
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll x,y,a,b,c;//入力と同じ
    cin >> x >> y >> a >> b >> c;
    vector<ll> red(a,0);//赤りんご
    vector<ll> green(b,0);//緑りんご
    priority_queue<int> unvisible;//無色の
    priority_queue<int,vector<int>, greater<int> > manage;//美味しさが小さいものから取る用
    ll sum = 0;
    rep(i,a)cin >> red[i];
    sort(red.begin(),red.end(),greater<ll>());
    rep(i,x){
        manage.push(red[i]);
        sum += red[i];
    }
    rep(i,b)cin >> green[i];
    sort(green.begin(),green.end(),greater<ll>());
    rep(i,y){
        manage.push(green[i]);
        sum += green[i];
    }
    rep(i,c){
        ll in;
        cin >> in;
        unvisible.push(in);
    }

    while(1){
        if(unvisible.empty())break;//念の為
        ll t = manage.top();
        if(unvisible.top() > t){
            sum -= t;
            sum += unvisible.top();
            manage.pop();
            manage.push(unvisible.top());
            unvisible.pop();
        }else break;
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a < b) {
  for(int i = 0; i < b ;i++) {
    cout << a;
  }
  }
  else{
  for(int i = 0; i < a ;i++) {
    cout << b;
  }
  }
}


Measured memory_bytes: 256
import math

N, M = map(int, raw_input().split())

ab = [map(int, raw_input().split()) for _ in xrange(N)]
cd = [map(int, raw_input().split()) for _ in xrange(M)]

for i in xrange(N):
    for j in xrange(M):

        d = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])

        if j == 0:
            t = d
            ans = 1

        elif t > d:
            t = d
            ans = j+1

    print ans

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    string s;
    cin >> s;
    for(const auto& c : s)cout << static_cast<decltype(c)>((c - 65 + N) % 26 + 65);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = min(A) + min(B)

for _ in range(m):
    x, y, c = map(int, input().split())
    t = A[x - 1] + B[y - 1] - c
    if t < ans:
        ans = t

print(ans)

Measured memory_bytes: 18612
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

val(a,b,x) = floor(a*x/b) - a * floor(x/b)

function main()
    A,B,N = reads(Int,Int,Int)
    if N < B
        println(Int(floor(A*N/B)))
        return
    end
    fi = 1
    fv = val(A,B,fi)
    ei = N
    ev = val(A,B,ei)
    ci = (fi+ei)÷2
    cv = val(A,B,ci)
    while true
        if fv < cv
            fi = ci
            fv = cv
        else
            ei = ci
            ev = cv
        end
        ci = (fi+ei)÷2
        cv = val(A,B,ci)
        if fi+1 >= ei
            println(Int(max(fv,cv,ev)))
            break
        end
    end
end

main()


Measured memory_bytes: 194696
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll


ll power(ll b, ll e, ll m ) {
    ll c = 1;
    while(e) {
        if(e&1LL)
            c = (c*b)%m;
        e /= 2LL;
        b = (b*b)%m;
    }
    return c;
}




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=power(2,n,mod)-1;
    vi arr(b+1,0);
    arr[0]=1;
    for(ll r=1;r<=b;r++)
    {
        ll mul=(n-r+1);
        mul*=power(r,mod-2,mod);
        mul%=mod;

        arr[r]=arr[r-1]*mul;
        arr[r]%=mod;
        
    }
    ans-=arr[a];
    ans-=arr[b];
    ans%=mod;
    while(ans<0)
    {
        ans+=10*mod;
    }
    ans%=mod;
    cout<<ans<<endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
   int N;
   cin >> N;
   vector<int> d(N);

   for(int i =0; i<N; i++){
       cin >> d[i];
   }
     sort(d.begin(),d.end());
    int count =1;
    for(int i =1; i<N; i++){
       if(d[i] != d[i-1]){
           count++;
       }
   }
   cout << count << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DNotDivisible solver = new DNotDivisible();
        solver.solve(1, in, out);
        out.close();
    }

    static class DNotDivisible {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            Integer[] tab = new Integer[n];
            HashMap<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < n; i++) {
                tab[i] = sc.nextInt();
                map.putIfAbsent(tab[i], 0);
                map.put(tab[i], map.get(tab[i]) + 1);
            }
            Arrays.sort(tab);
            HashMap<Integer, Integer> done = new HashMap<>();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (map.get(tab[i]) == 1) {
                    if (done.get(tab[i]) == null) {
                        ans++;
                    }
                }
                if (done.get(tab[i]) == null) {
                    for (int j = tab[i]; j < 1000001; j += tab[i]) {
                        done.put(j, 1);
                    }
                }
            }
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 125868
#include <bits/stdc++.h>
#define pb push_back
#define LL long long
#define x first
#define y second
#define pii pair<int,int>
#define mp make_pair
#define MEM(x) memset(x,0,sizeof(x))
#define pi acos(-1)
using namespace std;	
int main(){
	LL n;
	scanf("%lld",&n);
	LL ans=0;
	for(LL i =1;i*i<=n;i++){
		if(n%i==0){
			if(i!=1){
				if(n/(i-1)==n%(i-1))
					ans+=i-1;
			}
			LL x=n/i;
			if(x==i)
			continue;
			if(x==1)
			continue;
			if(n/(x-1)==n%(x-1)){
				ans+=x-1;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}
/*
n = x*m+x=x*(m+1);



*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<long double> vec;
vector<tuple<long double, long double, long double>>ans;
int main() {
	long double a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	for (long double i = 0; i <= f; i++) {
		for (long double j = 0; j <= f; j++) {
			if (c * i + d * j <= f) {
				vec.emplace_back(c * i + d * j);
			}
		}
	}
	sort(vec.begin(), vec.end());
	for (long double i = 0; i <= f / 10; i++) {
		for (long double j = 0; j <= f / 10; j++) {
			if (a * i * 100 + b * j * 100 <= f) {
				long double now = a * i * 100 + b * j * 100;
				long double g = min(f - now, now * e / 100);
				auto itr = upper_bound(vec.begin(), vec.end(), g);
				itr--;
				ans.emplace_back(make_tuple(100 * (*itr) / (now + (*itr)), now, *itr));
			}
		}
	}
	sort(ans.rbegin(), ans.rend());
	cout << get<1>(ans[0]) + get<2>(ans[0]) << " " << get<2>(ans[0]) << endl;
	return 0;
}


Measured memory_bytes: 7372
n = int(input())
# 偶数奇数が同じかつ和がt以下ならいける
cnt = 0
t = []
x = []
y = []

for i in range(n):
   ttmp, xtmp, ytmp = map(int, input().split())
   t.append(ttmp)
   x.append(xtmp)
   y.append(ytmp)

for i in range(n):
   if i == 0:
      if t[i] >= x[i]+y[i] and (t[i])%2 == (x[i]+y[i])%2:
         cnt += 1
      else:
         print("No")
         break
   else:
         if t[i] >= x[i]+y[i] and (t[i])%2 == (x[i]+y[i])%2 and x[i]+y[i]-x[i-1]-y[i-1] <= t[i]-t[i-1] :
            cnt += 1
         else:
            print("No")
            break

if cnt == n:
   print("Yes")



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

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  
  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    ans += (s[i] == t[i]);
  }
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    cin >> num;
    int box[3][100010];
    for(int i=0;i<num;i++){
        for(int j=0;j<3;j++){
            cin >> box[j][i];
        }
    }
    int ans[3];
    for(int i=0;i<3;i++){
        ans[i]=0;
    }
    int tmp[3];
    for(int i=0;i<num;i++){
        for(int j=0;j<3;j++){
            tmp[j]=max(ans[(j+1)%3]+box[j][i],ans[(j+2)%3]+box[j][i]);
        }
        for(int j=0;j<3;j++){
            ans[j]=tmp[j];
        }
    }
    cout << max(ans[0],max(ans[1],ans[2])) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

#define TRUE 0
#define FALSE -1

int check(char map[64][64], int i, int j, int up, int left, int down, int right) {
  int flg = FALSE;

  if(!up) {
    if(map[i-1][j] == '#') {
      flg = TRUE;
    }
  }
  if(!down) {
    if(map[i+1][j] == '#') {
      flg = TRUE;
    }
  }
  if(!left) {
    if(map[i][j-1] == '#') {
      flg = TRUE;
    }
  }
  if(!right) {
    if(map[i][j+1] == '#') {
      flg = TRUE;
    }
  }

  return flg;
}

int main(void) {
  int i, j;
  int flg = TRUE;
  int h, w;
  char s[64][64];
  scanf("%d %d", &h, &w);
  for(i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }

  for(i = 0; i < h; i++) {
    for(j = 0; j < w; j++) {
      if(s[i][j] == '#' && check(s, i, j, i==0,j==0,i==h-1,j==w-1) == FALSE) {
        flg = FALSE;
        break;
      }
    }
  }

  if(flg == TRUE) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n, k = map(int, input().split())
vs = list(map(int, input().split()))
res = 0
for i in range(min(n,k)+1):
    for j in range(min(n-i,k-i)+1):
        res_tmp = 0
        arr = []
        if i > 0:
            arr += vs[:i]
        if j > 0:
            arr += vs[(n-j):]
        if arr != []:
            arr.sort()
            n_len = len(arr)
            for m in range(min(k-i-j,n_len)):
                if arr[m] >= 0:
                    break
                res_tmp -= arr[m]
            res_tmp += sum(arr)
        res = max(res,res_tmp)
print(res)

Measured memory_bytes: 71488
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int sum[2005][2005],tot[2005][2005],w[2005][2005],n,m,Q;
char s[2005][2005];
int calc(int x,int y,int xx,int yy){
	if(s[x][y]=='0') return 0;
	return s[x+xx][y+yy]=='1';
}
int calc(int a[2005][2005],int x1,int y1,int x2,int y2){
	if(x1>x2||y1>y2) return 0;
	return a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
}
int main(){
	scanf("%d%d%d",&n,&m,&Q);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++){
		for(int p=1;p<=m;p++){
			sum[i][p]=sum[i-1][p]+sum[i][p-1]-sum[i-1][p-1]+(s[i][p]=='1');
			tot[i][p]=tot[i-1][p]+tot[i][p-1]-tot[i-1][p-1]+calc(i,p,-1,0);
			w[i][p]=w[i-1][p]+w[i][p-1]-w[i-1][p-1]+calc(i,p,0,-1);
		}
	}
	for(int i=1,x1,x2,y1,y2;i<=Q;i++){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		int point=calc(sum,x1,y1,x2,y2);
		int edge=calc(tot,x1+1,y1,x2,y2)+calc(w,x1,y1+1,x2,y2);
		printf("%d\n",point-edge);
	}
	return 0;
}

Measured memory_bytes: 52864
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t,i,x;
    t=1;
    while (t--) {
        string p,q;
        cin>>p>>q;
        bool ans=true; int uq=0;
        map<char,int> al1,al2,ct;
        for (i=1;i<p.size();i++) {
            if (p[i]==p[i-1]) {
                if (q[i]!=q[i-1]) ans=false;
            }
            else {
                if (q[i]==q[i-1]) ans=false;
            }
            if (ct[p[i]]==0) {
                uq++;
                ct[p[i]]++;
            }
        }
        for (int i=0;(i<p.size())&&(uq==26)&&(ans);i++) {
            if (p[i]!=q[i]) ans=false;
        }
        for (i=0;(i<p.size())&&(ans);i++) {
            al1[p[i]]++;
            al2[q[i]]++;
            if (al1[p[i]]!=al2[q[i]]) ans=false;
        }
        if (ans) cout<<"Yes\n";
        else cout<<"No\n";
    }
}


Measured memory_bytes: 916
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		String[] s = new String[n];
		for(int i=0; i<n; i++){
			s[i] = scn.next();
		}
      	int ac = 0;
      	int wa = 0;
      	int tle = 0;
      	int re = 0;
      	for(int i=0; i<n; i++){
          if(s[i].equals("AC")) ac++;
          if(s[i].equals("WA")) wa++;
          if(s[i].equals("TLE")) tle++;
          if(s[i].equals("RE")) re++;
        }
      	System.out.println("AC x " + ac);
      	System.out.println("WA x " + wa);
      	System.out.println("TLE x " + tle);
      	System.out.println("RE x " + re);
	}
}

Measured memory_bytes: 64756
import java.util.Scanner;

/**
 * @author yoshizaki
 * ABC 156
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        long count = scanner.nextLong();
        long blue = scanner.nextLong();
        long red = scanner.nextLong();

        long balls = 0;
        long bcount = 0;
        // 青だけ並ぶ
        if (count <= blue) {
            bcount = count;
        } else {
            // 青と赤が並ぶ
            // 青と赤が何セット並べられるか
            long set = (long) (count / (blue + red));
            // セット数から青の個数を出す
            bcount = set * blue;
            // 並べたボールの数を出す
            balls = set * (blue + red);
            // 青を並べきれるならそのまま追加
            if (count - balls >= blue) {
                bcount += blue;
            } else {
            // 青を並べきれない場合は残りの個数が青 
                bcount += (count - balls);
            }
        }
        System.out.println(bcount);
    }
}

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

int main(){
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < 4; i++){
  if (s.at(i)=='+'){
    count ++;
  }
    else
      count --;
  }
  cout << count ;
}


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

int main(){

  map<int64_t,int64_t> m;
  int64_t sum=0;
  int N;
  cin>>N;
  for(int i=0;i<N;++i){
    int A;
    cin>>A;
    ++m[A];
    sum += A;
  }

  int Q;
  cin>>Q;
  for(int i=0;i<Q;++i){
    int64_t B,C;
    cin>>B>>C;
    
    sum += (C-B)*m[B];
    
    m[C] += m[B];
    m[B]=0;
    
    cout<<sum<<endl;
  }
  
}

Measured memory_bytes: 9568
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main()
{
int N;
    cin >>N;
vector<int> D1(N);

vector<int> D2(N);


int count=0;

bool flag=false;
for(int i=0;i<N;i++){

    cin >> D1[i] >> D2[i];

    if(D1[i]==D2[i]){


        count++;
        if(count==3){


            flag=true;
        }
    }
    else{

        count=0;
    }
}

if(flag){
cout <<"Yes"<<endl; 
}
else{

    cout << "No" << endl;
}

return 0;
}

Measured memory_bytes: 3660