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

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int S = a*b;
		int L = 2*(a+b);
		System.out.println(S+" "+L);
	}
}

Measured memory_bytes: 17320
#include<iostream>
using namespace std;
int main(){
  int ans,pasuta,juice,most1=10000,most2=10000;
  for(int i=0;i<3;i++){
    cin >> pasuta;
    if(most1>pasuta){
      most1=pasuta;
    }
  }
  for(int i=0;i<2;i++){
    cin >> juice;
    if(most2>juice){
      most2=juice;
    }
  }
  ans=most1+most2-50;
  cout << ans << endl;
  return (0);
}

Measured memory_bytes: 1160
import std.stdio, std.conv, std.string, std.algorithm, std.math;

int calcSimple( int y, int money, double rate, int commission ) {
  int ans = 0;
  foreach ( i; 0 .. y ) {
	ans += to!int( money * rate );
	money -= commission;
  }
  return ans + money;
}

int calcCompound( int y, int money, double rate, int commission ) {
  foreach ( i; 0 .. y ) {
	money = to!int( money * ( 1 + rate ) );
	money -= commission;
  }
  return money;
}

void main()
{
  int m = to!int( strip( readln ) );
  foreach ( i; 0 .. m ) {
	int money = to!int( strip( readln ) );
	int y = to!int( strip( readln ) );
	int n = to!int( strip( readln ) );
	int ans = 0;
	foreach ( j; 0 .. n ) {
	  
	  auto line = split( strip( readln ), " " );
	  int isCompoundInterest = to!int( line[ 0 ] );
	  double rate = to!double( line[ 1 ] );
	  int commission = to!int( line[ 2 ] );
	  if ( isCompoundInterest == 0 ) {
		ans = max( ans, calcSimple( y, money, rate, commission ) );
	  } else {
		ans = max( ans, calcCompound( y, money, rate, commission ) );
	  }
	}
	writeln( ans );
  }
}

Measured memory_bytes: 1772
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[200010];
int pre[200010];
int suf[200010];

void solve() {
    for (int i = 0; i < n; i++) {
        pre[i+1] = max(pre[i], a[i]);
    }
    for (int i = n-1; i >= 0; i--) {
        suf[i] = max(suf[i+1], a[i]);
    }

    for (int i = 0; i < n; i++) {
        cout << max(pre[i], suf[i+1]) << endl;
    }
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 4096
#include <iostream>
#include <array>
#include <vector>

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    vector<int> coins(m);
    

    for(int i = 0; i < m; ++i) cin >> coins[i];
    
    vector<int> ans(n + 1, 100000);
    ans[0] = 0;

    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j < m; ++j) {
            if(i - coins[j] >= 0) {
                ans[i] = min(ans[i], ans[i - coins[j]] + 1);
            }
        }
    }

    cout << ans[n] << endl;

    return 0;
}

Measured memory_bytes: 3172
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;


