akhauriyash/Code-Regression huggingface dataset:
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    vector<int> a(5);
    rep(i,5) cin >> a[i];
    Cini(k);
    sort(All(a));
    if (*max_element(All(a)) - *min_element(All(a)) > k) { cout << ":("<<nn; return 0; }
    cout << "Yay!" << nn;
    return 0;
}

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

const int MOD = 998244353;
inline void Add(int &x, int y) { (x += y) >= MOD && (x -= MOD); }

int n;
char s[310];
int dp[310][310][310];
// dp[pos][cnt0][cnt1]
bool can[310][310][310];
// can[pos][cnt0][cnt1]

int main() {
	scanf(" %s", s + 1), n = strlen(s + 1);
	dp[n + 1][0][0] = 1;
	for (int i = n + 1; i; --i)
		for (int j = 0; j <= n; ++j)
			for (int k = 0; k <= n; ++k) {
				Add(dp[i - 1][j][k], dp[i][j][k]);
				int c = s[i - 1] & 15;
				if (!c) Add(dp[i][j][k + 1], dp[i][j][k]);
				else Add(dp[i][j + 1][k], dp[i][j][k]);
			}
	can[0][0][0] = true;
	for (int i = 0; i <= n; ++i)
		for (int j = n; ~j; --j)
			for (int k = n; ~k; --k) if (can[i][j][k]) {
				if (j) can[i][j - 1][k] = true;
				if (k) can[i][j][k - 1] = true;
				can[i + 1][j][k] = true;
				if (i < n && s[i + 1] == '0' && k) can[i + 1][j + 1][k - 1] = true;
				if (i < n && s[i + 1] == '1' && j) can[i + 1][j - 1][k + 1] = true;
				if (i < n - 1 && (s[i + 1] == '0' || s[i + 2] == '0')) can[i + 2][j + 1][k] = true;
				if (i < n - 1 && (s[i + 1] == '1' || s[i + 2] == '1')) can[i + 2][j][k + 1] = true;
			}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			for (int k = 0; k <= n; ++k) if (can[i][j][k]) Add(ans, dp[i + 1][j][k]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 123072
#include<stdio.h>
int main(){
    unsigned short usW_D_num;                /* 情報量の格納用変数 */
    unsigned short usW_D_house[4][3][10];    /* 部屋情報の格納用変数 */
    unsigned short usW_D_bil;                /* 棟番号の格納用変数 */
    unsigned short usW_D_flor;               /* 階数の格納用変数 */
    unsigned short usW_D_room;               /* 部屋番号の格納用変数 */
    signed long  ulW_D_riside;              /* 入居者数の格納用変数 */
    unsigned short i, j, k;            /* ループ変数 */

    /* 配列の初期化 */
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                usW_D_house[i][j][k] = 0;
            }
        }
    }

    /* 情報量の入力 */
    scanf("%d", &usW_D_num);
    /* 入居者変更情報の入力 */
    for(i = 0;i < usW_D_num;i++){
        /* 入居者変更情報の入力 */
        scanf("%d %d %d %d", &usW_D_bil, &usW_D_flor, &usW_D_room, &ulW_D_riside);
        /* 入居者変更情報の加算 */
        usW_D_house[usW_D_bil - 1][usW_D_flor - 1][usW_D_room - 1] += ulW_D_riside;
    }

    /* 部屋情報の出力 */
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                /* 各部屋の入居者の出力 */
                printf(" %d", usW_D_house[i][j][k]);
            }
            /* 階の区切り */
            printf("\n");
        }
        /* 第四棟でない場合棟を区切る */
        if(i != 3){
           /* 棟の区切り */
           printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
}





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

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
long long A[100010], B[100010], ans;
int main(void) {
	int N, i, j;
	scanf("%d", &N);
	for(i=0; i<N+1; i++)
		scanf("%lld", &A[i]);
	for(i=0; i<N; i++)
		scanf("%lld", &B[i]);
	for(i=N-1; i>=0; i--){
		if(A[i+1]>=B[i]){
			A[i+1]-=B[i];
			ans+=B[i];
			B[i]=0;
		}
		else{
			B[i]-=A[i+1];
			ans+=A[i+1];			
			A[i+1]=0;			
		}
		if(A[i]>=B[i]){
			A[i]-=B[i];
			ans+=B[i];			
			B[i]=0;
		}
		else{
			B[i]-=A[i];
			ans+=A[i];
			A[i]=0;
		}
	}	
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		int currentSum =0;

		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			currentSum += w;
			list.add(currentSum);
		}

		int minimunDiff=10000;
		for (int sum : list) {
			int currentDiff =Math.abs((currentSum-sum)-sum);
			minimunDiff = Math.min(minimunDiff, currentDiff);
		}
		System.out.println(minimunDiff);

	}

}


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

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

    n,m = map(int, input().split())
    xyz = [list(map(int, input().split())) for _ in range(m)]

    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    
    def unite(x,y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x,y = y,x
            par[x] += par[y]
            par[y] = x
            return True
    
    def same(x,y):
        return find(x) == find(y)
    
    def size(x):
        return -par[find(x)]
    
    #全ての根の要素を返す
    def roots():
        return [i for i, x in enumerate(par) if x < 0]
    
    par = [-1]*n

    for x,y,z in xyz:
        if same(x-1, y-1):
            continue
        unite(x-1, y-1)

    res = len(roots())
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32496
// AOJ 585 Nearest Two Points
// 2017.9.24 bal4u
// 2018.3.17
// 2018.5.3

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int x, y; } PP;

