akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1

const int maxn = 2e5 + 7;
const int INF = 0x3f3f3f3f;

struct node {
    int pos,val;
}a[maxn];

bool cmp(node aa,node bb) {
    return aa.pos < bb.pos;
}

LL q[maxn];

int main() {
    int n,d,x;
    scanf("%d%d%d",&n,&d,&x);
    for(int i = 1 ; i <= n ; i++) {
        scanf("%d%d",&a[i].pos,&a[i].val);
    }
    d <<= 1;
    sort(a+1,a+n+1,cmp);
    LL ans = 0;
    for(int i = 1 ; i <= n ; i++) {
        q[i] += q[i-1];
        a[i].val -= q[i] * x;
        if(a[i].val <= 0) continue;
        LL temp = (a[i].val + x - 1) / x;
        ans += temp;
//        cout << "i = " << i << " ans = " << ans << endl;
        q[i] += temp;
        int l = i , r = n;
        int res = 0;
        while(l <= r) {
            int mid = (l + r + 1) >> 1;
//            cout << "l = " << l << " r = " << r << " " << a[mid].pos << " " << a[i].pos + d << endl;
            if(a[mid].pos <= a[i].pos + d) {
                res = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
//        cout << "res = " << res << endl;
        q[res+1] -= temp;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
count = [0,0]
2.times do |i|
  f = -1+i*2
  sum = 0
  for j in 0..n-1
    sum += a[j]
    if f == 1 && sum <= 0
      count[i] -= sum-1
      sum = 1
    elsif f == -1 && sum >= 0
      count[i] += sum+1
      sum = -1
    end
    f *= -1
  end
end
p count.min

Measured memory_bytes: 11404
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
using namespace std;
#define REP(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define REP1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(){
    int N,p,q,r;
    cin>>N;
    p=N/100;
    q=(N-100*p)/10;
    r=N-100*p-10*q;
    if(p==7 || q==7 || r==7){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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


int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<vector<int>> a(N, vector<int>(M));
	vector<int> b(M);
	for(int i = 0; i < M; i++){
		cin >> b.at(i);
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> a.at(i).at(j);
		}
	}
	int sum = 0;
	int counter = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			sum += a.at(i).at(j) * b.at(j);
		}
		if(sum + C > 0){
			counter++;
		}
		sum = 0;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>





#define REP(i, n) for(int 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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define fil(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int cum1[200020], cum2[200020], A[200020];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	REP(i, N) {
		cin >> A[i];
		if (i % 2 == 0) {
			cum1[i + 1] = A[i];
			cum1[i + 1 + N] = -A[i];
			cum2[i + 1] = -A[i];
			cum2[i + 1 + N] = A[i];
		}
		else {
			cum1[i + 1] = -A[i];
			cum1[i + 1 + N] = A[i];
			cum2[i + 1] = A[i];
			cum2[i + 1 + N] = -A[i];
		}
	}
	REP(i, 2 * N) {
		cum1[i + 1] += cum1[i];
		cum2[i + 1] += cum2[i];
	}
	REP(i, N) {
		if (i % 2 == 0) {
			int ans = cum1[i + N] - cum1[i];
			print(ans);
		}
		else {
			int ans = cum2[i + N] - cum2[i];
			print(ans);
		}
	}
}

Measured memory_bytes: 5248
import collections

n = int(input())
s = [input() for i in range(n)]

s_count = collections.Counter(s)
largest = max(list(s_count.values()))
ans = []

for key in list(s_count.keys()):
    if s_count.get(key) == largest:
        ans.append(key)

ans.sort()

for word in ans:
    print(word)

Measured memory_bytes: 38908
PI = 3.14159265358979323846

a,b,x = gets.split.map(&:to_i)

s = 1.0 * x / a
ans = 0
a2  = 0

if s == a * b
  ans = 0
else
  if s > b * a / 2.0
    bu = 2.0 * s / a - b
    s -= a * bu
    b -= bu
    a2 = 2.0 * s / b
  else
    a2 = 2.0 * s / b
  end
  r = Math.atan((1.0*b)/a2)
  ans = r * (180.0/PI)
end

puts ans

Measured memory_bytes: 1788
using System;

namespace ABC055_C_Scc_Puzzle
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			long n = long.Parse(input[0]);
			long m = long.Parse(input[1]);

			long count;
			if (n <= m / 2)
			{
				//sのパーツを全て使い切る
				count = n;
				m -= n * 2;
				//残りのmでできる限り作る(c4つで1セット)
				count += m / 4;
			}
			else
			{
				count = m / 2;
			}
			
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 11092
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
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;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

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

	ll r=0, g=0, b=0;
	rep(i, N) {
		if (S[i] == 'R') r++;
		if (S[i] == 'G')g++;
		if (S[i] == 'B')b++;
	}

	ll ans = r * g * b;

	ll C = (N - 3) / 2;
	for (ll d = 0; d <= C; d++) {
		for (int s = 0; s <= N - 2 * d - 3; s++) {
			if (S[s] != S[s + d + 1] && S[s] != S[s + 2 * d + 2] && S[s + d + 1] != S[s + 2 * d + 2]) ans--;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    cout<<100<<" "<<100<<endl;
    int a,b; cin>>a>>b; a--,b--;
    char board[100][100];
    rep(i,50)rep(j,100) board[i][j]='.';
    rep(i,50)rep(j,100) board[50+i][j]='#';
    int y=0,x=0;
    while(b--){
        board[y][x]='#';
        x+=2;
        if(x>99) x=0,y+=2;
    }
    y=99,x=0;
    while(a--){
        board[y][x]='.';
        x+=2;
        if(x>99) x=0,y-=2;
    }
    rep(i,100){
        rep(j,100){
            cout<<board[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <queue>

#define LL long long

using namespace std;

string s;

int main()
{
	//freopen("test_in.txt", "r", stdin);
	//freopen("test_out.txt", "w", stdout);
	cin>>s;
	cout<<"2018"<<s.substr(4);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
 
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;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;
 
    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }
 
    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }
 
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
 
    return ret;
}

void solve(long long a, long long b, long long c){
    
    if(a == b && b == c){
        cout << 1;
    }else{
        if(a == b || b == c || a == c){
            cout << 2;
        }else{
            cout << 3;
        }
    }

    cout << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long A = sc.nextInt();//walk
        long B = sc.nextInt();//teleport
        //the best way: ascending order
        long[] town = new long[N];
        for(int i=0;i<N;i++)town[i]= sc.nextInt();
        long tired = 0;
        for(int i=0;i<N-1;i++){
        	long distance = town[i+1] - town[i];
        	tired += Math.min(distance*A,B);
        }
        System.out.println(tired);
    }
}

Measured memory_bytes: 47096
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN2(n,a);
  OUT(pow(n,2)-a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=100010;
int n,a[N],cnt;
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  sort(a+1,a+n+1);
  cout<<(a[n/2+1]-a[n/2])<<endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = Integer.parseInt(str);

		if(x < 1200){
			System.out.println("ABC");
		}else{
			System.out.println("ARC");
		}

	}

}


Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int A, B, N;
    cin >> N;
    A = 0;
    B = 0;
    char c;
    REP(i, N)
    {
        cin >> c;
        if (c == 'R')
            A++;
        else
            B++;
    }
    if (A > B)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    // system("pause");
}

Measured memory_bytes: 256
N,A = (int(T) for T in input().split())
X = [int(T) for T in input().split()]
DP = [[[0]*(N+1) for TS in range(0,50*N+1)] for TI in range(0,N+1)]
DP[0][0][0] = 1
for TI in range(0,N):
    for TS in range(0,50*N+1):
        for TK in range(0,N+1):
            if DP[TI][TS][TK]!=0:
                DP[TI+1][TS][TK] += DP[TI][TS][TK]
                DP[TI+1][TS+X[TI]][TK+1] += DP[TI][TS][TK]
print(sum(DP[N][A*TA][TA] for TA in range(1,N+1)))

Measured memory_bytes: 135652
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, cnt int
	fmt.Scan(&A, &B)
	for i := A; i <= B; i++ {
		tmp := i
		rev := 0
		for j := 4; j >= 0; j-- {
			rev += (tmp % 10) * int(math.Pow10(j))
			tmp /= 10
		}
		if rev == i {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_arr = [0] * n
a_arr[0] = a[0]
b_arr = [0] * m
b_arr[0] = b[0]

# Aの上からi冊読むのに何分かかるか
for i in range(1,n):
    a_arr[i] = a_arr[i-1] + a[i]

# Bの上からi冊読むのに何分かかるか
for i in range(1,m):
    b_arr[i] = b_arr[i-1] + b[i]

a_arr.insert(0, 0)
b_arr.insert(0, 0)

# Aから取る上限を探索
i_a_max = 0
for i in range(n+1):
    if a_arr[i] > k:
        break
    else:
        i_a_max = i

# Aから1冊も取らない場合のBの冊数を探索
i_b = 0
for i in range(m+1):
    if b_arr[i] <= k:
        i_b = i
    else:
        break


score = []
# Aをi冊読んだときで全探索
for i_a in range(i_a_max + 1):
    while(True):
        if a_arr[i_a] + b_arr[i_b] <= k:
            break
        elif i_b == 0:
            break
        else:
            i_b -= 1
    score.append(i_a + i_b)
    #print(i_a,i_b)
#print(i_a_max)
print(max(score))

Measured memory_bytes: 50752
def main():
    n = int(input())
    v = [int(v) for v in input().split()]
    c = [int(c) for c in input().split()]

    total = 0
    for nn in range(n):
        if v[nn] > c[nn]:
            total += v[nn]
            total -= c[nn]
    print(total)

    # max_total = 0
    # for i in range(2 ** n):
    #     total = 0
    #     for j in range(n):  # このループが一番のポイント
    #         if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
    #             total += v[j]
    #             total -= c[j]
    #     if total > max_total:
    #         max_total = total
    # print(max_total)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

int cnt(ll M){
    int digits=0;

    while(M>0){
        M/=10;
        digits++;
    }
    return digits;
}

int main(){
    ll N;
    cin>>N;

    int ans = cnt(N);
    
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i!=0)continue;
        ll b = N/i;

        int tmp = max(cnt(i),cnt(b));

        ans = min(ans,tmp);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	double T, A;
	cin >> T >> A;
	vector<double> VD;
	REP(i, N) {
		double H;
		cin >> H;
		double temp = T - H * 0.006;
		VD.push_back(temp);
	}
	double def = 1e10;
	int ind = -1;
	REP(i, N) {
		if (def > abs(A - VD[i])) {
			def = abs(A - VD[i]);
			ind = i;
		}
	}
	cout << ind + 1 << endl;
	PAU;
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  long long num[n+1];
  num[0]=2;
  num[1]=1;
  for(int i=2;i<n+1;i++){
    num[i]=num[i-1]+num[i-2];
  }
  cout<<num[n]<<endl;
  return 0;
}


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

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

ll a[100010][2];
const int MAX_N = 110;
const int MAX_V = 100100;
ll dp[MAX_N][MAX_V];

int main()
{
    ll n, w;

    cin >> n;
    cin >> w;

    for (int i = 0; i < n; ++i)
    {
        cin >> a[i][0];
        cin >> a[i][1];
    }
    for (int i = 0; i < MAX_N; ++i)
    {
        for (int j = 0; j < MAX_V; ++j)
        {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j <= MAX_V; ++j)
        {
            if (j - a[i][1] >= 0)
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - a[i][1]] + a[i][0]);

            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    ll res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
    {
        if (dp[n][sum_v] <= w)
            res = sum_v;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 86272
h, w = [int(w) for w in input().split()]
lls = [input() for w in range(h)]

lls = ["."*(w+2)]+["."+w+"."for w in lls] + ["."*(w+2)]
# N E S W
direction = [[-1, 0], [0, 1], [1, 0], [0, -1]]
cond = True
for i in range(1, h+2):
    for j in range(1, w+2):
        if lls[i][j] == ".":
            continue
        nb = False
        for d1, d2 in direction:
            if lls[i+d1][j+d2] == "#":
                nb = True
        if nb == False:
            cond = False

        now_dir = 0

print("Yes" if cond else "No")


Measured memory_bytes: 9168
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();


		Set<Integer> adj[] = new HashSet[n+1];
		for(int i = 1; i<adj.length; i++) {
			adj[i] = new HashSet<Integer>();
		}


		for(int i = 0; i < m; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			adj[a].add(b);
			adj[b].add(a);
		}

		int[] dist = new int[n+1];
		dist[0] = 0;
		int[] ans = new int[n+1];

		Set<Integer> endcheck = new HashSet<>();
		endcheck.add(1);
		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(1);

		while(!q.isEmpty()) {

			int v1 = q.poll();

			int tdist = dist[v1] + 1;

			Iterator<Integer> adjit = adj[v1].iterator();
			while(adjit.hasNext()) {
				int v2 = adjit.next();
				if(!endcheck.contains(v2)) {
					q.add(v2);
					endcheck.add(v2);

					if(dist[v2] < 1 || dist[v2] > tdist) {
						dist[v2] = tdist;
						ans[v2] = v1;
					}
				}
			}
		}

		System.out.println("Yes");
		for(int i = 2; i < n+1; i++) {
			System.out.println(ans[i]);
		}


	}

}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string N;
int K;
int dp[110][4][2];
signed main() {
    cin >> N >> K;
    dp[0][0][0] = 1;
    rep(i, N.length()) {
        int digit = N[i] - '0';
        if (digit == 0) {
            for (int j = 0; j <= K; j++) {
                dp[i + 1][j][0] += dp[i][j][0];
                dp[i + 1][j][1] += dp[i][j][1];
            }
            rep(j, K) {
                dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
            }
        } else {
            for (int j = 0; j <= K; j++) {
                dp[i + 1][j][1] += dp[i][j][0];
                dp[i + 1][j][1] += dp[i][j][1];
            }
            rep(j, K) {
                dp[i + 1][j + 1][0] += dp[i][j][0];
                dp[i + 1][j + 1][1] += dp[i][j][0] * (digit - 1);
                dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
            }

        }
    }
    cout << dp[N.length()][K][0] + dp[N.length()][K][1] << endl;
}

Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  const N=input[0].split(' ')[0]-0;
  const M=input[0].split(' ')[1]-0;
  const X=input[0].split(' ')[2]-0;
  var c=[];
  var a=[];
  var temp;
  for(var i=1;i<input.length;i++){
    temp=input[i].split(' ').map(e=>{return e-0;});
    c.push(temp[0]);
    temp.shift();
    a.push(temp.concat([]));
  }
  var isBought=new Array(N);
  isBought.fill(false);
  var min=Infinity;
  loop1:
  do{
    for(var i=0;i<N;i++){
      if(isBought[i]){
        isBought[i]=false;
      }else{
        isBought[i]=true;
        break;
      }
    }
    for(var i=0;i<M;i++){
      temp=0;
      for(var j=0;j<N;j++){
        if(isBought[j]){
          temp+=a[j][i];
        }
      }
      if(temp<X){
        continue loop1;
      }
    }
    temp=0;
    for(var i=0;i<N;i++){
      if(isBought[i]){
        temp+=c[i];
      }
    }
    if(min>temp){
      min=temp;
    }
  }while(!isBought.every(e=>{return !e;}))
  console.log(min===Infinity?-1:min);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 32808
N=int(input())
b=list(map(int,input().split()))

tmp=-1
idx=0
count=1
flag=True
ans=[]
while(len(b)):
    #print(idx)
    if idx<len(b):
        if b[idx]==count:
            tmp=idx
            idx+=1
            count+=1
        else:
            idx+=1
            count+=1
    if idx>(len(b)-1):
        if tmp==-1:
            flag=False
            break
        else:
            #print(tmp)
            ans.append(b[tmp])
            del b[tmp]
            tmp=-1
            idx=0
            count=1
#print(ans)
if flag:
    for i in range(len(ans)):
        print(ans[len(ans)-1-i])
else:
    print(-1)

Measured memory_bytes: 39024
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	char c[2], s[6] = "aeiou";
	scanf("%s", c);
	if(find(s, s + 5, c[0]) != s + 5) puts("vowel");
	else puts("consonant");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(final String[] args) {
		final Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		final int a = sc.nextInt();
		final int b = sc.nextInt();

		if (a % 2 != 0 && b % 2 != 0) {
			// 奇数
			System.out.println("Odd");

		} else {
			// 偶数
			System.out.println("Even");
		}
	}
}

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


int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx-sx, dy = ty-sy;
    cout << string(dy,'U') << string(dx,'R');
    cout << string(dy,'D') << string(dx,'L');
    cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
    cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
    cout << endl;
    return 0;
}

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