int main() {
  ll N;

  cin >> N;

  int ans[N];
  vector<P> aLst[N];

  queue<ll> que;
  for (int i = 0; i < N; ++i) {
    ll u, v, w;
    cin >> u >> v >> w;
    aLst[u - 1].emplace_back(v - 1, w);
    aLst[v - 1].emplace_back(u - 1, w);
  }

  que.push(0);
  ans[0] = 0;

  unordered_map<ll, bool> visited;

  while (!que.empty()) {
    ll cur = que.front();
    que.pop();
    // cout << "cur=" << cur << endl;
    for (size_t i = 0; i < aLst[cur].size(); ++i) {
      ll cur_child = aLst[cur][i].first;
      if (visited.count(cur_child) == 0) {
        que.push(cur_child);
        visited[cur_child] = true;
        if (aLst[cur][i].second % 2 == 0) {
          ans[cur_child] = ans[cur];
        } else {
          ans[cur_child] = 1 - ans[cur];
        }
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 12452
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

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

void solve()
{
    ll n,p;
    cin>>n>>p;
    ll od=0;
    for(int i=0;i<n;i++) {
        ll x;
        cin>>x;
        if(x%2) od++;
    }
    if(p==0&&od==0) {
        ll ans = (ll)1<<n;
        cout<<ans;
        return;
    }
    if(p==1&&od==0) {
        cout<<0;
        return;
    }
    //ll ev=n-od;
    //ll ans = 1<<ev;
    ll ans=(ll)1<<(n-1);
    cout<<ans;
}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3568
from bisect import bisect_right

n,m=map(int,input().split())
P=[]
Y=[]
A=[list() for _ in range(n)]										#二次元配列作る

for _ in range(m):
	p,y=map(int,input().split())
	P.append(p)
	Y.append(y)
	A[p-1].append(y)

A=[sorted(a) for a in A]												#二次元配列同一配列内でのソート

for i in range(m):
	j=bisect_right(A[P[i]-1],Y[i])
	print(str(P[i]).zfill(6)+str(j).zfill(6))

Measured memory_bytes: 34428
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
const int mod = 1e9+7;

int n,m,ar[maxn];

int arr[2][maxn];
bool che(int x){
    int a = x%1000;
    if(a == 123)return 1;
    if(a == 213)return 1;
    if(a == 132)return 1;
    if(x/1000 == 1 && x%100 == 23)return 1;
    if(x/100 == 12 && x%10 == 3)return 1;
    return 0;
}
int main()
{
    scanf("%d",&n);
    int now=0;
    memset(arr,0,sizeof(arr));
    arr[now][0]=1;
    for(int in=1;in<=n;in++){
        int nex = now ^ 1;
        for(int i=0;i<=4444;i++){
            for(int j=1;j<=4;j++){
                int x = i%1000*10+j;
                if(!che(x)){
                    arr[nex][x] += arr[now][i];
                    arr[nex][x] %= mod;
                }
            }
        }
        for(int i=0;i<=4444;i++)arr[now][i]=0;
        now = nex;
    }
    int s=0;
    for(int i=1;i<=4444;i++){
        s += arr[now][i];
        s %= mod;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);} 

ll modinv(ll a,ll p){return power(a,p-2,p);}

int solve(){
    ll n,k;
    cin>>n>>k;
    std::map<ll, ll> mm;
    f(i,0,k){
        ll d;
        cin>>d;
        f(i,0,d){
            ll tem;
            cin>>tem;
            mm[tem]++;
        }
    }
    cout<<n-mm.size()<<endl;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);



    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    

    // tests(){solve();}
    solve();
    return 0;
}/*#ifndef ONLINE_JUDGE
    #endif*/

    // make_pair make_tuple  tuple<int,int,int> continue resize insert

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

//const long long INF = 1000000001;
const int INF = 2147483647;

const long long MOD = 1000000009;

typedef long long ll;

const int max = 100000; //配列の最大長

int n;

ll search_low(ll *ls,int k){
  ll left,right;
  left = -1,right = n;

  while(right - left > 1){
    ll mid = left + (right - left) / 2;
    if(ls[mid] >= k){
      right = mid;
    } else {
      left = mid;
    }
  }

  return left+1;
}

ll search_up(ll *ls,int k){
  ll left,right;
  left = -1,right = n;

  while(right - left > 1){
    ll mid = left + (right - left) / 2;
    if(ls[mid] > k){
      right = mid;
    } else {
      left = mid;
    }
  }

  return right;
}

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

  ll a[n],b[n],c[n];
  for(int i=0; i<n; i++) std::cin >> a[i];
  for(int i=0; i<n; i++) std::cin >> b[i];
  for(int i=0; i<n; i++) std::cin >> c[i];

  std::sort(a,a+n); std::sort(b,b+n); std::sort(c,c+n);

  ll count = 0;
  for(int i=0; i<n; i++){
    ll temp1 = search_low(a,b[i]); //bの各値未満の数
    ll temp2 = n - search_up(c,b[i]); //bの各値超過の個数
    count += temp1 * temp2;
  }

  std::cout << count << std::endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());
    int ans = 0;
    rep(i, N) {
        int a = L[i];
        rep2(j, i+1, N) {
            int b = L[j];
            int c_max = a + b;
            int idx = lower_bound(L.begin(), L.end(), c_max) - L.begin();
            rep2(k, j+1, idx) {
                int c = L[k];
                if (a < b + c && b < a + c && c < a + b) {
                    ans++;
                }
            }
        }
    }
    cout << ans << '\n';
}

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


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	string S;
	int cnt = 0;
	int ans = 0;

	cin >> N >> S;
	rep(i, 0, SZ(S))
	{
		if (S[i] == 'I')
		{
			cnt++;
		}
		else
		{
			cnt--;
		}
		chmax(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n, x = na()
aaa = na()
ans = 0
s = 0
for i in range(n):
    nt = x - s
    if aaa[i] <= nt:
        s = aaa[i]
        continue
    else:
        ans += aaa[i] - nt
        s = nt
print(ans)


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

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}


int ds[10];

bool check(int x){
    while(x){
        int tmp = x % 10;
        if(ds[tmp] == 1) return false;
        x /= 10;
    }
    return true;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < 10; i++){
        int tmp;
        cin >> tmp;
        ds[tmp] = 1;
    }

    while(1){
        if(check(n)){
            cout << n << endl;
            break;
        }
        n++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    ll ans = 0;
    ll count = 0;
    rep(i, sz(s)){
      if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
        count++;
      } else {
        chmax(ans, count);
        count = 0;
      }
    }
    chmax(ans, count);
    print(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7;
using namespace std;
ll t;
ll arr[200005];
int main()
{
    ll a,b,c,d,e,f,i,j;
    cin>>a;
    for(i=0;i<a;i++)
    {
        cin>>arr[i];
    }
    d=arr[0];
    for(i=1;i<a;i++)
    {
        d=__gcd(d,arr[i]);
    }
    cout<<d<<endl;


return 0;

}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int a, b; cin >> a >> b;
  if (a <= 8 && b <= 8) cout << "Yay!\n";
  else cout << ":(\n";
}


Measured memory_bytes: 256
S = gets.chomp
N = (S.size-1) / 2
F =->(s){
  n = s.size / 2
  s[0,n] == s[-n,n].reverse
}
x = F[S]
x &&= F[S[0,N]]
x &&= F[S[N+1..-1]]
puts x ? :Yes : :No

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N, A;
    cin >> N >> A;
    cout << (N % 500 <= A ? "Yes" : "No") << "\n";
}

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

using namespace std;

int main(void) {
  string o, e;
  cin >> o >> e;
  for(int i = 0; i < o.length() - 1; i++) {
    cout << o[i] << e[i];
  }
  if(o.length() - e.length() == 1) {
    cout << o[o.length() - 1];
  }
  else {
    cout << o[o.length() - 1] << e[e.length() - 1];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll H,W;cin>>H>>W;
    vvl info(H,vl(W));
    rep(i,H)rep(j,W)cin>>info[i][j];
    vector<pair<pl,pl>> ans;
    rep(i,H)rep(j,W){
        if(i<H-1){
            if(info[i][j]%2){
                ans.push_back({{i+1,j+1},{i+2,j+1}});
                info[i][j]--,info[i+1][j]++;
            }
        }
        else{
            if(j<W-1){
                if(info[i][j]%2){
                    ans.push_back({{i+1,j+1},{i+1,j+2}});
                    info[i][j]--,info[i][j+1]++;
                }
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto p:ans)cout<<p.fi.fi<<" "<<p.fi.se<<" "<<p.se.fi<<" "<<p.se.se<<endl;
    return 0;
}

Measured memory_bytes: 8304
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int n,m;
int shuru;
bool ok;
priority_queue<int> q1;
priority_queue<int> q2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&shuru);
		q1.push(shuru);
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&shuru);
		q2.push(shuru);
	}
	if(n<m)
	{
		cout<<"NO";return 0;
	}
	while(!q1.empty()&&!q2.empty())
	{
		int tmp=q1.top();
		q1.pop();
		if(tmp==q2.top())q2.pop();
		if(tmp<q2.top())
		{
			ok=1;break;
		}
	}
	if(ok==1)cout<<"NO";
	else cout<<"YES";
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll maxx = 1e5 + 20;

ll a[maxx], n, ans;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(ll i = 0; i < n; i++) cin >> a[i];
	for(ll i = 0; i < n; i++)
	{
		ans += (a[i] / 2ll);
		a[i] %= 2;
		if (!a[i]) continue;
		if (i == n-1 || !a[i+1]) continue;
		ans++; a[i+1]--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>


 int main()
 {
   double r;
   double Length,S;
   double pi = 3.141592653589;

   scanf("%lf",&r);

   Length = 2.0 * pi* r;
   S = pi * r * r;

   printf("%lf %lf\n",S,Length);
return(0);
}

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


using namespace std;


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

    map<char, long long> c;
    c['R'] = 0;
    c['G'] = 0;
    c['B'] = 0;

    for (auto ch : S) {
        c[ch] += 1;
    }

    long long remove = 0;
    for (long long d = 1; d <= (N - 1) / 2; d++) {
        for (long long i = 0; i < S.length() - 2 * d; i++) {
            long long j, k;
            j = i + d;
            k = j + d;
            if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
                remove++;
            }
        }
    }
    long long ans = c['R'] * c['G'] * c['B'] - remove;
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	int parent ,left ,right ;
};
int getroot(node);
const int nil = -1;
int D[30],H[30];
node N[30];
void setdepth(int,int);
int setheight(int);

