akhauriyash/Code-Regression huggingface dataset:
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        String[] a = new String[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.next();
            if(a[i].equals("0")){
                System.out.println("0");
                return;
            }
        }

        BigInteger ans = new BigInteger("1");
        BigInteger val = new BigInteger("1000000000000000000");
        for(int i = 0; i < n; i++){

            BigInteger mul1 = new BigInteger(a[i]);

            ans = ans.multiply(mul1);

            if(ans.compareTo(val)==1){
                System.out.println("-1");
                return;
            }
        }

        System.out.println(ans.toString());

    }
}

Measured memory_bytes: 65248
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}



int main(){
	FIO
	
	stack<int> s[1100];
	int n, q;
	cin >> n >> q;
	while(q--){
		int op, t;
		cin >> op >> t;
		if(op == 0){
			int x;
			cin >> x;
			s[t].push(x);
		}else if(op == 1){
			if(s[t].empty());
			else cout << s[t].top() << '\n';
		}else{
			if(!s[t].empty())
				s[t].pop();
		}
	}
	return 0;
}



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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<bool>> v(M,vector<bool>(N,false));
    for (int i = 0; i < M; i++)
    {
        int k; cin >> k;
        for (int j = 0; j < k; j++)
        {
            int t; cin >> t;
            t--;
            v[i][t] = true;
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; i++)
    {
        cin >> p[i];
    }
    
    int ans = 0;
    for (int bit = 0; bit < (1<<N); bit++)
    {
        bool is_all_on = true;
        for (int i = 0; i < M; i++)
        {
            int cnt = 0;
            for (int j = 0; j < N; j++)
            {
                if((bit >> j) & 1) {
                    if(v[i][j]==true) cnt++;
                }
            }
            if(cnt%2!=p[i]){
                is_all_on = false;
                break;
            }
        }
        if(is_all_on) ans++;
    }
    cout << ans << endl;
        
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 10010
#define llg long long 
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,a[maxn];
int main()
{
	//yyj("A");
	for (llg i=2;i<=13;i++) a[i]=i-1;
	a[1]=13;
	cin>>n>>m;
	if (a[n]>a[m]) puts("Alice");
	if (a[n]==a[m]) puts("Draw");
	if (a[n]<a[m]) puts("Bob");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 6e6+3;
int a[N], s[N];
int n, x, qw = 555555;

struct Fenwick {
  void add(int p, int nu) {
    while (p <= qw) {
      s[p] += nu;
      p += p&-p;
    }
  }
  int ask(int p, int ans = 0) {
    for (; p > 0; p -= p & -p)
      ans += s[p];
    return ans;
  }
} f;

int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &x);
    x = min(x, qw);
    if (a[0] > 0 || (f.ask(x) == x && f.ask(qw) > f.ask(x))) { puts("No"); continue; }
    puts("Yes");
    for (; a[x] == 1; --x)
      a[x] = 0, f.add(x, -1);
    a[x] = 1; if (x > 0) f.add(x, 1);
  }
  return 0;
}


Measured memory_bytes: 7092
i = gets.split
gets.to_i.times do
  o = gets.split.map { |e| i.index(e) }.join(' ')
  ans =
  case o
  when /1 2|2 4|3 1|4 3/ then i[0]
  when /0 3|3 5|2 0|5 2/ then i[1]
  when /0 1|1 5|4 0|5 4/ then i[2]
  when /0 4|1 0|4 5|5 1/ then i[3]
  when /0 2|2 5|3 0|5 3/ then i[4]
  else i[5]
  end
  puts ans
end

Measured memory_bytes: 8664
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<climits>

using namespace std;

typedef pair<int,pair<int,int> >P;

struct Edge{
  int to,cost;
  Edge(int _to, int _cost):to(_to), cost(_cost){};
};

int minCost[101][11];
vector<Edge> edge[101];
static const int INF = INT_MAX;

int c,n,m,s,d;

int dijkstra(void){
  priority_queue<P, vector<P>, greater<P> >que;
  que.push(make_pair(0,make_pair(s,c)));

  for(int i=0;i<101;i++)
    for(int j=0;j<11;j++)
      minCost[i][j]=INF;

  while(!que.empty()){
    P p = que.top();
    que.pop();
    
    for(int i=0;i<edge[p.second.first].size();i++){
      Edge e = edge[p.second.first][i];
      if(p.first+e.cost < minCost[e.to][p.second.second]){
	minCost[e.to][p.second.second] = p.first+e.cost;
	que.push(make_pair(p.first+e.cost,make_pair(e.to,p.second.second)));
      }
    }
    
    if(p.second.second==0)continue;
    
    for(int j=0;j<edge[p.second.first].size();j++){
      Edge e = edge[p.second.first][j];
      if(p.first+e.cost/2 < minCost[e.to][p.second.second-1]){
	minCost[e.to][p.second.second-1] = p.first+e.cost/2;
	que.push(make_pair(p.first+e.cost/2,make_pair(e.to,p.second.second-1)));
      }
    }
  }
  int ans=INT_MAX;
  for(int i=0;i<11;i++)
    ans=min(minCost[d][i],ans);

  return ans;
}