using namespace std;

const ll inf=1000000007;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

ll a[200005], sum[200005];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+a[i]*((sum[n]-sum[i])%inf)%inf)%inf;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6884
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int[] x = new int[3];
     x[0] = scan.nextInt();
     x[1] = scan.nextInt();
     x[2] = scan.nextInt();
     java.util.Arrays.sort(x);
     System.out.println(x[0]+" "+x[1]+" "+x[2]);
    }
}



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> a;
    a.push_back(1);
    for(int i = 6; i<=9; i+= 3) {
        int value = i;
        while(value <= 1e5) {
            a.push_back(value);
            value *= i;
        }
    }
    sort(a.rbegin(), a.rend());


    vector<int> dp(100010,1e9);
    dp[0] = 0;

    for(int i = 1; i <= 1e5; ++i) {
        for(int j = 0; j < (int)a.size(); ++j) {
            if(i >= a[j]) dp[i] = min(dp[i], dp[i-a[j]] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long ll;
const int MAXN = 0;

int main()
{
//	freopen("input.in", "r", stdin);
    string s;
    cin >> s;

    int l = 0;
    int r = s.size() - 1;
    int ans = 0;
    while (l < r)
    {
        if (s[l] == s[r])
        {
            l++;
            r--;
        }
        else if (s[l] == 'x')
        {
            l++;
            ans++;
        }
        else if (s[r] == 'x')
        {
            r--;
            ans++;
        }
        else
        {
            cout << -1;
            return 0;
        }
    }

    cout << ans;
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int K = scan.nextInt();
		int S = 0;

		if(A >= K) {
			S = K;
		} else {
			S = A;
			K -= A;
			K -= B;
			if(K > 0) {
				S -= K;
			}
		}
		System.out.println(S);
	}
}

Measured memory_bytes: 35668
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

int main()
{
    ll n;
    string x;
    cin >> n >> x;
    vector<ll> v;
    ll d[200004] {0};
    for(ll i = n; i > 0; i--){
        if(i % 2 == 1 && n % i == 0) v.push_back(n / i);
    }
    ll ans = 0;
    for(ll l : v){
        ll sum = 0;
        ll b = 1;
        for(ll i = 0; i < l; i++){
            if(x[l - 1 - i] == '1') sum = (sum + b) % MOD;
            b = b * 2 % MOD;
        }
        string s = x.substr(0, l);
        string r;
        for(ll i = 0; i < l; i++){
            if(s[i] == '0') r += '1';
            else r += '0';
        }
        string coner = s;
        for(ll i = 0; i < (n / l) / 2; i++) coner += r + s;
        if(coner <= x) sum++;
        d[l] = (d[l] + sum) % MOD;
        for(ll y : v){
            if(y % l == 0 && y != l){
                d[y] = (d[y] - d[l] + MOD) % MOD;
            }
        }
        ans = (ans + d[l] * l * 2) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int k,a,b; cin >> k >> a >> b;
    ll B = 1;
    for(int i = 0; i < k; i++){
        if(b-a <= 2 || i == k-1){
            B++;
        }else{
            if(B >= a){
                B+=(b-a); i++;
            }else{
                B++;
            }
        }
    }
    cout << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;
int main(){
	int a[101] = { 0 }, b[101] = { 0 }, c[101] = { 0 }, n;
	in >> n;
	int d[200][3];
	REP(i, n) {
		in >> d[i][0] >> d[i][1] >> d[i][2];
		a[d[i][0]]++;
		b[d[i][1]]++;
		c[d[i][2]]++;
	}
	REP(i, n) {
		if (a[d[i][0]] > 1)d[i][0] = 0;
		if (b[d[i][1]] > 1)d[i][1] = 0;
		if (c[d[i][2]] > 1)d[i][2] = 0;
		cout <<d[i][0]+d[i][1]+d[i][2] << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3100
c = []

def listcreate():
    global c
    c = []
    for y in range(a[0]):
        b = []
        for x in range(a[1]):
            b.append("#")
        c.append(b)
    return

def listdraw():
    global c
    for y in range(len(c)):
        for x in range(len(c[0])):
            print(c[y][x], end='')
        print()
    return

for i in range(10000):
    a = list(map(int,input().split()))
    if sum(a)==0:
        break
    listcreate()
    listdraw()
    print()



Measured memory_bytes: 7220
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    string s;
    cin >> s;
    long long count=-1,ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            count++;
            ans = ans + (i-count);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		int[] a = new int[n];
		long[] b = new long[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}
      int i = 1;
      
		for(int t = 1; k >= 0 ; --k , ++t ,i = a[i - 1]) {
          if(b[i - 1] > 0)
				k %= (t - b[i - 1]);
				b[i - 1] = t;
          if(k==0L){
				System.out.println(i);
				return;
			}
        }


	}


}



Measured memory_bytes: 62012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;
int V;
vector<int> G[MAX],rG[MAX],vs;
bool used[MAX];
int cmp[MAX];

void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void DFS(int v){
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        if(used[G[v][i]]==0) DFS(G[v][i]);
    }
    vs.push_back(v);
}

void rDFS(int v,int k){
    used[v]=1;
    cmp[v]=k;
    for(int i=0;i<rG[v].size();i++){
        if(used[rG[v][i]]==0) rDFS(rG[v][i],k);
    }
}

int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++){
        if(used[v]==0) DFS(v);
    }
    
    memset(used,0,sizeof(used));
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
        if(used[vs[i]]==0) rDFS(vs[i],k++);
    }
    return k;
}

