akhauriyash/Code-Regression huggingface dataset:
#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 = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int 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


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...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

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

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


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

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



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int r;
    cin >> r;
    print(3 * r * r);
    
    
}


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

#ifdef LOCAL 
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 2111;
int h, w;
char mp[maxn][maxn];
int dpl[maxn][maxn];
int dpt[maxn][maxn];
int dpr[maxn][maxn];
int dpb[maxn][maxn];

int main() 
{
    scanf("%d%d", &h ,&w);
    for (int i = 0; i < h; ++i) {
        scanf("\n");
        for (int j = 0; j < w; ++j) {
            scanf("%c", &mp[i][j]);
        }
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (mp[i][j] == '#') continue;
            if (i) {
                dpt[i][j] = dpt[i - 1][j];
            }
            if (j) {
                dpl[i][j] = dpl[i][j - 1]; 
            }
            dpt[i][j] += mp[i][j] == '.' ? 1 : 0;
            dpl[i][j] += mp[i][j] == '.' ? 1 : 0;
        }
    }
    for (int i = h - 1; i >= 0; --i) {
        for (int j = w - 1; j >= 0; --j) {
            if (mp[i][j] == '#') continue;
            if (i < h - 1) {
                dpb[i][j]  = dpb[i + 1][j];
            }
            if (j < w - 1) {
                dpr[i][j] = dpr[i][j + 1];
            }
            dpr[i][j] += mp[i][j] == '.' ? 1 : 0;
            dpb[i][j] += mp[i][j] == '.' ? 1 : 0;
        }
    }
    eprintf("dpl[1][5] = %d\n", dpl[1][5]);
    eprintf("dpr[1][5] = %d\n", dpr[1][5]);
    eprintf("dpb[1][5] = %d\n", dpb[1][5]);
    eprintf("dpt[1][5] = %d\n", dpt[1][5]);
    eprintf("\n");
    
    eprintf("\n");
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (mp[i][j] == '.') {
                ans = max(ans, dpt[i][j] + dpl[i][j] + dpb[i][j] + dpr[i][j] - 3);
            }
        }
    }
    printf("%d\n", ans);
}


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