int main(void){
  int a,b,f;

  while(cin >> c >> n >> m >> s >> d,c|n|m|s|d){

    for(int i=0;i<=n;i++)edge[i].clear();

    for(int i=0;i<m;i++){
      cin >> a >> b >> f;
      edge[a].push_back(Edge(b,f));
      edge[b].push_back(Edge(a,f));
    }

    cout << dijkstra() << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,ans=0,sum=0, Max=-1, Min=3e9+1;
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  pri(ans);
  return 0;
}

Measured memory_bytes: 3912
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		try
		{
			Scanner sc = new Scanner(System.in);
			int w, n, a, b, tmp;
			String input;

			w = sc.nextInt();
			n = sc.nextInt();

			int[] lots = new int[w];
			for(int i = 0; i < w; i++)
			{
				lots[i] = i + 1;
			}

			for(int i = 0; i < n; i++)
			{
				input = sc.next();
				String[] ab = input.split(",");
				a = Integer.parseInt(ab[0]) - 1;
				b = Integer.parseInt(ab[1]) - 1;

				tmp = lots[a];
				lots[a] = lots[b];
				lots[b] = tmp;
			}

			for(int i = 0; i < w; i++)
			{
				System.out.println(lots[i]);
			}
		}
		catch(InputMismatchException e)
		{
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 25852
def GCD(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if y==0:
        return x
    elif x%y==0:
        return y
    else:
        return GCD(y,x%y)

N,X=map(int,input().split())
x=list(map(int,input().split()))

ans=0

for xi in x:
    ans=GCD(ans,xi-X)

print(ans)

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int H, W, N;
  int table[100][100] = {0};

  scanf("%d%d%d", &H, &W, &N);

  int index = 0;
  FOR1(i, 1, N + 1) {
    int a;

    scanf("%d", &a);

    FOR(j, a) {
      table[index / W][min(index % (2 * W), 2 * W - index % (2 * W) - 1)] = i;
      index++;
    }
  }

  FOR(i, H) {
    FOR(j, W) printf("%d ", table[i][j]);
    printf("\n");
  }

  return 0;
}


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

int main() {
  int N, M, C;
  cin >> N >> M;
  vector<int> roads(N, 0);

  for (int i =0; i<2*M; i++){
    cin >> C;
    roads[C-1] ++;
  }
  for (int i=0; i< N; i++){
    cout << roads[i] << endl;
  }
}


Measured memory_bytes: 256
def binary_search(arr, target, n)
  left = 0
  right = n
  while left < right
    mid = (left + right) / 2
    if target == arr[mid]
      return 1
    elsif target < arr[mid]
      right = mid
    elsif target > arr[mid]
      left = mid + 1
    end
  end
  return 0
end

n = gets.to_i
S = gets.split.map(&:to_i)
q = gets.to_i
T = gets.split.map(&:to_i)
cnt = 0
T.each do |t|
  cnt += binary_search(S, t, n)
end
puts cnt



Measured memory_bytes: 15352
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    
    posi,zero,nega = [],[],[]
    for num in a:
        if num > 0:
            posi.append(num)
        elif num == 0:
            zero.append(num)
        else:
            nega.append(num)
            
    lp,lz,ln = len(posi),len(zero),len(nega)
    posi.sort(),nega.sort()
    posi,zero,nega = np.array(posi),np.array(zero),np.array(nega)
    _nega = nega[::-1]*(-1)
    
    def ch(x):
        if x == 0:
            return (lz*(lz-1))//2+lz*(lp+ln)+lp*ln
        elif x > 0:
            count = (lz*(lz-1))//2+lz*(lp+ln)+lp*ln
            puse = np.searchsorted(posi,(x//posi),side="right")
            pdup = np.count_nonzero(posi**2<=x)
            nuse = np.searchsorted(_nega,x//_nega,side="right")
            ndup = np.count_nonzero(_nega**2<=x)
            return (np.sum(puse)+np.sum(nuse)-pdup-ndup)//2+count
        else:
            count = np.searchsorted(nega,x//posi,side="right")
            return np.sum(count)

    l,r = -10**18-1,10**18+1
    while r-l > 1:
        mid = (r+l)//2
        if ch(mid) >= K:
            r = mid
        else:
            l = mid
    print(r)
    
if __name__ == "__main__":
    main()


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


int n, m;
int city[1000], weather[1000];
int dp[1001][1001];
int ans = 999999999;


void solve(){
	for (int i = 0; i < n; i++){
		for (int j = i; j < m; j++){
			dp[i + 1][j + 1] = min(dp[i+1][j], dp[i][j] + city[i] * weather[j]);
		}
	}
	for (int i = 0; i <= m; i++)
		ans = min(ans, dp[n][i]);
}


int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> city[i];
	for (int i = 0; i < m; i++)	cin >> weather[i];

	for (int i = 1; i < 1001; i++)
		for (int j = 0; j < 1001; j++) dp[i][j] = 999999999;

	solve();

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
#include <cstdint>

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

int n;
cin >> n;
vi a(n-1),ans(n);
rep(i,n-1) cin >> a[i];
Sort(a);
ans[n-1] = 0;
rep(i,n-1){
  ans[a[i]-1]++;
}
rep(i,n) cout << ans[i] << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n;
string s;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	int ans=0,a=0,b=0,c=0;
	fo(i,0,n){
		cin>>s;
		fo(j,0,s.size()-1) if(s[j]=='A'&&s[j+1]=='B')ans++;
		if(s[0]=='B'&&s[s.size()-1]=='A')c++;
		else if(s[0]=='B')b++;
		else if(s[s.size()-1]=='A')a++;
	}
	if(a==0&&b==0)ans+=max(c-1,0);
	else ans+=c+min(a,b);
	cout<<ans<<endl;
	return 0;
}

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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    rep(i, h) {
      rep(j, w) {
        if ((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0)) cout << '#';
        else cout << '.';
        if (j == w - 1) cout << endl;
      }
      if (i == h - 1) cout <<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3076
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [a, b, c] = input[0].split(' ').map(x => parseInt(x))

  if (c >= a && c <= b) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29644
#include <cstdio>
#include <cstdlib>
#include <queue>

char map[1000][1000];
int check[1000][1000];
int cx[10];
int cy[10];

int main(){
	int i,j,k,l,h,w,ch,pd=0;
	int tex,tey,ted;
	std::queue<int> qx;
	std::queue<int> qy;
	std::queue<int> qd;

	scanf("%d %d %d",&h,&w,&ch);
	scanf("%c",&map[0][0]);
	for(i=0;i<h;i++){
		for(j=0;j<=w;j++){
			scanf("%c",&map[i][j]);
			if(map[i][j]=='S'){cy[0]=i; cx[0]=j;}
			if(map[i][j]=='1'){cy[1]=i; cx[1]=j;}
			if(map[i][j]=='2'){cy[2]=i; cx[2]=j;}
			if(map[i][j]=='3'){cy[3]=i; cx[3]=j;}
			if(map[i][j]=='4'){cy[4]=i; cx[4]=j;}
			if(map[i][j]=='5'){cy[5]=i; cx[5]=j;}
			if(map[i][j]=='6'){cy[6]=i; cx[6]=j;}
			if(map[i][j]=='7'){cy[7]=i; cx[7]=j;}
			if(map[i][j]=='8'){cy[8]=i; cx[8]=j;}
			if(map[i][j]=='9'){cy[9]=i; cx[9]=j;}
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<=w;j++)check[i][j]=0;
	}

	i=0;
	while(i<ch){
		qx.push(cx[i]); qy.push(cy[i]); qd.push(0);
		++i;
		while(!qx.empty()){
			tex=qx.front(); tey=qy.front(); ted=qd.front();
			qx.pop(); qy.pop(); qd.pop();
			check[tey][tex]=1;
			if(tey==cy[i] && tex==cx[i]){
				pd+=ted;
				while(!qx.empty())qx.pop();
				while(!qy.empty())qy.pop();
				while(!qd.empty())qd.pop();
				for(k=0;k<h;k++){
					for(l=0;l<=w;l++)check[k][l]=0;
				}
				break;
			}
			++ted;
			if(tex+1<w && map[tey][tex+1]!='X' && check[tey][tex+1]==0){
				check[tey][tex+1]=1;
				qx.push(tex+1); qy.push(tey); qd.push(ted);
			}
			if(tex-1>=0 && map[tey][tex-1]!='X' && check[tey][tex-1]==0){
				check[tey][tex-1]=1;
				qx.push(tex-1); qy.push(tey); qd.push(ted);
			}
			if(tey+1<h && map[tey+1][tex]!='X' && check[tey+1][tex]==0){
				check[tey+1][tex]=1;
				qx.push(tex); qy.push(tey+1); qd.push(ted);
			}
			if(tey-1>=0 && map[tey-1][tex]!='X' && check[tey-1][tex]==0){
				check[tey-1][tex]=1;
				qx.push(tex); qy.push(tey-1); qd.push(ted);
			}
		}
	}

	printf("%d\n",pd);
	return 0;
}

Measured memory_bytes: 5932
<?php
fscanf(STDIN, '%d', $N);
$DX = explode(' ', fgets(STDIN));
$span = $DX[0];
$chocolates = $DX[1];
$AN = [];
for($i = 0; $i < $N; $i++) {
    fscanf(STDIN, '%d', $temp);
    $AN[] = $temp;
}
//var_dump($DX);
//var_dump($AN);
foreach($AN as $day) {
    for($j = 0; $j < $span; $j++) {
        $temp = $j * $day + 1;
//var_dump($temp);
        if($temp > $span) {
            break;
        } else {
            $chocolates += 1;
        }
    }
}
echo $chocolates;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vi nums(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    ll ans = 0;
    int l = 0;
    int r = 0;
    int now = 0;
    while (l < n) {
        while (r < n && (nums[r] ^ now) == nums[r] + now) {
            ++ans;
            now ^= nums[r++];
        }
        now ^= nums[l++];
        ans += (r - l);
    }
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int a,i,num,b[27]={0};
    char c;
    
    scanf("%c",&c);
    num = c - 'A';
    b[num]++;
    for(i=0;i<1201;i++){
        scanf("%c",&c);
        if(c>96){
            num = c - 'a';
        }else{
            num = c - 'A';
        }
        b[num]++;
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,b[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
//おまじない
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  string s;
  cin>>s;
  
  sort(s.begin(), s.end());
  
  int b=0;
  if(s.at(0)!=s.at(1)){
    b++;}
  if(s.at(2)!=s.at(3)){
    b++;}
  if (s.at(0)==s.at(2)){
    b++;}
  
  
  if(b==0){
    cout<<"Yes"<<endl;}
  else{
    cout<<"No"<<endl;}
  }
    
  


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> bool chmax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main() {
    string s, t;
    cin >> s >> t;
    int sl = s.size();
    int tl = t.size();
    int ans = INF;
    for (int i = 0; i < sl - tl + 1; ++i) {
        int cnt = 0;
        for (int j = 0; j < tl; ++j) {
            if (t[j] != s[i + j])
                cnt++;
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
	int N;
	vector<int> V;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		V.push_back(tmp);
	}
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		if (V[i]-tmp < 0)
		{
			V[i] = 0;
		}
		else
		{
			V[i] -= tmp;
		}
	}
	
	cout << accumulate(V.begin(), V.end(),0) << endl;
}

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

int main(){
  int A,B,C,D;
  int Taka=0;
  int Aoki=0;
  cin >>A >>B >>C >>D;
  
  for (int i=0; C>0; i++){
    C -=B;
    Taka++;
  }
  for (int i=0; A>0; i++){
    A -=D;
    Aoki++;
  }

  if (Taka == 1)
    cout << "Yes" <<endl;
  else if (Aoki >= Taka)
    cout << "Yes" <<endl;
  else
    cout << "No" <<endl;
  
  
}

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

int main() {
    int x, y;
    cin >> x >> y;
    for (int c = 0; c <= x; c++)
    {
        int t = x - c;
        if (2 * c + 4 * t == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

int main(){

  int n,x;
  cin>>n>>x;
  vector<int> m;

  int nokori = 0;
  int sum = 0;
  int Min = 111111111;
  for(int i = 0;i<n;i++){
    int tmp;
    cin>>tmp;
    m.push_back(tmp);
    sum += tmp;
    Min = min(Min,tmp);
    
  }
  int ans = (x-sum)/Min;

  cout<<n+ans<<endl;


  return 0;
}


Measured memory_bytes: 256
#include  <stdio.h>

int  main()
{
    int m,n,c=0;
    int i;
    scanf("%d%d",&m,&n);
    if(m>1)
    {
    	c = m*(m-1)/2;
	}
	if(n>1)
	{
		c += n*(n-1)/2;
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0){
            break;
        }
        int cnt[11];
        fill(cnt,cnt+11,0);
        int ans = 0;
        rep(i,n){
            int a,b;
            cin >> a >> b;
            cnt[b] += a;
            ans += a*b;
        }
        int hoge = 10;
        int rem = m;
        while(hoge >= 0){
            if(rem - cnt[hoge] >= 0){
                rem -= cnt[hoge];
                ans -= cnt[hoge]*hoge;
                hoge--;
            }else{
                ans -= rem*hoge;
                break;
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 3088
s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
pre = ""
nex = ""
c = 1
TFC = [input().split() for _ in range(q)]
for i in TFC:
# for j in range(q):
#     i = list(map(str,input().split()))
    if i ==["1"]:
        c *= -1
        # s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        # s = i[2]+s
        if c == 1:
            pre=i[2]+pre
        else:
            nex = nex + i[2]
    elif i[0]=="2" and i[1]=="2":
        # s = s +i[2]
        if c ==1:
            nex = nex +i[2]
        else:
            pre = i[2]+pre
s = pre+s+nex
if c ==-1:
    s = s[::-1]
print(s)

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

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

typedef long long ll;

int main(){
  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  ll a[x],b[y],c[z];
  for(int i=0;i<x;i++) cin >> a[i];
  for(int i=0;i<y;i++) cin >> b[i];
  for(int i=0;i<z;i++) cin >> c[i];
  ll sum[x*y];
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      sum[i*y+j]=a[i]+b[j];
    }
  }
  sort(sum,sum+x*y);
  ll t=min(k,x*y);
  ll d[t];
  for(int i=0;i<t;i++){
    d[i]=sum[x*y-i-1];
  }
  ll ans[t*z];
  for(int i=0;i<t;i++){
    for(int j=0;j<z;j++){
      ans[i*z+j]=d[i]+c[j];
    }
  }
  sort(ans,ans+t*z);
  for(int i=0;i<k;i++){
    cout << ans[t*z-i-1] << endl;
  }
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    ll n;
    cin >> n;
    ll a[10005];
    ll b[10005];
    ll p[1000005] = {0};
    ll c = 1;
    ll cnt = 0;
    rep(i,n){
        cin >> a[i];
        b[i] = a[i];
        rep(j,2,sqrt(a[i])/1+1){
            cnt = 0;
            while(a[i]%j == 0){
                a[i] /= j;
                cnt++;
            }
            chmax(p[j],cnt);
        }
        if (a[i] != 1) chmax(p[a[i]],(ll)1);
    }
    rep(i,1000001){
        if (p[i] != 0){
            rep(j,p[i]){
                c *= i;
                c %= MOD;
            }
        }
    }
    ll ans = 0;
    rep(i,n){
        ans += c*modinv(b[i],MOD)%MOD;
        ans %= MOD;
    }
    PRINT(ans);
}

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

int main() {
    int A, B; cin >> A >> B;
    if (A != 1 && B != 1) {
        cout << 1 << endl;
    }
    if (A != 2 && B != 2) {
        cout << 2 << endl;
    }
    if (A != 3 && B != 3) {
        cout << 3 << endl;
    }
}

Measured memory_bytes: 256
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"81 58
" => r"110",

r"4 54
" => r"31"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: i32,
        y: i32
    }

    (x + (y / 2)).to_string()
}


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

#define int long long


signed main()
{
    string s, t, u;
    cin >> s >> t >> u;
    cout << (char)toupper(s[0]) << (char)toupper(t[0]) << (char)toupper(u[0]) << endl;
    return 0;
}



Measured memory_bytes: 256
function bomb(y,x){
   if(N==max)return;
   if(x<0)x=n-1;
   if(y<0)y=n-1;
   if(x>=n)x=0;
   if(y>=n)y=0;
   if(yx[y][x]!=-1){bomb(y+1,x-1);}
   else{yx[y][x]=("   "+N).slice(-4);N++;bomb(y+1,x+1);}
}
 
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i++){
   var n=Arr[i];
   var max=n*n+1;
   if(n==0)break;
   var yx=[];
   for(var j=0;j<n;j++){
      yx[j]=[];
      for(var k=0;k<n;k++){
         yx[j][k]=-1;
      }
   }
   var N=1;
   bomb(Math.floor(n/2)+1,Math.floor(n/2));
   console.log(yx.join("\n").replace(/\,/g,""));
}

Measured memory_bytes: 8648
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int A,B;
    cin>>A>>B;
    if(A>0&&A<10&&B>0&&B<10) cout<<A*B<<endl;
    else cout<<"-1"<<endl;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple3<T: std::str::FromStr + Copy>() -> (T, T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 3);
  (v[0], v[1], v[2])
}

fn read_touple4<T: std::str::FromStr + Copy>() -> (T, T, T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 4);
  (v[0], v[1], v[2], v[3])
}

fn main() {
   use std::cmp::max;
    let (n, m, q) = read_touple3::<usize>();
    let mut Q = vec![];
    for _ in 0..q {
      let (a, b, c, d) = read_touple4::<usize>();
      Q.push((a- 1, b  - 1, c, d));
    }


    let mut vs = vec![];
    make_vec(m, n, 0, 1, vec![], &mut vs);
    let mut ans = 0;
    for v in &vs {
      let mut hoge = 0;
      for &(a, b, c, d) in &Q {
        if v[b] - v[a] == c {
          hoge += d;
        }
      }

      ans = max(ans, hoge);
    }

    println!("{}", ans);

}

fn make_vec(m: usize, n: usize, pos: usize, now: usize, v: Vec<usize>, data: &mut Vec<Vec<usize>>) {
    if pos == n {
      data.push(v);
      return
    }

    for i in now..=m {
      let mut t = v.clone();
      t.push(i);
      make_vec(m, n, pos+1, i, t, data);
    }
}

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

const int INF = 99999999;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> vW(N+1,0), vE(N+1,0);
    for(int i=0; i<N; i++){
        vW[i+1] += vW[i];
        if(S[i] == 'W') vW[i+1]++;
        vE[i+1] += vE[i];
        if(S[i] == 'E') vE[i+1]++;
    }
    int ans = INF;
    for(int i=0; i<N; i++){
        int now = vW[i] + (vE[N]-vE[i+1]);
        if(ans > now) ans = now;
    }
    cout << ans << endl;
    return 0;
}

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

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

int main(){
  int     n, a[100] = {0};
  scanf("%d", &n);
  for(int i=0; i<n; i++){ scanf("%d", &a[i]); }
  qsort( a, n, sizeof(int), compare_int );
  
  printf("%d", a[n-1]-a[0]);
  
  return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
long long n,k,z,x,c,s,a[200001],b[200001];
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++)cin>>a[i],b[i]=1000000000;
    b[0]=10000000001;
    b[1]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=k; j++)
            b[i+j]=min(b[i]+(abs(a[i]-a[i+j])),b[i+j]);
    }
    if(n==1)cout<<a[1]<<endl;
    else cout<<b[n]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	ll n; cin>>n;

	rep(i,1,3600){
		rep(j,1,3600){
			double k=(4*i*j)-(j*n)-(i*n);
			if(k==0)continue;
			double l=(n*i*j)/k;
			ll a=l;
			double b=a;
			if(b==l && a>0){
				cout<<i<<" "<<j<<" "<<a<<endl;
				return 0;
			}
		}
	}



	return 0;
}

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

int main()
{
    ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    long long int sum=0,i,n,mx;
    cin>>n;

    vector<long long int> v(n);
    for(i=0;i<n;i++)
        cin>>v[i];
        mx=v[0];
    for(i=1;i<n;i++)
    {
        if(mx>v[i])
        {
            sum+=mx-v[i];


        }
        else mx=v[i];

    }
    cout <<sum;







}


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

using namespace std ;
#define rep(i,n) for(int i =0 ; i < int (n); i++)
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



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

	int a ; 
	cin>> a;
	if(a % 1000 == 0){
		cout << 0;
	}
	else{
		int ans = 1000 - a % 1000 ;
		cout << ans;
	}
	

	return 0 ;
}

Measured memory_bytes: 3640
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    K -= 1
    a1_i = A.index(1)
    left = (a1_i + K - 1) // K
    right = (N - 1 - (left * K) + K - 1) // K
    print(left + right)

if __name__ == '__main__':
    main()


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



int n, k;
vector<int> a;
int dp[2][100005];

int solve(int turn, int left){
	if(left < a[0]){
		if(turn == 1) return 0;
		if(turn == 0) return 1;
	}
	
	if(dp[turn][left] != -1) return dp[turn][left];
	
	if(turn == 0){
		int tmp = 1;
		for(int i=0; i<n; i++){
			if(left - a[i] >= 0){
				tmp = solve(1, left - a[i]);
				if(tmp == 0) break;
			}
		}
		dp[turn][left] = tmp;
	}
	else{
		int tmp = 0;
		for(int i=0; i<n; i++){
			if(left - a[i] >= 0){
				tmp = solve(0, left - a[i]);
				if(tmp == 1) break;
			}
		}
		dp[turn][left] = tmp;
	}
	
	return dp[turn][left];
}

int main(){
	cin >> n >> k;
	a = vector<int>(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	
	sort(a.begin(), a.end());
	
	for(int i=0; i<2; i++){
		for(int j=0; j<=k; j++){
			dp[i][j] = -1;
		}
	}
	
	int flag = solve(0, k);
	
	if(flag == 0){
		cout << "First" << endl;
	}
	if(flag == 1){
		cout << "Second" << endl;
	}
	
	return 0;
}


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

int main(void){
    int n;
    cin >> n;

    int64_t ans = 1;
    int64_t divisor = 1e9 + 7;

    for(int i = 1; i <= n; i++){
        ans = (ans * i ) % divisor;
    } 

    printf("%ld\n", ans);
}

Measured memory_bytes: 256
#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;

/*
 <url:https://arc085.contest.atcoder.jp/tasks/arc085_b>
 問題文============================================================
 N 枚のカードからなる山札があります。カードにはそれぞれ数が書かれており，
 上から i 枚目には ai が書かれています。
 
 この山札を使い，X さんと Y さんが 2 人でゲームをします。
 X, Y さんは最初，Z,W が書かれたカードを持っています。 そして X さんから交互に以下を行います。
 
 山札から何枚かカードを引く。そして今持っているカードを捨て，最後に引いたカードを代わりに持つ。
 ただし，必ず 1 枚は引かなくてはならない。
 山札がなくなるとゲームは終了で，2 人の持っているカードに書かれた数の差の絶対値がこのゲームのスコアになります。
 
 X さんはスコアを最大化するように，Y さんはスコアを最小化するようにゲームをプレイした時，
 スコアはいくつになるでしょうか？
 
 =================================================================
 
 解説=============================================================
 
 よくよく考えると 最適にするには X君は a_N or a_N-1 のカードをとらなければ行けないことがわかる
 よって O(1)
 
 
 ちなみに min-max法 + αβ法　を使えば　ゴリ押せる
 
 ================================================================
 */

// ===================================== //
// O(1)
void solve1(){
    ll N,Z,W; cin >> N >> Z >> W;
    vector<ll> a(N);
    for(auto &in:a) cin >> in;
    if(N != 1){
        cout << max({abs(a[N-1] - W),abs(a[N-2] - a[N-1])}) << endl;
    }else{
        cout << abs(a[N-1]-W) << endl;
    }
}

// ===================================== //
// minmax + αβ
ll N, Z, W;
ll dp[2001][2001];
vector<ll> a;
ll rec(ll i,ll j, ll k,ll alpha, ll beta) {
    ll& res = dp[i][j];
    if (res != -LINF)return res;
    if (i == N || j == N) {
        ll X = (i == 0) ? Z : a[i];
        ll Y = (j == 0) ? W : a[j];
        res = abs(X - Y);
        return res;
    }
    if (k == 1) {
        res = LINF;
        for (int y = i + 1; y <= N;y++) {
            res = min(res, rec(i, y, 0, alpha, res));
            if (alpha >= res) {
                return alpha;
            }
        }
    }
    else {
        for (int x = j + 1; x <= N;x++) {
            res = max(res, rec(x, j, 1, res, beta));
            if (res >= beta) {
                return beta;
            }
        }
    }
    return res;
}
void solve_minmax(){
    cin >> N >> Z >> W;
    a.resize(N + 1);
    for (int i = 1; i <= N;i++) cin >> a[i];
    for (int i = 0; i <= N;i++) {
        for (int j = 0; j <= N;j++) {
            dp[i][j] = -LINF;
        }
    }
    cout << rec(0, 0, 0, -LINF, LINF) << endl;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    solve1();
//    solve_minmax();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

///////////////////////////



int main() {

	ll H, W;
	ll a[1000][1000];

	cin >> H >> W;

	repn(i, H) {
		repn(j, W) {
			cin >> a[i][j];
		}
	}

	vector<ll> x,y,xx,yy;

	repn(i, H) {
		repn(j, W - 1) {
			if (a[i][j] % 2 == 1) {
				x.push_back(i);
				y.push_back(j);
				xx.push_back(i);
				yy.push_back(j + 1);
				a[i][j]--;
				a[i][j + 1]++;
			}
		}
	}

	repn(i, H - 1) {
		if (a[i][W] % 2 == 1) {
			x.push_back(i);
			y.push_back(W);
			xx.push_back(i + 1);
			yy.push_back(W);
			a[i][W]--;
			a[i + 1][W]++;
		}
	}

	cout << x.size()<<endl;

	rep(i, x.size()) {
		cout << x[i] << " " << y[i] << " " << xx[i] << " " << yy[i] << endl;
	}
	

	system("PAUSE");
}

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

int main()
{
    double l;
    cin >> l;
    cout << fixed << setprecision(15);
    cout << (l/3)*(l/3)*(l/3) << endl;
    return 0;
}

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

using namespace std;
using ll=long long;

int main(){

  ll n,p;
  cin>>n>>p;
  
  unordered_map<ll,int> mp;
  for(ll i=2;i*i<=p;i++){
    while(p%i==0){
      mp[i]++;
      p/=i;
    }
  }
  if(p!=1)mp[p]++;
  
  ll ans=1;
  for(auto&[k,v]:mp){
    for(int i=0;i<v/n;i++)ans*=k;
  }
  
  cout<<ans<<endl;
}
      


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

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

using namespace std;
using lint=long long;

int main(){
	lint x; cin>>x;

	lint m=(x+10)/11,n=(x+4)/11;
	cout<<min(2*m,2*n+1)<<'\n';

	return 0;
}


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

nums = []
def inc(num):
    if num > 3234566667:
        return None
    if num <= 3234566667:
      nums.append(num)

    num_str = str(num)
    end = num_str[-1:]
    end_num = int(end)

    if end_num < 9:
        inc(int(num_str + str(end_num + 1)))
   
    inc(int(num_str + end))
    
    if end_num > 0:
        inc(int(num_str + str(end_num - 1)))

for i in range(1, 10):
    inc(i)

sort_nums = sorted(nums)
print(sorted(nums)[k - 1])

Measured memory_bytes: 8880
import java.math.*;
import java.io.*;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    br.readLine();
    String str[] = br.readLine().split(" ");
    
    BigInteger d[] = new BigInteger[str.length];
    BigInteger v = BigInteger.ONE;
    
    for(int i = 0; i < str.length; i++) {
      d[i] = new BigInteger(str[i]);
      v = v.multiply(d[i]);
    }
    v = v.subtract(BigInteger.ONE);
    
    BigInteger t = BigInteger.ZERO;
    for(int i = 0; i < str.length; i++) {
      t = t.add(v.remainder(d[i]));
    }
    
    System.out.println(t);
  }
}


Measured memory_bytes: 46804
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      	int num = Integer.parseInt(line);
        int count = 0;
        Double result;
      	if(num == 1) {
          result = 1.0;
          System.out.println(result);
        } else {
          for(int i=1; i <= num; i++) {
            if(i % 2 != 0) {
              count++;
            }
          }
          result = (double)count / (double)num;
          System.out.println(result);
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=501234;

int n,a[17][17],bt[17],flg[1<<17];
ll dp[1<<17],dp2[1<<17];
queue<int> q2;

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
        for(int j=0; j<n; ++j) scanf("%d",&a[i][j]);
    for(int i=1; i<=n+1; ++i) bt[i]=1<<i-1;
    for(int i=2; i<=n; ++i)
        for(int i2=bt[i]+1; i2<bt[i+1]; ++i2)
            for(int j=1; j<i; ++j) if((i2>>j&1)==1)
                    for(int k=0; k<j; ++k) if((i2>>k&1)==1) dp[i2]+=a[j][k];
    for(int i=2; i<=n; ++i)
        for(int i2=bt[i]+1; i2<bt[i+1]; ++i2){
            int s=i2;
            do{
                ll tmp3=dp[s]+dp2[s^i2];
                if(dp2[i2]<tmp3) dp2[i2]=tmp3;
                s=i2&(s-1);
            }while(s>=bt[i]);
        }
    printf("%lld",dp2[(1<<n)-1]);
    return 0;
}


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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var k = long.Parse(inputs[1]);

            var s = Console.ReadLine();

            var result = "";

            for (var i = 0; i < n; i++)
            {
                result += i == k - 1 ? s[i].ToString().ToLower() : s[i].ToString();
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27524
#include <bits/stdc++.h>
#define MAXN 200005
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
using namespace std;

ll a[MAXN], n, x = 1, temp, sol;
bool flag = false;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		if (temp == x) {a[x]++; flag = true;}
		else if (temp == x + 1 and flag) {x++; a[x]++;}
		else sol++;
	}
	for (int i = 0; i <= n + 1; i++) {
		if (a[i]) sol += (a[i] - 1);
	}
	flag ? cout << sol : cout << -1;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<deque>
#define jio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
//#define mp make_pair
#define pb push_back
#define lld long long int
#define clr clear()
#define ff first
#define ss second
#define N 1000005
//#define M 1000
#define endl '\n'
#define c_s_b() __builtin_popcount()

#define sze 10000009
#define pii pair<int,int>
#define big 100009
#define int long long

using namespace std;

int n,m;
vector<int>v1;
int act1[big],act2[big],act3[big];
 int dp[big][2][2][2];
bool ok1=true,ok2=true,ok3=true;

int fun(int index,bool ok1,bool ok2,bool ok3){
    if(index>n) return INT_MIN;
    if(index==n) return 0;
    if(dp[index][ok1][ok2][ok3]!=-1) return dp[index][ok1][ok2][ok3];


return dp[index][ok1][ok2][ok3]=max((ok1?act1[index]+fun(index+1,0,1,1):INT_MIN),max((ok2?act2[index]+fun(index+1,1,0,1):INT_MIN),(ok3?act3[index]+fun(index+1,1,1,0):INT_MIN)));


}


int32_t main(){
   jio;
    cin>>n;
    for(int i=0;i<n;i++){
         cin>>act1[i]>>act2[i]>>act3[i];
    }
    // memset(dp,-1,sizeof(dp));
    for(int i=0;i<big;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                for(int l=0;l<2;l++){
                    dp[i][j][k][l]=-1;
                }
            }
        }
    }
    int minm_cst=fun(0,true,true,true);


    cout<<minm_cst<<endl;






    return 0;


}