int main(){

    int E;cin>>V>>E;
    for(int i=0;i<E;i++){
        int a,b;cin>>a>>b;
        add_edge(a,b);
    }
    
    scc();
    
    int Q;cin>>Q;
    for(int i=0;i<Q;i++){
        int a,b;cin>>a>>b;
        if(cmp[a]==cmp[b]) cout<<1<<endl;
        else cout<<0<<endl;
    }
    
}




Measured memory_bytes: 8992
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll arr[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll k;
  cin>>k;
  cout<<arr[k];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 3005

bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}

ll dp[N][N],vis[N];
string s,t,ans;
map<pl,ll>m,v;


ll solve(ll i,ll j)
{
    if(i<0 || j<0)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(s[i]==t[j])
        return dp[i][j]=1+solve(i-1,j-1);
    else
        return dp[i][j]=max(solve(i-1,j),solve(i,j-1));
}

void print(ll i,ll j)
{
    if(i<0 || j<0 || !dp[i][j] || dp[i][j]==-1)
    return;
    if(m[mp(i,j)] || vis[dp[i][j]])
    return;
    m[mp(i,j)]=1;
    if(s[i]==t[j])
    {
        vis[dp[i][j]]=1;
        print(i-1,j-1);
        ans+=s[i];
    }
    else
    {
        if(i && dp[i][j]==dp[i-1][j])
            print(i-1,j);
        if(j && dp[i][j]==dp[i][j-1])
            print(i,j-1);
    }
}