int main() {
    int N, K;
    cin >> N >> K;

    int R, S, P;
    cin >> R >> S >> P;

    string T;
    cin >> T;

    int ans = 0;
    rep(i, N) {
        if (i >= K && T[i] == T[i-K]) T[i] = 'n';
        else {
            if (T[i] == 'r') ans += P;
            else if (T[i] == 's') ans += R;
            else ans += S;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))

x = 0 # 4の倍数の数
y = 0 # 2の倍数の数
z = 0 # それ以外の数
for a in A:
    if a % 4 == 0:
        x += 1
    elif a % 2 == 0:
        y += 1
    else:
        z += 1

if x == 0:
    if z > 0:
        print('No')
    else:
        print('Yes')
else:
    if y == 0:
        if x+1 >= z:
            print('Yes')
        else:
            print('No')
    else: 
        if x >= z:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 14252
#include<iostream>
using namespace std;
int main()
{
  int arr[26]={0};
  string s;
  while(getline(cin,s))
  {
  int l=s.length();
  for(int i=0;i<l;i++)
  {
    if(s[i]>='A' && s[i]<='Z')
    {
      s[i]=tolower(s[i]);
    }
    if(s[i]=='a')
    {
      arr[0]+=1;
    }
    if(s[i]=='b')
    {
      arr[1]+=1;
    }
    if(s[i]=='c')
    {
      arr[2]+=1;
    }if(s[i]=='d')
    {
      arr[3]+=1;
    }if(s[i]=='e')
    {
      arr[4]+=1;
    }if(s[i]=='f')
    {
      arr[5]+=1;
    }if(s[i]=='g')
    {
      arr[6]+=1;
    }if(s[i]=='h')
    {
      arr[7]+=1;
    }if(s[i]=='i')
    {
      arr[8]+=1;
    }if(s[i]=='j')
    {
      arr[9]+=1;
    }if(s[i]=='k')
    {
      arr[10]+=1;
    }if(s[i]=='l')
    {
      arr[11]+=1;
    }if(s[i]=='m')
    {
      arr[12]+=1;
    }if(s[i]=='n')
    {
      arr[13]+=1;
    }if(s[i]=='o')
    {
      arr[14]+=1;
    }if(s[i]=='p')
    {
      arr[15]+=1;
    }if(s[i]=='q')
    {
      arr[16]+=1;
    }if(s[i]=='r')
    {
      arr[17]+=1;
    }if(s[i]=='s')
    {
      arr[18]+=1;
    }if(s[i]=='t')
    {
      arr[19]+=1;
    }if(s[i]=='u')
    {
      arr[20]+=1;
    }if(s[i]=='v')
    {
      arr[21]+=1;
    }if(s[i]=='w')
    {
      arr[22]+=1;
    }if(s[i]=='x')
    {
      arr[23]+=1;
    }if(s[i]=='y')
    {
      arr[24]+=1;
    }if(s[i]=='z')
    {
      arr[25]+=1;
    }
  }
  }
  for(int i=0;i<26;i++)
  {
    cout<<char('a'+i)<<" : "<<arr[i]<<endl;
  }
}



Measured memory_bytes: 3184
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main()
{
	int cnt = 0;
	for (int i = 0; i < 3; ++i)
	{
		int a;
		cin >> a;

		if (a == 5) cnt++;
	}

	if (cnt == 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//約数列挙
vector<ll> FD(ll n) {
	vector<ll> ans;
	ans.push_back(n);
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans.push_back(i);
			if (i != 1 && i * i != n)ans.push_back(n / i);
		}
	}
	return ans;
}

int main() {
	io_init;
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	ll ans = 0;
	auto d = FD(sum);
	for (int i = 0; i < d.size(); i++) {
		vector<ll> B(N);
		for (int j = 0; j < N; j++) {
			B[j] = A[j] % d[i];
		}
		sort(B.begin(), B.end());
		for (int j = 0; j <= N; j++) {
			ll a = 0, b = 0;
			for (int k = 0; k < j; k++) {
				a += B[k];
			}
			for (int k = j; k < N; k++) {
				b += d[i] - B[k];
			}
			if (a == b && a <= K) {
//				cout << a << " " << d[i] << endl;
				ans = max(ans, d[i]);
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
	
	int n;
	cin >> n;
	
	int need = n * (n-1) / 2;
	
	queue<int> playq[n];
	for (int i=0; i<n; i++) {
		for (int j=0; j<n-1; j++) {
			int c;
			cin >> c;
			playq[i].push(c-1);
		}
	}
	
	bool can = true;
	
	vector<pair<int, int> > order;
	
	while (can) {
		can = false;
		for (int i=0; i<n; i++) {
			if (playq[i].size() == 0) continue;
			int want = playq[i].front();
			if (playq[want].size() == 0) continue;
			if (playq[want].front() == i) {
				playq[i].pop();
				playq[want].pop();
				order.push_back(make_pair(i, want));
				can = true;
			}
		}
	}
	
	if (order.size() != need) {
		cout << -1 << endl;
	}
	else {
		
		int las[n]; // last day each player used
		int day[need];
		for (int i=0; i<n; i++) {
			las[i] = -1;
		}
		
		int l = INT_MIN;
		
		for (int i=0; i<need; i++) {
			int pa = order[i].first;
			int pb = order[i].second;
			int la = las[pa];
			int lb = las[pb];
			int lany = max(la, lb);
			int mday = lany + 1;
			day[i] = mday;
			las[pa] = mday;
			las[pb] = mday;
			l = max(day[i], l);
		}
	
		cout << l + 1 << endl;
		
	}
	
}


Measured memory_bytes: 10608
#!/usr/bin/env python3
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
ans = 1
c = [0] * 100010
c[0] = 3
for i in range(n):
    ans *= c[a[i]] - c[a[i] + 1]
    ans %= MOD
    c[a[i] + 1] += 1
print(ans)


Measured memory_bytes: 14276
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	cout <<(n==m ? "Yes" : "No");
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int A ,B ,C ,D;
int main() {
	cin >> A >> B >> C >> D;
  if (A + B == C + D ) {
    cout << "Balanced" << endl;
  }else if(A + B > C + D ){
	cout << "Left" << endl;
  }else{
  cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    long long K,A,B;cin >> K >> A >> B;
    if(K == 1){
        cout << 2 << endl;
        return 0;
    }
    if(A+2 >= B){
        cout << 1+K << endl;
        return 0;
    }
    if(A < B){
        if(K < A+1){
            cout << 1+K << endl;
            return 0;
        }
        long long ans = 0;
        ans += B;
        K -= A+1;
        cout << ans + (B-A)*(K/2) + K%2 << endl;
    }

}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N, K, Q;
int A[MAX_N];
int sumA[MAX_N];

signed main()
{
  cin >> N >> K >> Q;
  REP(n,Q) {
    cin >> A[n]; A[n]--;
    sumA[A[n]]++;
  }

  REP(n,N) {
    if(K - Q + sumA[n] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define fill(x,y) memset(x,y,sizeof(x))
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, i;
	cin >> n;
	string s;
	while(n > 0)
	{
		n--;
		ll x = n % 26;
		// if(x == 0)
		// 	x = 26;
		
		char ch = 'a' + x;
		s = ch + s;
		n /= 26;

	}
	cout << s << endl;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long L = sc.nextInt();
        long R = sc.nextInt();

        int min = 2018;
        int mod;

        for (long i = L; i < R; i++) {
            for (long j = i + 1; j <= R; j++) {
                if (min >= (mod = (int) (i * j % 2019))) {
                    min = mod;
                }
                if (min == 0) {
                    break;
                }
            }
            if(min == 0) {
                break;
            }
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <cstdint>

typedef int64_t i64;

i64 gcd(i64 a, i64 b)
{
	if(a > b) return gcd(b, a);
	if(a == 0) return b;
	return gcd(b % a, a);
}

i64 count_numbers(i64 lim, i64 c, i64 d)
{
	i64 x = lim / c;
	i64 y = lim / d;
	i64 z = lim / (c * d / gcd(c, d));
	return lim - (x + y - z);
}

int main()
{
	i64 a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

	i64 ans = count_numbers(b, c, d) - count_numbers(a - 1, c, d);

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n, a, b;
	cin>>n>>a>>b;
	int res = 0;
	while(n){
		int x = n;
		int s = 0;
		while(x){
			s += x%10;
			x /= 10;
		}
		if(a<=s && s<=b) res+=n;
		n--;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for(ll i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

int main() {
    int a,b;
    while(cin >> a >> b) {
        map<int,int> m;
        m[a]++;
        m[b]++;

        vector<ll> v = divisor(a);
        rep(i,v.size()) {
            m[v[i]]++;
        }

        v = divisor(b);
        rep(i,v.size()) {
            m[v[i]]++;
        }

        int ans = 1;
        map<int,int>::iterator ite;
        for(ite = m.begin(); ite != m.end(); ite++) {
            if(ite->second == 2) {
                ans = max(ans, ite->first);
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) {
                break;
            }
            int i = 0;
            for(int j = 0; i < H; j++) {
                if(i % 2 == 0) {
                    if(W % 2 == 0) {
                        for(int k = 0; k < W/2; k++) {
                            System.out.print("#.");
                        }
                    }else {
                        for(int k = 0; k < W/2; k++) {
                            System.out.print("#.");
                        }
                        System.out.print("#");
                    }
                }else {
                    if(W % 2 == 0) {
                        for(int k = 0; k < W/2; k++) {
                            System.out.print(".#");
                        }
                    }else {
                        for(int k = 0; k < W/2; k++) {
                            System.out.print(".#");
                        }
                        System.out.print(".");
                    }
                }
                System.out.println("");
                i++;
            }
            System.out.println("");
        }
    }
}



Measured memory_bytes: 31884
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
//#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

signed main (){
    string s;
    cin>>s;
    string t="CODEFESTIVAL2016";
    int ans=0;
    rep(i,0,s.size()){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
    


    
}
/*
1-21-2
*/


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l2=[]
hugoc=0
for i in range(n):
  x=l[i]
  if x<0:
    hugoc+=1
  l2.append(abs(x))
l2.sort()
if hugoc%2==0:
  print(sum(l2))
else:
  print(sum(l2[1:])-l2[0])

Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()

int main()
{
    int c[3][3];
    int cimin[3];
    int x = 0;
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
        cimin[i] = min({c[i][0], c[i][1], c[i][2]});
    }
    for (int i = 0; i <= cimin[0]; i++)
    {
        for (int j = 0; j <= cimin[1]; j++)
        {
            for (int k = 0; k <= cimin[2]; k++)
            {
                int count = 0;
                if (c[0][0] - i == c[1][0] - j && c[1][0] - j == c[2][0] - k)
                {
                    count++;
                }
                if (c[0][1] - i == c[1][1] - j && c[1][1] - j == c[2][1] - k)
                {
                    count++;
                }
                if (c[0][2] - i == c[1][2] - j && c[1][2] - j == c[2][2] - k)
                {
                    count++;
                }
                if (count == 3)
                {
                    x++;
                }
            }
        }
    }
    if (x > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> x(n), y(n), h(n);
    int sx, sy, sh;
    for(int i=0; i<n; i++){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i] > 0) sx=x[i], sy=y[i], sh=h[i];
    }

    for(int cx=0; cx<=100; cx++){
        for(int cy=0; cy<=100; cy++){
            int H=sh+abs(sx-cx)+abs(sy-cy);
            bool f=true;
            for(int i=0; i<n; i++){
                int ansh=max(H-abs(x[i]-cx)-abs(y[i]-cy), 0);
                if(ansh != h[i]) f=false;
            }
            if(f) cout << cx << " " << cy << " " << H << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, t, a[100008];

int main(){
	cin >> n >> t;
	for(ll i = 1; i <= n; i++){cin >> a[i];}
	
	ll minp = 1e9+1;
	ll maxd = 0;
	ll ans = 0;
	
	for(ll i = 1; i <= n; i++){
		if(a[i]-minp == maxd){
			ans++;
		}
		if(a[i]-minp > maxd){
			maxd = a[i]-minp;
			ans = 1;
		}
		
		minp = min(a[i], minp);
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define sc scanf
#define pf printf
#define ll long long
#define sz size()

int main()
{
    ll n,i,b,w,t,a;
    while(cin>>a>>b)
    {
        cout<<(a*b)/__gcd(a,b)<<endl;
    }
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  long long H, W; cin >> H >> W;
  long long Sa, Sb, Sc;
  long long Sdif;
  long long minSdif = (long long)1e9;
  for(long long h = 1; h < H; ++h) {
    Sa = h * W;
    Sb = (H-h) * (W/2);
    Sc = (H-h) * (W - W/2);
    if(Sc < Sb) swap(Sb, Sc);
    if(Sb < Sa) swap(Sa, Sb);
    if(Sc < Sb) swap(Sb, Sc);
    Sdif = Sc - Sa;
    minSdif = min(minSdif, Sdif);
    Sa = h * W;
    Sb = (H-h)/2 * W;
    Sc = (H-h - (H-h) / 2) * W;
    if(Sc < Sb) swap(Sb, Sc);
    if(Sb < Sa) swap(Sa, Sb);
    if(Sc < Sb) swap(Sb, Sc);
    Sdif = Sc - Sa;
    minSdif = min(minSdif, Sdif);
  }
  swap(H, W);
  for(long long h = 1; h < H; ++h) {
    Sa = h * W;
    Sb = (H-h) * (W/2);
    Sc = (H-h) * (W - W/2);
    if(Sc < Sb) swap(Sb, Sc);
    if(Sb < Sa) swap(Sa, Sb);
    if(Sc < Sb) swap(Sb, Sc);
    Sdif = Sc - Sa;
    minSdif = min(minSdif, Sdif);
    Sa = h * W;
    Sb = (H-h)/2 * W;
    Sc = (H-h - (H-h) / 2) * W;
    if(Sc < Sb) swap(Sb, Sc);
    if(Sb < Sa) swap(Sa, Sb);
    if(Sc < Sb) swap(Sb, Sc);
    Sdif = Sc - Sa;
    minSdif = min(minSdif, Sdif);
  }
  cout << minSdif << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}


int main() {
	long long N, M;
	long long ans = 0;

	cin >> N >> M;

	if (N == 1 || M == 1) {
		if (N == 1 && M == 1) {
			ans = 1;
		}
		else {
			ans = N * M - 2;
		}
	}
	else {
		ans = (N - 2)*(M - 2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      #define ll int
      #define N 400000
      #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
      #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
      #define po pop_back
      #define pb push_back
      #define pp pair<ll,ll>
      #define lb lower_bound
      #define fi first
      #define se second
      #define debug(x) cout << #x << " = " << x << endl
      #define ub upper_bound
      #define ibs ios_base::sync_with_stdio(false)
      #define cti cin.tie(0)
      #define all(x) x.begin(),x.end()
      #define PI 3.14159265
      #define cot cout.tie(0)
      using namespace std;
       /**
        * @author :: Sawlani
        *
        */
        int main()
        {
            ll a,b;
            cin >>  a >> b;

            if(a>=1&&a<=9&&b>=1&&b<=9)
                cout <<  a*b <<  endl;
            else
                cout << -1 <<  endl;


        }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; 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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  cout << n*m - (n+m-1) << endl;
}

Measured memory_bytes: 256
N = int(input())
A, B = map(int,input().split())
P = list(map(int,input().split()))
prob1 = 0
prob2  =0
prob3 = 0
for i in P: 
  if i <= A: prob1 += 1
  elif B + 1 <= i: prob3 += 1
  else: prob2 += 1
print(min(prob1,prob2,prob3))    

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

using namespace std;

#define MAX 10

struct Edge{
  int dst,weight;
  Edge(int dst,int weight) : dst(dst),weight(weight) {}
};

int V,E;
int ans_dist;
vector<int> ans;
vector<Edge> G[MAX];
bool visited[MAX][MAX];

void dfs(int v,int dist,vector<int> &routes){
  if(ans_dist < dist){
    ans_dist = dist;
    ans = routes;
  }
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    int to = G[v][i].dst;
    if(visited[v][to]) continue;
    visited[v][to] = visited[to][v] = true;
    routes.push_back(to+1);
    dfs(to,dist+G[v][i].weight,routes);
    routes.pop_back();
    visited[v][to] = visited[to][v] = false;
  }
}

int main(){
  int a,b,c;
  while(cin >> V >> E, (V | E)){
    ans_dist = 0; ans.clear();
    for(int i = 0 ; i < V ; i++){
      G[i].clear();
    }
    memset(visited,false,sizeof(visited));
    for(int i = 0 ; i < E ; i++){
      cin >> a >> b >> c; a--, b--;
      G[a].push_back(Edge(b,c));
      G[b].push_back(Edge(a,c));
    }
    vector<int> vec;
    for(int i = 0 ; i < V ; i++){
      vec.push_back(i+1);
      dfs(i,0,vec);
      vec.pop_back();
    }
    cout << ans_dist << endl;
    for(int i = 0 ; i < (int)ans.size() ; i++){
      if(i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);
const A = input[1].split(" ").map((val) => parseInt(val, 10));

const gcd = (a, b) => (b ? gcd(b, a % b) : a);

if (N === 2) {
  console.log(Math.max(A[0], A[1]));
  return;
}

let sumFromL = [];
let sumFromR = [];

sumFromL[0] = A[0];
for (let i = 1; i < N; i++) {
  sumFromL[i] = gcd(sumFromL[i - 1], A[i]);
}

sumFromR[N - 1] = A[N - 1];
for (let i = N - 2; i >= 0; i--) {
  sumFromR[i] = gcd(sumFromR[i + 1], A[i]);
}

let gcds = [];
for (let i = 0; i < N; i++) {
  gcds[i] = gcd(sumFromL[i - 1] || 0, sumFromR[i + 1] || 0);
}

console.log(Math.max(...gcds));


Measured memory_bytes: 34676
#include <vector>
#include <iostream>
#include <iomanip>

using namespace std;

typedef long int ll;

double solve(vector<vector<vector<double>>>& dp,vector<vector<vector<bool>>>& memo,int a,int b,int c,int n)
{

    if (a<0 || b<0 || c<0) return 0;
    if (a==0 && b==0 && c==0) return 0;

    if (memo[a][b][c]) return dp[a][b][c];


    double den = double(a) + double(b) + double(c);

    double A = (double(a)/den) * solve(dp,memo,a-1,b,c,n);

    double B = (double(b)/den) * solve(dp,memo,a+1,b-1,c,n);

    double C = (double(c)/den) * solve(dp,memo,a,b+1,c-1,n);

    memo[a][b][c] = true;

    double ex = double(n)/den;
    dp[a][b][c] = A + B + C + ex;

    //cout<<dp[a][b][c]<<endl;

    return dp[a][b][c];
}

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

    int a = 0;
    int b = 0;
    int c = 0;

    for (int i=0;i<N;++i)
    {
        int x;
        cin>>x;

        if (x==1) ++a;
        if (x==2) ++b;
        if (x==3) ++c;
    }

    vector<vector<vector<double>>> dp(N+1,vector<vector<double>>(N+1,vector<double>(N+1)));
    vector<vector<vector<bool>>> memo(N+1,vector<vector<bool>>(N+1,vector<bool>(N+1)));

    cout<<setprecision(14)<<solve(dp,memo,a,b,c,N)<<endl;

    return 0;
}


Measured memory_bytes: 227144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=110;
int a[MAX][MAX],b[MAX];
int main()
{
    int n,m,c;
    scanf("%d %d %d",&n,&m,&c);
    for(int i=0;i<m;i++)
        scanf("%d",&b[i]);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            scanf("%d",&a[i][j]);
    }
    int ans=0,sum;
    for(int i=0;i<n;i++)
    {
        sum=0;
        for(int j=0;j<m;j++)
        {
            sum+=b[j]*a[i][j];
        }
        if(sum+c>0) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int g[201][201][201];

int gcd3(int a, int b, int c){
    if(g[a][b][c] > 0){
        return g[a][b][c];
    }

    if(a%b == 0){
        if(b%c == 0){
            g[a][b][c] == c;
            return c;
        }else{
            return gcd3(a, c, b%c);
        }
    }else{
        return gcd3(b, a%b, c);
    }

}

int main(){
    int K;
    cin >> K;
        
    for(int i=0; i<=K; i++){
        for(int j=0; j<=K; j++){
            for(int k=0; k<=K; k++){
                g[i][j][k] = -1;
            }
        }
    }
    long long ans = 0;
    for(int i=1; i<=K; i++){
        for(int j=1; j<=K; j++){
            for(int k=1; k<=K; k++){
                ans += gcd3(i, j, k);
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define mk make_pair

const int MAXN = 112345;
const double PI = atan(1) * 4;

map<char, int> cnt;

int main() {

	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		
		for(char x = 'a'; x <= 'z'; x++) {
			
			int qt = 0;
			for(int j = 0; j < s.size(); j++)
				if(s[j] == x) qt++;
			
			if(cnt.count(x)) cnt[x] = min(cnt[x], qt);						
			else cnt[x] = qt;
			
			//cout << x << " " << cnt[x] << endl;	
		}
	}
	
	string ans = "";
	for(char x = 'a'; x <= 'z'; x++) {
		for(int i = 0; i < cnt[x]; i++)
			ans += x;
	}
	
	cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
    int a,b,x;
    
    scanf("%d %d",&a,&b);
    
    x=a-b;
    
    if(x==0)cout<<"a == b"<<endl;
    else if(x>0)cout<<"a > b"<<endl;
    else cout<<"a < b"<<endl;
    
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    ll b = 0, c = 0;
    for (int i = n-1; i >= 1; i--) {
        if (a[i] == a[i-1]) {
            if (b == 0) {
                b = a[i];
                i--;
            } else {
                c = a[i];
                break;
            }
        }
    }
    cout << b * c << endl;
    return 0;
}


Measured memory_bytes: 3996
def main():
  # S = list(input())
  S = input()

  sum_ = 0
  for bit in range(1 << len(S)-1):
    pre = 0
    for i in range(len(S)-1):
      mask = 1 << i
      if (bit & mask):
        # print(S[pre:i+1])
        sum_ += int(S[pre:i+1])
        pre = i+1
      # print('bit:', bin(bit))
      # print('mask', bin(mask))
    # print(S[pre:])
    sum_ += int(S[pre:])
  print(sum_)


if(__name__ == '__main__'):
  main()

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

int main()
{
    int N, M, C, ans, temp;
    cin >> N >> M >> C;
    int A[N][M], B[M];
    for (int i = 0; i < M; i++)
        cin >> B[i];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    ans = 0;
    for (int i = 0; i < N; i++) {
        temp = 0;

        for (int j = 0; j < M; j++) {
            temp += A[i][j] * B[j];
        }

        if (temp + C > 0)
            ans += 1;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N=330;
int i,j,k,n,m,ch,ff,ans,t;
int a[N][N],z[N],p[N];
vector<int> A[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int main() {
	R(n);R(m);
	ans=n;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) R(a[i][j]);
	for (i=1;i<=n;i++) p[i]=1,A[a[i][1]].push_back(i);
	for (i=1;i<m;i++) {
		t=0;
		for (j=1;j<=m;j++) if (!z[j] && A[j].size()>A[t].size()) t=j;
		ans=min(ans,(int) A[t].size());
		z[t]=1;
		for (j=0;j<A[t].size();j++) {
			int x=A[t][j];
			while (z[a[x][p[x]]]) p[x]++;
			A[a[x][p[x]]].push_back(x);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1280
my $input = <STDIN>;
chomp $input;
my ($h, $w) = split / /, $input;
my @a;
for ($i=0; $i<$h; $i++) {
  my $input = <STDIN>;
  chomp $input;
  my @tmp = split(/ /, $input);
  push(@a, @tmp);
}
my $num = 0;
my $out = "";
for ($i=0; $i<$h; $i++) {
	for ($j=0; $j<$w-1; $j++) {
    	my $t = $i * $w + $j;
        if ($a[$t] % 2 == 1) {
        	$num++;
            $a[$t] -= 1;
            $a[$t+1] += 1;
            $out .= ($i+1) . " " . ($j+1) . " " . ($i+1)
              . " " . ($j+2) . "\n";
        }
    }
}
$j = $w - 1;
for ($i=0; $i<$h-1; $i++) {
	my $t = $i * $w + $j;
    if ($a[$t] % 2 == 1) {
    	$num++;
        $a[$t] -= 1;
        $a[$t+$w] += 1;
        $out .= ($i+1) . " " . ($j+1) . " " . ($i+2)
          . " " . ($j+1) . "\n";
    }
}
print $num . "\n";
print $out;

Measured memory_bytes: 29952
#include<bits/stdc++.h>
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rev(a,n) reverse(a,a+n)
using namespace std;
int n,b;
ll ans;
int main() {
	cin>>n;
	vector<ll> a(n);
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) a[i]-=i+1;
	sort(all(a));
	b=a[n/2];
	rep(i,0,n) ans+=abs(a[i]-b);
	cout<<ans;
	return 0;
}


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

template<typename ...> static inline int gc(void) { return getchar(); }
static inline void read(long long int &x){int k;x=0;for(;;){k=gc();if(48<=k&&k<=57){x=k-48;break;}}for(;;){k=gc();if(k<48||k>57)break;x=x*10+k-48;}}

typedef priority_queue<long long> P;
long long d[100000], m, i, M, N, O, a[300000];
P q;

int main(){
    read(N);
    M = N << 1;
    O = N * 3;
    for(; i < O; ++i){
        read(a[i]);
        q.push(-a[i]);
        m += a[i];
        if(!(i ^ N - 1)){
            *d = m;
        }
        if((N <= i) && (i < M)){
            m += q.top();
            q.pop();
            d[i - N + 1] = m;
        }
    }
    q = P();
    m = 0;
    for(i = N * 3; --i >= N;){
        q.push(a[i]);
        m += a[i];
        if(!(i ^ M)){
            d[i - N] -= m;
        }
        if(i < M){
            m -= q.top();
            q.pop();
            d[i - N] -= m;
        }
    }
    cout << *max_element(d, d + N + 1) << endl;
}


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

using namespace std;

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

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int s;
  double w, h;
  while(scanf("%lld,%lf,%lf", &s, &w, &h) != EOF) {
    double bmi = w/(h*h);
    if(bmi >= 25) printf("%lld\n", s);
  }

  return 0;
}

Measured memory_bytes: 3216
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, a, b;
    cin >>n >>a >>b;
    cout <<min(n*a, b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    int G[n][n+1];
    memset(G, 0, sizeof(G));
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a][b] = 1;
        G[b][a] = 1;
    }

    int perm[n];
    for (int i = 0; i < n; i++) {
        perm[i] = i;
    }
    int ans = 0;
    do {
        for (int i = 0; i < n - 1; i++) {
            if (!G[ perm[i] ][ perm[i + 1] ]) break;
            if (i == n - 2) ans++;
        }
    } while (next_permutation(perm, perm + n) && perm[0] == 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

main()
{
  int N,T,i,min;
  int *c,*t;
  scanf("%d%d",&N,&T);
  min = 10000;
  c = malloc(sizeof(int)*N);
  t = malloc(sizeof(int)*N);
  for(i=0;i<N;i++)
  {
    scanf("%d%d",&c[i],&t[i]);
    if(t[i]<=T)
      if(min>=c[i])
        min = c[i];
  }
  if(min == 10000)
    printf("TLE\n");
  else
    printf("%d\n",min);
  
}

Measured memory_bytes: 128
#!/usr/bin/env python3


def main():
    n, m = list(map(int, input().split()))
    p = [i-1 for i in list(map(int, input().split()))]

    uf = UnionFind(n)
    for i in range(m):
        x, y = list(map(int, input().split()))
        uf.union(x-1, y-1)

    roots = uf.roots()
    sets_dict = {}
    members_dict = {}
    for i in roots:
        sets_dict[i] = set([])
        members_dict[i] = set([])

    for i in range(n):
        root = uf.find(i)
        sets_dict[root].add(p[i])
        members_dict[root].add(i)
        # print(i, root)
    # print(sets_dict)
    # print(members_dict)
    ans = 0
    for i in roots:
        ans += len(sets_dict[i] & members_dict[i])
    print(ans)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


if __name__ == "__main__":
    main()


Measured memory_bytes: 77340
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; i++)
 
//const long long INF = 1LL << 60;
const int INF = 1e9;
using ll = long long;

int main()
{
	std::string S;
	std::cin >> S;

	bool isOk = true;
	int ans = 0;
	int tmp = 0;
	for(char c : S)
	{
		if((c != 'A') && (c != 'C') && (c != 'T') && (c != 'G'))
		{
			isOk = false;
			tmp = 0;
		}
		else
		{
			isOk = true;
			tmp++;
		}
		ans = std::max(ans, tmp);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3632