#define INF  0x10101010

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

PP p[500005], L[500005], R[500005];

#define BASE 10000
#define VMAX 20002
int f[VMAX+1];
void distsort(int n, PP *ps, PP *po)
{
	int i, x;
	PP *p, *end;

	end = ps + n;
	for (p = ps; p < end; p++) f[BASE + p->x]++;
	for (i = 1; i <= VMAX; i++) f[i] += f[i-1];
	for (i = n-1; i >= 0; i--) {
		x = BASE + ps[i].x, po[--f[x]] = ps[i];
	}
}

void merge(PP *p, int low, int mid, int high)
{
	int n1, n2, i, j, k;

	n1 = mid-low, n2 = high-mid;
	memcpy(L, p+low, sizeof(PP)*n1);
	memcpy(R, p+mid, sizeof(PP)*n2);
	L[n1].y = R[n2].y = INF;

	i = 0, j = 0;
	for (k = low; k < high; k++) {
		if (L[i].y <= R[j].y) p[k] = L[i++];
		else                  p[k] = R[j++];
	}
}

int closest_pair(int n, PP *p)
{
	int m, i, j, t;
	int ans, d, x;

	if(n <= 1) return INF;
	m = n >> 1;
	x = p[m].x;
	ans = closest_pair(m, p);
	d   = closest_pair(n-m, p+m);
	if (d < ans) ans = d;
	merge(p, 0, m, n);

	t = 0;
	for (i = 0; i < n; i++) {
		d = p[i].x-x;
		if (d*d >= ans) continue;

		for (j = 0; j < t; j++) {
			int dx = p[i].x - L[t-1-j].x;
			int dy = p[i].y - L[t-1-j].y;
			int dy2 = dy*dy;
			if (dy2 >= ans) break;
			d = dx*dx + dy2;
			if (d < ans) ans = d;
		}
		L[t++] = p[i];
	}
	return ans;
}

int main()
{
	int n, i;

	n = in();
	for (i = 0; i < n; i++) L[i].x = in(), L[i].y = in();
	distsort(n, L, p);
	printf("%d\n", closest_pair(n, p));
	return 0;
}


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

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp

using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)

class Union_Find {
private:
  ll n;
  vector<ll> parent;

public:
  Union_Find(ll v){
    n=v;
    parent.resize(n,-1);
  }