int main()
{
	sup; 
	cin>>s>>t;
	memset(dp,-1,sizeof(dp));
	solve(sz(s)-1,sz(t)-1);
	print(sz(s)-1,sz(t)-1);
	pr(ans);
	/*fab(i,0,sz(s))
	{
	    fab(j,0,sz(t))
	    {
	        if(dp[i][j]==-1 || dp[i][j]>9)
	            cout<<dp[i][j]<<" ";
	        else
	            cout<<" "<<dp[i][j]<<" ";
	        
	    }
	    cout<<endl;
	}*/
    return 0;
}


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

#define ll long long
#define ar array
 
using namespace std;



int main() {
	
	int a,b,c,d,e,f,maior,menor;
	
	cin >> a >> b >> c >> d >> e >> f;
	
	maior = e-a;
	
	if(maior > f){
		cout << ":(" <<endl;
	}else{
		cout << "Yay!" <<endl;
	}
	
	
   	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <limits.h>
#include <queue>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using ll = long long;

using namespace std;

ll pow_mod(ll a, ll b, ll p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

ll sum_digit(ll N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

ll gcd(ll a,ll b) {
	if (!b)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

typedef pair<int, int> P;

int H, W;
string maze[55];

int cost[55][55];

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

int bfs() {
	queue<P> que;
	rep(i, H)rep(j, W)cost[i][j] = INT_MAX;
	que.push(P(0, 0));
	cost[0][0] = 0;

	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == H - 1 && p.second == W - 1)break;
		rep(i, 4) {
			int nx = p.first + dx[i], ny = p.second + dy[i];

			if (0 <= nx && nx < H && 0 <= ny && ny < W&&maze[nx][ny] != '#'&&cost[nx][ny] == INT_MAX) {
				que.push(P(nx, ny));
				cost[nx][ny] = cost[p.first][p.second] + 1;
			}
		}
	}
	return cost[H - 1][W - 1];
}

int main(){
	scanf("%d %d", &H, &W);
	rep(i, H)cin >> maze[i];
	int cnt = 0;
	rep(i, H)rep(j, W)if (maze[i][j] == '.')cnt++;
	int dfg = bfs();
	if (dfg == INT_MAX)printf("-1");
	else printf("%d", cnt - dfg - 1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    string s;
    string p;
    cin >> s;
    cin >> p;
    bool flag = false;
    F(i, 0, s.size()){
        F(j, 0, p.size()){
            if(s[(i + j) % s.size()] != p[j]){
                goto nextloop;
            }
        }
        cout << "Yes" << endl;
        return 0;
nextloop :
        continue;
    }
    cout << "No" << endl;
    return 0;
}



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

typedef pair<int,int> P;
typedef pair<int,pair<int,int>> PP;
int main(){
	for(int w,h;;){
		cin>>w>>h;
		if(w+h==0)break;
		vector<vector<vector<P>>> g(w,vector<vector<P>>(h,vector<P>()));
		for(int d,i=1; i<=h; i++){
			for(int j=1; j<w; j++){
				cin>>d;
				if(!d){
					g[j-1][i-1].push_back(P(1,0));
					g[j][i-1].push_back(P(-1,0));
				}
			}
			if(i!=h){
				for(int j=0; j<w; j++){
					cin>>d;
					if(!d){
						g[j][i-1].push_back(P(0,1));
						g[j][i].push_back(P(0,-1));
					}
				}
			}
		}
		/*
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				cout<<g[j][i].size()<<" ";
			}
			cout<<endl;
		}
		*/
		vector<vector<int>> d(w,vector<int>(h,INT_MAX));
		priority_queue<PP, vector<PP>, greater<PP>> q;
		q.push(PP(d[0][0]=1,P(0,0)));
		for(;q.size();){
			int cost = q.top().first;
			P now = q.top().second;
			q.pop();
			for(P v : g[now.first][now.second]){
				v.first += now.first;
				v.second += now.second;
				if(cost+1 < d[v.first][v.second]){
					q.push(PP(d[v.first][v.second]=cost+1,v));
				}
			}
		}
		cout<<(d[w-1][h-1] < INT_MAX ? d[w-1][h-1] : 0)<<endl;
	}
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100000][3];
int b[100001][3];
int maximum(int a,int b,int c)
{
	int z=max(a,b);
	int res=max(z,c);
	return res;
}
int f(int x,int y)
{
	if(x==n-1)
	{
		return(a[x][y]);
	}
	if(b[x][y]!=0)
	return b[x][y];
	if(y==0)
	{
		b[x][y]=max(a[x][y]+f(x+1,1),a[x][y]+f(x+1,2));
		
	}
		if(y==1)
	{
		b[x][y]=max(a[x][y]+f(x+1,0),a[x][y]+f(x+1,2));
	}
		if(y==2)
	{
		b[x][y]=max(a[x][y]+f(x+1,0),a[x][y]+f(x+1,1));
	}
	
	return b[x][y];
	
}
int main()
{
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	int res;
	res=maximum(f(0,0),f(0,1),f(0,2));
	cout<<res<<endl;
}

Measured memory_bytes: 7296
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a >= b) {
				System.out.println(10);
			}
			else{
				System.out.println(0);
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination

signed main()
{
    int2(n, m);
    vb st(n, false), en(n, false);

    rep(i, m) {
        int2(a, b);
        if (a == 1) {
            st[b-1] = true;
        } else if (b == 1) {
            st[a-1] = true;
        } else if (a == n) {
            en[b-1] = true;
        } else if (b == n) {
            en[a-1] = true;
        }
    }

    rep(i, n) {
        if (st[i] && en[i]) {
            std::cout << "POSSIBLE" << std::endl;
            return 0;
        }
    }
    std::cout << "IMPOSSIBLE" << std::endl;


    return 0;
}




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

void Main()
{
  int N, K; cin >> N >> K;
  vector<int> x(N);
  rep(i,N) cin >> x[i];
  int minTime = 2e9;
  rep(i,N-K+1) {
    int iTime = abs(x[i]);
    if (x[i+K-1] > 0) iTime += x[i+K-1] - x[i];
    int iTime2 = abs(x[i+K-1]);
    if (x[i] < 0) iTime2 += x[i+K-1] - x[i];
    minTime = min(minTime, iTime);
    minTime = min(minTime, iTime2);
  }
  cout << minTime << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int a, p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){char s[15],a,i;
for(;fgets(s,15,stdin);){for(a=9;a>=0;a--)for(i=0;i<a;s[i]=(s[i]+s[i+1]-6)%10+48,i++);printf("%c\n",*s);}}

Measured memory_bytes: 0