Measured memory_bytes: 18176
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val A = new Array[Int](M)
  for (i <- 0 until M)
    A(i) = in.next().toInt

  //
  val map = Map(
    1 -> 2, 2 -> 5, 3 -> 5,
    4 -> 4, 5 -> 5, 6 -> 6,
    7 -> 3, 8 -> 7, 9 -> 6
  )


  val dp = new Array[Int](N+1)
  val init = -1
  for (i <- 0 to N)
    dp(i) = init

  dp(0) = 0
  for (i <- 1 to N) {
    for (e <- A) {
      val diff = i - map(e)
      if (diff >= 0) {
        if (dp(i) == 0)
          dp(i) = dp(diff) + 1
        else
          dp(i) = Math.max(dp(i), dp(diff) + 1)
      }
    }
  }

  var now = N
  var ans = ""
  while (now > 0) {
    breakable {
      for (i <- (1 to 9).reverse) {
        val diff = now - map(i)
        if (A.contains(i) && diff >= 0) {
          if (dp(diff) == dp(now) - 1) {
            now = diff
            ans += i.toString
            break
          }
        }
      }
    }
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 63428
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = a * a * Math.PI;
        double c = a * 2 * Math.PI;
        System.out.println(String.format("%.6f", b) + " " + String.format("%.6f", c));

    }

}


Measured memory_bytes: 28112