  ll root(ll v){
    if(parent[v]<0)return v;
    return parent[v]=root(parent[v]);
  }
  ll size(ll v){
    return -parent[root(v)];
  }
  bool connect(ll a,ll b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(size(a)<size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
  bool same(ll a,ll b){
    return root(a)==root(b);
  }

};

void solve(){
  ll n,q;
  cin>>n>>q;
  Union_Find uni(n);
  rep(i,q){
    ll c,x,y;
    cin>>c>>x>>y;
    if(c){
      auto tmp = uni.same(x,y);
      cout<<(tmp)<<endl;
    }
    else{
      uni.connect(x,y);
    }
  }
}

main(){
  solve();
}


Measured memory_bytes: 3164
N = int(input())
D,X = map(int, input().split())

A = [int(input()) for i in range(N)]

ans = 0

for i in A:
	j = 0
	while True:
		if (i*j+1) > D:
			break
		ans += 1
		j += 1

print(ans+X)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pair<int,int>>



int main(){
    ios::sync_with_stdio(0);
    int x, y, z;
    cin >> x >> y >> z;
    if ((x==y && x != z) || (x==z && x != y) || (z==y && x != z))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma region Macros
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if (N%1000==0) cout << 0 << '\n';
    else cout << -(N%1000-1000) << '\n';
}

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

class Main {

	static int k = 0;

	static int n = 0;

	static int[] w;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n_k = br.readLine().split(" ");

		n = Integer.parseInt(n_k[0]);

		k = Integer.parseInt(n_k[1]);

		w = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = Integer.parseInt(br.readLine());
		}

		System.out.println(solve());
	}

	static int checks(long p){
		int i =0;
		for(int j=0; j<k; j++){
			long s =0;

			while(s+w[i] <=p){
				s += w[i];
				i++;
				if(i == n) return n;
			}
		}
		return i;
	}

	static long solve(){
		long left =0;
		long right = 100000*100000;
		long mid ;

		while(right-left >1){
			mid = (left+right)/2;

			int v = checks(mid);
			if(v >=n){ right = mid;}
			else {
				left = mid;
			}
		}

		return right;
	}

}

Measured memory_bytes: 35120
#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 n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 1e9;
  rep(i, n) {
    int c = 0;
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      c++;
    }
    ans = min(ans, c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

int n, m, k;
char mat[7][7];

vector<int> f(int n) 
{
    vector<int> v(7, 0);
    int i = 0; 
    while (n > 0) { 
        v[i] = n % 2; 
        n = n / 2; 
        i++; 
    } 
    return v; 
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    rep(i, 0, 7) rep(j, 0, 7) mat[i][j] = '.';
    cin >> n >> m >> k;
    rep(i, 0, n) rep(j, 0, m) cin >> mat[i][j];

    int X = 1 << (n );
    int Y = 1 << (m );
    int res = 0;

    rep(i, 0, X){
        rep(j, 0, Y){
            char mm[7][7];
            rep(x, 0, 7) rep(y, 0, 7) mm[x][y] = mat[x][y];
            auto u = f(i), v = f(j);
            rep(x, 0, 7) if(u[x]) rep(a, 0, 7) mm[x][a] = '.';
            rep(x, 0, 7) if(v[x]) rep(a, 0, 7) mm[a][x] = '.';

            int cnt = 0;
            rep(x, 0, 7) rep(y, 0, 7) if(mm[x][y] == '#') cnt++;
            if(cnt == k) res++;
        }
    }

    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 3592
n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
if n == 1:
	print(1)
	exit()
a = sorted(a)
for i in range(n):
	tc = a[i]
	for j in range(i + 1, n):
		nd = a[j]
		x1, y1, = tc[0], tc[1]
		x2, y2, = nd[0], nd[1]
		rz1 = x1 - x2
		rz2 = y1 - y2
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))


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

using namespace std;