int main(){
	int n;
	cin >>n;
	for(int i=0;i<n;i++) N[i].parent = N[i].left = N[i].right = nil;
	for(int i=0;i<n;i++){
		int id;
		cin >> id;
		cin >> N[id].left >> N[id].right;
		if(N[id].left != nil) N[N[id].left].parent = id;
		if(N[id].right != nil) N[N[id].right].parent = id;
	}
	//cerr << "input was succeeded." << endl;
	int root = getroot(N[0]);
	//cerr << "root was gotten." << endl;
	setdepth(root,0);
	//cerr << "depth was setted." << endl;
	setheight(root);
	//cerr << "height was setted." << endl;

	for(int i=0;i<n;i++){
		cout << "node " << i <<": parent = "<<N[i].parent<<", sibling = ";
		if(i != root){
			if(N[N[i].parent].left == i) cout << N[N[i].parent].right;
			else cout << N[N[i].parent].left;
		}
		else cout << nil;
		cout <<", degree = ";
		int deg = 0;
		if(N[i].left != nil) deg++;
		if(N[i].right != nil) deg++;
		cout << deg << ", depth = " <<D[i]<<", height = "<<H[i] <<", ";
		if(i == root) cout << "root";
		else if(deg ==0) cout <<"leaf";
		else cout << "internal node";
		cout << endl;
	}
}