int main(){
    int N;
    cin >> N;
    float x;
    float ans=0;
    string u;
    for(int i=0;i<N;i++){
        cin >> x >> u;
        if(u=="JPY"){
            ans+=x;
        }
        else{
            ans += 380000.0 * x;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn=new Scanner(System.in);
	String a=stdIn.next();
	String b=stdIn.next();
	String c=stdIn.next();
	String A=a.substring(0,1).toUpperCase();
	String B=b.substring(0,1).toUpperCase();
	String C=c.substring(0,1).toUpperCase();
	System.out.println(A+B+C);
    }
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
class Dinic{
    struct Edge{
        int to, rev;
        T cap;
        Edge(int to, int rev, T cap) : to(to), rev(rev), cap(cap){}
    };

    vector<vector<Edge>> g; // グラフ
    vector<int> level, iter; // スタートからの距離、どこまで調べ終わったか
    int size;
public:
    Dinic(int size) : g(size, vector<Edge>()), size(size){}

    void init(int size){
        g = vector<vector<Edge>>(size, vector<Edge>());
        this->size = size;
    }

    void add_edge(int from, int to, T cap){
        g[from].push_back(Edge(to, g[to].size(), cap));
        g[to].push_back(Edge(from, g[from].size() - 1, 0));
    }

    void bfs(int s){
        level = vector<int>(size, -1);
        queue<int> que;
        level[s] = 0;
        que.push(0);
        while (!que.empty()){
            int v = que.front(); que.pop();
            for(auto && e : g[v]){
                if(e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f){
        if(v == t) return f;
        for(int i = iter[v]; i < g[v].size(); ++i){
            Edge &e = g[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                int d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s, int t){
        int flow = 0;
        while(true){
            bfs(s);
            if(level[t] < 0) return flow;
            iter = vector<int>(size);
            int f;
            while((f = dfs(s, t, INF)) > 0) flow += f;
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
    int m, n;
        cin >> m >> n;
        if(m + n == 0) break;
        vector<int> b(m), r(n);
        for(int i = 0; i < m; ++i){
            cin >> b[i];
        }
        for(int i = 0; i < n; ++i){
            cin >> r[i];
        }
        Dinic<int> dinic(m + n + 2);
        for(int i = 0; i < m; ++i){
            dinic.add_edge(0, i+1, 1);
            for(int j = 0; j < n; ++j){
                if(__gcd(b[i], r[j]) > 1) dinic.add_edge(i+1, j + m + 1, 1);
            }
        }
        for(int i = 0; i < n; ++i){
            dinic.add_edge(i + m + 1, m + n + 1, 1);
        }
        cout << dinic.max_flow(0, m + n + 1) << "\n";
    }
    return 0;
}


Measured memory_bytes: 7376
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL unsigned long long
#define MOD 1000000007
#define inf 1999999999



int main() {
	string S;
	cin >> S;
	if (S == "Sunny")cout << "Cloudy" << endl;
	else if (S == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int k=-1;
  for(int i=2;i<100000;++i) {
    if(i*(i-1)==2*N) {
      k = i;
      break;
    }
  }
  if(k==-1) {
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  cout<<k<<endl;
  vector<vector<int> > ans(k);
  int num = 1;
  for(int i=0;i<k;++i) {
    for(int j=i+1;j<k;++j) {
      ans[i].push_back(num);
      ans[j].push_back(num);
      num++;
    }
  }
  for(int i=0;i<k;++i) {
    cout<<ans[i].size()<<" ";
    for(int j=0;j<ans[i].size();++j) cout<<ans[i][j]<<" ";
    cout<<endl;
  }
}



Measured memory_bytes: 4240
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    ll ans;
    ll zx = X;
    if(zx < 0){
        zx = -zx;
    }

    if(zx / D >= K){
        ans = (zx/D - K) * D + zx%D;
        cout << ans;
        return 0;
    }

    ll p = zx % D;
    ll m = D - zx%D;
    if((K - zx/D) % 2 == 0){
        cout << p;
    }else{
        cout << m;
    }

}


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

int main()
{
	int n;
	cin >> n;
	int *a = new int[n];
	int *b = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	int sum = 0;
	sort(b, b + n);
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
			sum++;
	}
	if (sum <= 2)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 10000

main()
{
  int i, j, n, q, count = 0;
  int s[N], t[N];

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%d", &s[i]);
    }
  scanf("%d", &q);
  for(i = 0; i < q; i++)
    {
      scanf("%d", &t[i]);
    }

  for(i = 0; i < q; i++)
    {
      for(j = 0; j < n; j++)
	{
	  if(t[i] == s[j])
	    {
	      count++;
	      break;
	    }
	}
    }

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

Measured memory_bytes: 648
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N, M;
    cin >> N >> M;
    rep(i, M){
        ll a;
        cin >> a;
         N -= a;
    }
    cout << max(-1LL, N) << endl;

    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    char s[1005];
    int len,i;
    scanf("%s",s);
    len=strlen(s);
    int temp=0;
    for(i=0;i<len;i++){
        if(s[i]=='C'){
            temp=1;
        }
        if(s[i]=='F'&&temp==1){
            temp=2;
        }
    }
    if(temp==2){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
D=[]
for i in range(M):
    D.append(list(map(int,input().split())))
    
S=min(a)+min(b)
P=[]
for i in range(M):
    P.append(a[D[i][0]-1]+b[D[i][1]-1]-D[i][2])
P.append(S)
print(min(P))

Measured memory_bytes: 42660
#include<iostream>
#include<string>
#define FOR(i,s,t) for(int (i)=(s);(i)<(t);i++)
using namespace std;
int a[30];

int main() {
    string S;
    cin >> S;
    FOR(i, 0, S.size()) {
        a[S[i] - 'a']++;
    }
    int cnt = 0;
    FOR(i, 0, 26) {
        if (a[i] % 2 == 1) {
            cnt++;
        }
    }
    if (cnt == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (cnt % 2 == 1) {
        cnt -= 1;
    }
    cout << cnt / 2 << endl;


}

Measured memory_bytes: 3140
#include <stdio.h>

int main()
{
  int s[10000], t[500], n, q, i, j, count = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      scanf("%d",&s[i]);
    }

  scanf("%d",&q);

  for(i = 0; i < q; i++)
    {
      scanf("%d",&t[i]);
    }

  for(i = 0; i < q; i++)
    {
      j = 0;
      s[n] = t[i];
      while(s[j] != t[i])
	{
	  j++;
	}
      if(j != n)
	{
	  count++;
	  s[j] = -1;
	}
    }

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



Measured memory_bytes: 2104
fun main(args: Array<String>) {
    agc022a()
}

fun agc022a() {
    val s = readLine()!!.toCharArray()

    if (s.size < 26) {
        val find = ('a'..'z').find { !s.contains(it) }!!
        return println(s + find)
    }


    val indexOfFirst =
        (s.lastIndex downTo 1).firstOrNull { s[it] > s[it - 1] }
    val replaceIndex = when (indexOfFirst) {
        -1, null -> return println(-1)
        else -> indexOfFirst - 1
    }

    val replaceChar = s[replaceIndex]
    val answer = s.slice(0 until replaceIndex) +
            s.slice(replaceIndex..s.lastIndex).findLast { it > replaceChar }

    println(answer.joinToString(""))
}


Measured memory_bytes: 35892
// Date: 2020-03-17

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

struct node {
    int w, s, v, id;
    bool operator < (const node& r) const { return w + s < r.w + r.s; }
} a[N];

int n;
LL dp[20010];

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) cin >> a[i].w >> a[i].s >> a[i].v, a[i].id = i;
    sort(a+1, a+1+n);
    rep(i, 1, n) per(j, a[i].s, 0) chkmax(dp[j+a[i].w], dp[j] + a[i].v);
    LL ans = 0;
    rep(i, 0, 20000) chkmax(ans, dp[i]);
    cout << ans;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100000

int Partition(int *, int, int);

int main()
{
    int i, n;
    int A[MAX];
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    int pos = Partition(A, 0, n-1);
    for (i = 0; i < n-1; i++) {
        (i == pos)? printf("[%d] ", A[i]) : printf("%d ", A[i]);
    }
    printf("%d\n", A[i]);
}

int Partition(int *A, int p, int r){
    int x = A[r];
    int i = p-1;
    int j;
    for (j = p; j <= r-1; j++){
        if (A[j] <= x){
            i++;
            int temp = A[i];
            A[i] = A[j];
            A[j] = temp;
        }
    }
    int temp = A[i+1];
    A[i+1] = A[r];
    A[r] = temp;
    return i+1;
}



Measured memory_bytes: 2140
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

typedef long long ll;

const int MAX_N = 1e4 + 4, MAX_M = 1e2 + 2, MOD = 1e9 + 7;
string k;
int n, d;
int dp[2][MAX_N][MAX_M];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;
	
	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}


int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> k >> d;
	k = '#' + k;
	dp[1][0][0] = 1;
	for (int i = 1; i < k.size(); i++)
		for (int j = 0; j < d; j++) {
			dp[1][i][j] = dp[1][i - 1][(j - (k[i] - '0') + d * 10) % d];
			for (int h = 0; h < (k[i] - '0'); h++)
				dp[0][i][j] = _sum(dp[0][i][j], dp[1][i - 1][(j - h + d * 10) % d]);

			for (int h = 0; h < 10; h++)
				dp[0][i][j] = _sum(dp[0][i][j], dp[0][i - 1][(j - h + d * 10) % d]);
		}

	cout << (_sum(dp[0][k.size() - 1][0], dp[1][k.size() - 1][0]) - 1 + MOD) % MOD;
	return 0;
}

Measured memory_bytes: 8320
n = int(input())
s = []
t = []
for _ in range(n):
    si, ti = input().split()
    ti = int(ti)
    s.append(si)
    t.append(ti)
x = input()
ans = sum(t)
for i in range(n):
    ans -= t[i]
    if s[i] == x:
        break
print(ans)

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

n, k = map(int, input().split())
dt = []
for _ in range(n):
    a,b = map(int, input().split())
    dt.append([b,a])
dt.sort(reverse=True)
# print(dt)

t = [0] * (n+1)
from heapq import *

h = []
h2 = []
f = [0] * (n+1)
g = [0] * (n+1)
c = 0
tf = 0
for i in range(k):
    tmp = dt[i]
    if t[tmp[1]] == 0:
        t[tmp[1]] += 1
        c += 1
    else:
        heappush(h, tmp[0])
    tf += tmp[0]
f[c] = tf

for i in range(k, n):
    tmp = dt[i]
    if t[tmp[1]] == 0:
        t[tmp[1]] += 1
        heappush(h2, -tmp[0])

while len(h2) > 0 and len(h) > 0:
    tout = heappop(h)
    tin = -heappop(h2)
    c += 1
    tf = tf - tout + tin
    f[c] = tf

for i in range(n+1):
    ff = f[i]
    if ff != 0:
        g[i] = ff + i*i
print(max(g))


Measured memory_bytes: 65756
class _in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}constexpr int operator*(){return it;}constexpr bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr _in(int n):i(0),n(n){}explicit constexpr _in(int i,int n):i(i,n<i),n(n){}constexpr const my_iterator& begin(){return i;}constexpr const my_iterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    string st; cin >> st;
    int N = st.size();
    vector<int> s, t;
    for(int i :_in(N)) {
        if(st[i] == 'S') s.emplace_back(i);
        else t.emplace_back(i);
    }

    int tid = 0;
    int sum = 0;
    for(int x : s) {
        while(tid < (int)(t.size()) && t[tid] < x) tid++;
        if(tid >= (int)(t.size())) break;
        sum += 2;
        tid++;
    }
    cout << N - sum << endl;
    return 0;
}

Measured memory_bytes: 1680
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
template<class T>
class UnionFind
{
private:
	vector<T> parentNo;
	vector<T> parentRank;
	vector<T> parentSize;

public:
	// コンストラクタ
	UnionFind(int n) 
	{
		parentNo.resize(n);
		parentRank.resize(n, 0);
		parentSize.resize(n, 1);
		for (int i = 0; i < n; i++) {
			// 始めは全部ROOT
			parentNo[i] = i;
		}
	}

	int root(T x) 
	{
		if (parentNo[x] == x) {
			return x;
		} else {
			T rootParentNo = root(parentNo[x]);
			parentNo[x] = rootParentNo;
			return rootParentNo;
		}
	}

	bool same(T x, T y) 
	{
		return root(x) == root(y);
	}

	int size(T x) 
	{
		return parentSize[root(x)];
	}

	void unite(T xc, T yc) 
	{
		T xr = root(xc);
		T yr = root(yc);
		if (xr == yr) {
			return;
		}
		if (parentRank[xr] < parentRank[yr]) {
			parentNo[xr] = yr;
			parentSize[yr] += parentSize[xr];
		} else {
			parentNo[yr] = xr;
			parentSize[xr] += parentSize[yr];
			if (parentRank[xr] == parentRank[yr]) {
				parentRank[xr]++;
			}
		}
	}
};


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

	int N;
	string S;
	cin >> N >> S;

	string ans = S;
	REP(i, S.size()) {
		char one = (S[i] - 'A' + N) % 26;
		ans[i] = one + 'A';
	}
	cout << ans << endl; 
	return 0;
}



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

long long a[1005];
const int MOD=1e9+7;

void func(long long x)
{
    for(int i=2;i<=x;i++){
        while(x%i==0){
            a[i]++;
            x/=i;
        }
    }
}




int main()
{
    int n;
    cin>>n;
    long long ret=1;
    for(int i=2;i<=n;i++)
        func(i);
    for(int i=0;i<=1000;i++){
        ret*=(a[i]+1);
        ret%=MOD;
    }
    cout<<ret;




}


Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int, int> II;
typedef pair<int, II> III;

static const int INF = 1 << 30;

int main(int argc, char* argv[]) {
	int h, w, sh, sw, eh, ew, ans;
	cin >> h >> w >> sh >> sw >> eh >> ew;
	--sh, --sw, --eh, --ew;
	vector<string> b(h);
	for (int i = 0; i < h; ++i) {
		cin >> b[i];
	}
	priority_queue<III, vector<III>, greater<>> q;
	q.emplace(III(0, II(sh, sw)));
	vector<vector<int>> min_cost(h, vector<int>(w, INF));
	min_cost[sh][sw] = 0;
	while (!q.empty()) {
		III top = q.top();
		int cost = top.first, y = top.second.first, x = top.second.second;
		if (y == eh && x == ew) {
			cout << cost << endl;
			return 0;
		}
		q.pop();
		for (int dy = -2; dy <= 2; ++dy) {
			for (int dx = -2; dx <= 2; ++dx) {
				int ny = y + dy, nx = x + dx;
				if (ny >= 0 && ny < h && nx >= 0 && nx < w) {
					if (b[ny][nx] == '#') continue;
					if (abs(ny - y) + abs(nx - x) == 1) {
						if (cost < min_cost[ny][nx]) {
							min_cost[ny][nx] = cost;
							q.emplace(III(cost, II(ny, nx)));
						}
					} else {
						if (cost + 1 < min_cost[ny][nx]) {
							min_cost[ny][nx] = cost + 1;
							q.emplace(III(cost + 1, II(ny, nx)));
						}
					}
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 9464
N,T=map(int,input().split())
ok = []

for i in range(N):
	ok.append([int(i) for i in input().split()])
		
ok.sort(key=lambda x: x[0])

ans = 1200

for i in range(N):
	if ok[i][1] <= T:
		ans = ok[i][0]
		break
		
	
print("TLE" if ans == 1200 else ans)

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

int main(){
    int N,Y,tmpi,tmpj,tmpk,rem;
    cin >> N >> Y;
    rem = Y;
    tmpi = Y / 10000;
    for(int i=tmpi;i>=0;i--){
        rem -= i*10000;
        tmpj = rem / 5000;
        for(int j=tmpj;j>=0;j--){
            rem -= j*5000;
            tmpk = rem / 1000;
            if(i+j+tmpk==N){
                cout << i << " " << j << " " << tmpk << endl;
                return 0;
            }
            rem += j*5000;
        }
        rem += i*10000;
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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

vector<vector<int>> c(3, vector<int>(3));

int main() {
    for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) cin >> c[i][j];
    int csum = c[0][0]+c[1][1]+c[2][2];
    string ans = "Yes";
    ans = (csum == c[1][0]+c[2][1]+c[0][2] && ans == "Yes") ? "Yes" : "No";
    ans = (csum == c[2][0]+c[0][1]+c[1][2] && ans == "Yes") ? "Yes" : "No";
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        a = LI()
        r = -1
        for i in range(n):
            b = a[i]
            for c in a[i+1:]:
                t = b*c
                if r >= t:
                    continue
                s = str(t)
                if all([int(s[k]) == int(s[k+1])-1 for k in range(len(s)-1)]):
                    r = t

        rr.append(r)
        break

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9104
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = K
    k = 1
    while K > 1:
        K //= 2
        k += 1
    if K == 0:
        print(sum(A))
        return
    cnt = [0 for _ in range(k)]
    for a in A:
        for i in range(k):
            if (a >> i) & 1:
                cnt[i] += 1
    X = 0
    if N % 2 == 0:
        n = N // 2 - 1
    else:
        n = N // 2
    for i in range(k):
        if cnt[k - i - 1] <= n:
            if X + (2 ** (k - i - 1)) <= B:
                X += 2 ** (k - i - 1)
    answer = 0
    for a in A:
        answer += X ^ a
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14984
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    int n,mi,c,minplace,l;
    l=0;
    int a[107];
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        mi=a[i];
        minplace=i;
        for(int j=i;j<n;j++){
            if(a[j]<mi){
                mi=a[j];
                minplace=j;
            }
        }
        if(minplace!=i){
            c=a[minplace];
            a[minplace]=a[i];
            a[i]=c;
            l++;
        }
    }
    rep(i,n){
        cout << a[i];
        if(i!=n-1) cout << " ";
    }
    cout << endl << l << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  vector<int> y1, x1, y2, x2;
  for (int i = 0; i + 1 < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] % 2 == 1) {
        a[i + 1][j]++;
        a[i][j]--;
        y1.push_back(i);
        x1.push_back(j);
        y2.push_back(i + 1);
        x2.push_back(j);
      }
    }
  }
  for (int j = 0; j + 1 < w; j++) {
    if (a[h - 1][j] % 2 == 1) {
      a[h - 1][j + 1]++;
      a[h - 1][j]--;
      y1.push_back(h - 1);
      x1.push_back(j);
      y2.push_back(h - 1);
      x2.push_back(j + 1);
    }
  }
  cout << y1.size() << endl;
  for (int i = 0; i < y1.size(); i++) {
    printf("%d %d %d %d\n", y1[i] + 1, x1[i] + 1, y2[i] + 1, x2[i] + 1);
  }
}


Measured memory_bytes: 5224
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        string s = ReadLineStr();
        string t = ReadLineStr();
        int rtn = 0;
        for (int i = 0; i < 3; i++) {
            if (s.Substring(i , 1) == t.Substring(i , 1)) {
              rtn++;
            }
        }
        Console.WriteLine(rtn);
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"}; 
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
vs in;
int f(int a,int b,int c,int d){
//	cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	bool H=false;
	loop(i,a,c)loop(j,b,d)if(in[i][j]=='x')H=true;
	if(!H)return 0;
	vi ta,yo;
	loop(i,a,c){
		bool h=true;
		loop(j,b,d)if(in[i][j]=='o')h=false;
		if(h)yo.pb(i);
	}
	loop(i,b,d){
		bool h=true;
		loop(j,a,c)if(in[j][i]=='o')h=false;
		if(h)ta.pb(i);
	}
	int out=0;
//	cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
//	cout<<yo.size()<<" "<<ta.size()<<endl;
	rep(i,yo.size())rep(j,ta.size())
		out=max(out,f(a,b,yo[i],ta[j])+f(a,ta[j]+1,yo[i],d)+f(yo[i]+1,b,c,ta[j])+f(yo[i]+1,ta[j]+1,c,d)+1);
	return out;
}
int main(){
	int n;
	cin>>n;
	in=vs(n);
	rep(i,n)cin>>in[i];
	cout<<f(0,0,n,n)<<endl;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<double> prob(n+1, 0.0);
    double pi;
    prob[0] = 1.0;
    for(int i = 0; i < n; i++) {
        cin >> pi;
        for(int i = n-1; i >= 0; i--) {
            prob[i+1] += prob[i]*pi;
            prob[i] = prob[i] * (1.0-pi);
        }
    }
    double ans = 0;
    for(int i = 1; i <= n; i++) {
        if (i > n-i)
            ans += prob[i];
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}




Measured memory_bytes: 256