int getroot(node x){
	int x_id = 0;
	while(x.parent != nil){
		x_id = x.parent;
		x = N[x_id];
	}
	//cerr << "root:" << x_id << endl;
	return x_id;
}

void setdepth(int id,int d){
	//cerr << "error1" << endl;
	D[id] = d;
	//cerr << "error2" << endl;
	if(N[id].left != nil) setdepth(N[id].left,d+1);
	//cerr << "error3" << endl;
	if(N[id].right != nil) setdepth(N[id].right,d+1);
	//cerr << "error4" << endl;
}

int setheight(int id){
		int l,r;
		l = r = 0;
		if(N[id].left != nil) l = setheight(N[id].left)+1;
		if(N[id].right != nil) r = setheight(N[id].right)+1;
		return H[id] = max(l,r);
}

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

int main(){
  int N, Y;
  cin >> N >> Y;
  int n, y;
  int n2, y2;
  for(int a=0; a<=max(N, Y/10000); ++a){
    n = N; y = Y;
    n -= a;
    y -= 10000 * a;
    for(int b=0; b<=max(n, y/5000); ++b){
      n2 = n; y2 = y;
      n2 -= b;
      y2 -= 5000 * b;
      if(1000*n2 == y2){
        cout << a << " " <<  b << " " << n2 << "\n";
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << "\n";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a>=b && b>=c) cout<<a-c<<endl;
	else if(a>=c && c>=b) cout<<a-b<<endl;
	else if(b>=a && a>=c) cout<<b-c<<endl;
	else if(b>=c && c>=a) cout<<b-a<<endl;
	else if(c>=a && a>=b) cout<<c-b<<endl;
	else if(c>=b && b>=a) cout<<c-a<<endl;
	return 0;
} 

Measured memory_bytes: 256
import itertools
N = int(input())
AB = [list(map(int, input().split())) for n in range(N)]
sortA = sorted(AB, key= lambda x:x[0])
sortB = sorted(AB, key= lambda x:x[1])
if N % 2 == 0:
  k1 = int(N/2-1)
  k2 = int(N/2)
  minM = sortA[k1][0] + sortA[k2][0]
  maxM = sortB[k1][1] + sortB[k2][1]
  print(maxM-minM+1)
else:
  k = int((N+1)/2)-1
  A = sortA[k][0]
  B = sortB[k][1]
  print(B-A+1)

Measured memory_bytes: 51548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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 long long INF = 1LL << 60;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
  int k;
  string s;
  cin >> k >> s;
  int len = s.size();
  if (k >= len)
  {
    cout << s << endl;
    return 0;
  }
  else
  {
    rep(i, k)
      cout << s[i];
    cout << "..." << endl;
    return 0;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;


uint rate(ll k){
    if (k < 400) return 0;
    else if (k < 800) return 1;
    else if (k < 1200) return 2;
    else if (k < 1600) return 3;
    else if (k < 2000) return 4;
    else if (k < 2400) return 5;
    else if (k < 2800) return 6;
    else if (k < 3200) return 7;
    else return 8;
}

int main() {
    array<ll, 9> rates{0};
    ll N;
    cin >> N;
    for (auto &&i: irange(0LL, N)){
        ll k;
        cin >> k;
        rates.at(rate(k))++;
    }
    ll count{0};
    for (auto &&i: irange(0LL, 8LL)){
        if (rates.at(i) != 0) count++;
    }
    cout << ((count == 0) ? ((rates.at(8)==0) ? 0 : 1) : count) << " ";
    cout << count + rates.at(8) << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys
input = sys.stdin.readline
def solve():
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  a2 = [0]
  for i in range(n):
    a2.append(a[i]+a2[i])
  for i in range(n+1):
    a2[i] %= m
  c = Counter(a2)
  ans = 0
  for i in c.values():
    ans += i*(i-1)//2
  print(ans)
  
solve()

Measured memory_bytes: 17660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;

  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int ub = n;
  int lb = 0;

  while(ub-lb>1){
    //    cout << "lb ub " << lb << " " << ub << endl;
    int mid = (ub+lb)/2;
    bool ok = true;
    map<int,int> cnt;
    rep1(i,n-1){
      if(a[i-1] < a[i]) continue;
      else{
	if(a[i-1]>=a[i]){
	  if(mid==1){
	    ok = false;
	    break;
	  }
	  if(a[i-1] >= a[i]){
	    if(a[i-1]>a[i]){
	      auto itr = cnt.upper_bound(a[i]);
	      if(itr!=cnt.end()){
		//		cout << "erase pos" << (*itr).first << endl;
		vector<int> er;
		for(;itr!=cnt.end();itr++){
		  er.pb((*itr).first);
		}
		for(int j=0;j<er.size();j++){
		  cnt.erase(er[j]);
		}
	      }
	    }
	    int cpos = a[i];
	    //	    cout << "pre cnt[cpos] cpos " << cnt[cpos] << " " << cpos << endl;
	    cnt[cpos]++;

	    while(cnt[cpos]==mid){
	      cnt.erase(cpos);
	      --cpos;
	      if(cpos==0){
		ok=false;
		break;
	      }
	      cnt[cpos]++;	    
	    }
	    //	    cout << "cnt[cpos] cpos " << cnt[cpos] << " " << cpos << endl;
		    
	  }
	}	
      }
      if(!ok) break;
    }

    if(ok) ub = mid;
    else lb = mid;    
  }
  cout << ub << endl;


  
  return 0;
    

}


Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    S = list(input())
    T = list(input())
    S.sort()
    T.sort(reverse = True)
    if S < T:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
long long a[200000];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=k;i<n;i++){
		if(a[i-k]<a[i]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
    return 0;
}

Measured memory_bytes: 5188
#include <iostream>
#include <algorithm>
using namespace std;
int n, w, a[1009], sum[1009], dp[1009];
int main() {
	int cnt = 0;
	while (cin >> n >> w, n) {
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
		int ret = max(0, sum[n] - w);
		for (int i = 1; i < n; i++) {
			dp[i] = 1999999999;
			for (int j = 0; j < i; j++) {
				int cost = abs(w - sum[i] + sum[j]);
				dp[i] = min(dp[i], dp[j] + cost);
			}
			ret = min(ret, dp[i] + max(0, sum[n] - sum[i] - w));
		}
		cout << "Case " << ++cnt << ": " << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b;
	cin>>a>>b;
	if (a>=13)
		cout<<b;
	else if (a>=6 and a<=12)
		cout<<b/2;
	else
		cout<<0;
}

Measured memory_bytes: 256
import collections
a=raw_input()
trans=[None]*(len(a)+1)
trans[len(a)]=[None]*26
for i, ch in reversed(list(enumerate(a))):
	trans[i]=trans[i+1][:]
	trans[i][ord(ch)-ord('a')]=i+1
q=collections.deque([0])
prev=[None]*(len(a)+1)
prev[0]=-1
try:
	while True:
		cur=q[0]
		q.popleft()
		for i in xrange(26):
			if trans[cur][i]==None:
				result=[chr(ord('a')+i)]
				while cur!=0:
					result.append(a[cur-1])
					cur=prev[cur]
				raise KeyboardInterrupt
			elif prev[trans[cur][i]]==None:
				prev[trans[cur][i]]=cur
				q.append(trans[cur][i])
except KeyboardInterrupt:
	print "".join(reversed(result))

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

using namespace std;
 
inline int Arrange(const int start,vector<int> &par){
	if(start!=par[start]) return par[start]=Arrange(par[start],par);
	return start;
}

inline void Unify(const int x,const int y,vector<int> &par){
	par[Arrange(x,par)]=Arrange(y,par);
	return ;
}

inline vector<int> UnionFind(const int n,const vector<pair<int,int>> edge){
	vector<int> par;
	for(int i=0;i<n;i++) par.push_back(i);
	for(int i=0;i<edge.size();i++) Unify(edge[i].first,edge[i].second,par);
	for(int i=0;i<n;i++) Arrange(i,par);
	return par;
}
 
int main(){ 
	int n,m; cin>>n>>m;
	vector<int> v;
	for(int i=0;i<n;i++){
		int k; cin>>k;
		v.push_back(k-1); 
   }
   vector<pair<int,int>> edge;
	for(int i=0;i<m;i++){
		int x,y; cin>>x>>y;
		edge.push_back(make_pair(x-1,y-1));
	}
	vector<int> p=UnionFind(n,edge);
	int ans=0;
	for(int i=0;i<n;i++) ans+=(p[i]==p[v[i]]); 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3060
H,N=map(int,input().split())

L=[]
for i in range(N):
    a,b=map(int,input().split())
    L.append([a,b])
L.sort()
import math
X=math.ceil(H/L[i][0]*L[i][1])
dp=[10**20 for i in range(10**4+100)]
dp[0]=0
for i in range(N):
    for j in range(len(dp)):
        if j%L[i][0]==0:
            Y=j//L[i][0]
        else:
            Y=j//L[i][0]+1
        if j-L[i][0]>=0:
            dp[j]=min(dp[j],Y*L[i][1],dp[j-L[i][0]]+L[i][1])
        else:
            dp[j]=min(dp[j],Y*L[i][1])
print(dp[H])

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

using ll=long long;
using ld=long double;
using P=complex<ld>;
const ll MOD=998244353;

ld cross(P x,P y){
    return x.real()*y.imag()-x.imag()*y.real();
}
bool onLine(P x,P y,P z){
    return cross(x-y,z-x)==0;
}
int main(){
    int n;
    cin>>n;
    vector<P> xy(n);
    for(int i=0;i<n;i++){
        ld x,y;
        cin>>x>>y;
        xy[i]={x,y};
    }
    
    ll res=1;
    for(int i=0;i<n;i++){
        res*=2;
        res%=MOD;
    }
    res--;
    for(int i=0;i<n;i++){
        vector<int> used(n,false);
        res--;
        for(int j=i+1;j<n;j++){
            if(used[j]) continue;
            ll cnt=2;
            for(int k=j+1;k<n;k++){
                if(onLine(xy[i],xy[j],xy[k])){
                    used[k]=true;
                    cnt*=2;
                    cnt%=MOD;
                }
            }
            res-=(cnt-1);
            res%=MOD;
        }
    }
    res=(res%MOD+MOD)%MOD;
    cout<<res<<endl;
    return 0;
}

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

#define ll long long int

using namespace std;

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

	if (a == b) {
		cout << c << endl;
	}
	else if (b == c) {
		cout << a << endl;
	}
	else {
		cout << b << endl;
	}

	return (0);
}

Measured memory_bytes: 256
NM = list(map(int,input().split()))
N=NM[0]
M=NM[1]
road=[]

x = []
y = []
for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

for j in range(1,N+1):
    road.append(x.count(j)+y.count(j))
    road[j-1]=str(road[j-1])

print('\n'.join(road))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n[2],m[2];
string ff[2][105];
char f[2][105][105];

int par[20005],ran[20005];
void init(){ for(int i=0;i<20005;i++) par[i] = i, ran[i] = 0; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }

vector<int>edge[2][20005];;
int root[2];

void solve(int a){
	rep(i,105) rep(j,105) f[a][i][j] = '.';
	rep(i,20005) edge[a][i].clear();
	for(int i=0;i<n[a];i++){
		for(int j=0;j<m[a];j++){
			f[a][i+1][j+1] = ff[a][i][j];
		}
	}
	init();
	for(int i=0;i<n[a]+2;i++){
		for(int j=0;j<m[a]+2;j++){
			if(f[a][i][j] == '.'){
				int dx[4]={0,0,1,-1};
				int dy[4]={1,-1,0,0};
				rep(k,4){
					int nx = i+dx[k];
					int ny = j+dy[k];
					if(0<=nx && nx<n[a]+2 && 0<=ny && ny<m[a]+2 && f[a][nx][ny] == '.'){
						unite(i*105+j, nx*105+ny);
					}
				}
			}
			else{
				int dx[8]={0,0,1,1,1,-1,-1,-1};
				int dy[8]={1,-1,-1,0,1,-1,0,1};
				rep(k,8){
					int nx = i+dx[k];
					int ny = j+dy[k];
					if(0<=nx && nx<n[a]+2 && 0<=ny && ny<m[a]+2 && f[a][nx][ny] == '#'){
						unite(i*105+j, nx*105+ny);
					}
				}
			}
		}
	}
	for(int i=0;i<n[a]+2;i++){
		for(int j=0;j<m[a]+2;j++){
			int dx[4]={0,0,1,-1};
			int dy[4]={1,-1,0,0};
			rep(k,4){
				int nx = i+dx[k];
				int ny = j+dy[k];
				if(0<=nx && nx<n[a]+2 && 0<=ny && ny<m[a]+2 && f[a][nx][ny] != f[a][i][j]){
					int id1 = find(nx*105+ny);
					int id2 = find(i*105+j);
					edge[a][id1].pb(id2);
					edge[a][id2].pb(id1);
					//cout << a << " " << id1 << " " << id2 << endl;
				}
			}
		}
	}
	root[a] = find(0);
}
string dfs(int v,int u,int id){
	vector<string>zan;
	for(int i=0;i<edge[id][v].size();i++){
		int to = edge[id][v][i];
		if(to == u) continue;
		zan.pb( dfs(to,v,id) );
	}
	sort(zan.begin(),zan.end());
	string ret = "(";
	rep(i,zan.size()) ret += zan[i];
	ret += ")";
	return ret;
}
void cmp(){
	rep(x,2) for(int i=0;i<20005;i++){
		SORT(edge[x][i]);
		ERASE(edge[x][i]);
	}
	string x = dfs(root[0],-1,0);
	string y = dfs(root[1],-1,1);
	puts(x==y?"yes":"no");
}
int main(){
	while(1){
		for(int ii=0;ii<2;ii++){
			cin >> n[ii] >> m[ii];
			if(n[ii] == 0) return 0;
			rep(i,n[ii]) cin >> ff[ii][i];
		}
		solve(0);
		solve(1);
		cmp();
	}
}


Measured memory_bytes: 13108
mod=10**9+7
def num2bi(x, k):
  #10進数xを2進数k桁(string)で出力
  out=format(x, '0'+str(k)+'b')
  return out

N=int(input())
A=list(map(int, input().split()))
ma=max(A)
keta=1
while ma>=2**keta:
  keta+=1
  
onekazu=[0 for i in range(keta)]
k=str(keta)
for i in range(N):
  temp=format(A[i], '0'+str(k)+'b')
  onekazu=[onekazu[j]+1 if temp[j]=='1' else onekazu[j] for j in range(keta)]
    
out=0
out=sum([(onekazu[i]*(N-onekazu[i])%mod)*(2**(keta-1-i))%mod for i in range(keta)])
out%=mod  
print(out)

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


void solve(){
    int n;
    cin >> n;
    int a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    int m=0;
    rep(i,n){
        rep(j,n){
            m = max(abs(a[i]-a[j]), m);
        }
    }
    cout << m << endl;
}

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


Measured memory_bytes: 256
def func(n):
    if (n==0):return [n,n+1]
    if (n==9):return [n-1,n]
    return [n-1,n,n+1]
k = int(input())
k_su = 0
lunlun_fl = [1,2,3,4,5,6,7,8,9]
while True:
    k_su += 1
    lunlun_fl_ = lunlun_fl
    #print('{} 桁目探索開始'.format(k_su+1))
    for i in lunlun_fl_:
        if (len(str(i)) != k_su):
            continue
        lunlun_n = list(map(lambda x:int(str(i)+str(x)),func(int(str(i)[-1]))))
        lunlun_fl.extend(lunlun_n)
        if (len(lunlun_fl) >= k):break
    #print(lunlun_fl)
    if (len(lunlun_fl) >= k):break
print(lunlun_fl[k-1])



Measured memory_bytes: 7268
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   // #endif
    int n, m;
    cin>>n>>m;
    char a[n][m];
    for(int i = 0;i<n;i++){
        for(int j =0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            if(a[i][j] == '.'){
                if(i == 0 and j != 0){
                    dp[i][j] = dp[i][j-1] % MOD;
                } else if(i != 0 and j == 0){
                    dp[i][j] = dp[i-1][j] % MOD;
                } else if(i != 0 and j != 0){
                    dp[i][j] = ((dp[i-1][j] % MOD) + (dp[i][j-1] % MOD)) % MOD;
                } else {
                    dp[i][j] =1 ;
                }
            }
        }
    }    
    cout<<dp[n-1][m-1]<<endl;
    return 0;
}



Measured memory_bytes: 9088
from sys import stdin, stdout
from collections import deque, defaultdict

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m, x = rli()
	A = []
	for _ in range(n):
		A.append(list(rli()))
	mask = 0
	for i in range(n):
		mask |= (1 << i)

	opt = INF

	def process(s):
		nonlocal opt
		i = 0
		cost = 0
		algs = [0 for _ in range(m)]
		while s:
			s, bit = divmod(s, 2)
			if bit:
				cost += A[i][0]
				for j in range(1, m+1):
					algs[j-1] += A[i][j]
			i += 1
		if all(skill >= x for skill in algs):
			opt = min(opt, cost)

	process(mask)
	s = mask
	while s > 0:
		process(s)
		s = (s-1) & mask

	print(opt if opt < INF else -1)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 69260
n=int(input())
s=input()
l=len(s)
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
cnt=0
for j in range(2,l):
    for i in range(1,j):
        if j*2<=i+l:
            if s[i-1]!=s[j-1] and s[j-1]!=s[j*2-i-1] and s[i-1]!=s[j*2-i-1]:
                cnt+=1
print(ans-cnt)

Measured memory_bytes: 67920
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value


void solve() {

	int N;
	cin >> N;
	string S[110];
	int P[110];
	map<string, vector<pair<int, int>>> list;
	for (int i = 0; i < N; i++) {
		cin >> S[i] >> P[i];
		list[S[i]].eb(make_pair(P[i], i + 1));
	}

	for (auto &i : list) {
		sort(i.scd.begin(), i.scd.end(), greater<pair<int, int>>());
		for (int j = 0; j < i.scd.size(); j++) {
			cout << (i.scd)[j].scd << endl;
		}
	}

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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


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

    cin >> a >> b >> c;

    if((a+b+c) >=22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
let s = read_line ()
let n = String.length s
let us = Array.make 26 false
let j = ref ~-1
let _ = Char.(String.(iteri (fun i c -> if i > 0 && s.[i - 1] < s.[i] then j := i - 1) s; iteri (fun i c -> if n < 26 || i <= !j then us.(code c - code 'a') <- true) s; if n = 26 && !j = -1 then (print_endline "-1"; exit 0); let m, t = if n < 26 then 0, s else code s.[!j] - code 'a' + 1, sub s 0 !j in for i = m to 25 do if not us.(i) then (Printf.printf "%s%c\n" t (chr (i + code 'a')); exit 0) done))

Measured memory_bytes: 2432