akhauriyash/Code-Regression huggingface dataset:
/************************************************************LET US BREAK BAD!****************************************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    //#ifndef ONLINE_JUDGE
    //    freopen("../input.txt", "r", stdin);
    //    freopen("../output.txt", "w", stdout);
    //#endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll h, w, m;
        cin>>h>>w>>m;
        vlp v(m);
        vl r(h, 0);
        vl c(w, 0);
        map<ll, map<ll, ll>> mm;
        rep(i, m){
            cin>>v[i].fst>>v[i].sec;
            v[i].fst--; v[i].sec--;
            mm[v[i].fst][v[i].sec] = 1;
            r[v[i].fst]++;
            c[v[i].sec]++;
        }
        ll mx1 = *max_element(r.begin(), r.end());
        ll mx2 = *max_element(c.begin(), c.end());
        ll ans = mx1+mx2-1;
        vl rr;
        vl cc;
        rep(i, h){
            if(r[i]==mx1){
                rr.pb(i);
            }
        }
        rep(i, w){
            if(c[i]==mx2){
                cc.pb(i);
            }
        }
        ll flag = 0;
        rep(i, (int)rr.size()){
            rep(j, (int)cc.size()){
                if(mm[rr[i]][cc[j]]==0){
                    ans++;
                    flag = 1;
                    break;
                }
            }
            if(flag){
                break;
            }
        }
        cout<<ans<<endl;


    }
return 0;
}


Measured memory_bytes: 67848
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
#define pb 					push_back
#define FAST_IO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<" ";
	return os;
}



int h[100002];
int a[100002];
int main() {	
	int  n, m;
	cin >> n >> m;
	for(int i=1; i<=n; i++) {
		cin >> h[i];
	}
	for(int i=1; i<=m; i++) {
		int x, y;
		cin >> x >> y;
		a[x] = max(a[x], h[y]);
		a[y] = max(a[y], h[x]);
	}
	int ans =0;
	for(int i=1; i<=n; i++) {
		if(h[i]> a[i]) {
			// cout << i << " ";
			ans++;
		}
	}
	// cout << "\n";
	cout  << ans << "\n";
	return 0;
}














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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int K;
int d[MC];
priority_queue<P2 , vector<P2> , greater<P2> > Q;

int main(){
	cin >> K;
	repp(i,1,K){
		int z = i;
		while(z>0){
			d[i] += z%10;
			z /= 10;
		}
		Q.push(MP(d[i],i));
	}
	{
		int z = K;
		while(z>0){
			d[0] += z%10;
			z /= 10;
		}
		Q.push(MP(d[0],0));
	}
	while(!Q.empty()){
		int x = Q.top().second;
		Q.pop();
		repp(i,0,10){
			int y = (x*10+i)%K;
			if(d[y] > d[x]+i){
				d[y] = d[x]+i;
				Q.push(MP(d[y],y));
			}
		}
	}
	cout << d[0] << endl;
	return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define int long long
#define abs(a) llabs(a)
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

long long x[10000010], y[10000010];
signed main()
{

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

   int a, n, cnt = 0, ans = 0, wa, cans = 0;
   string s, v;

   cin >> n;

   rep(i, n)
   {
      cin >> x[i];
      cnt = cnt + x[i];
   }

   rep(i, n)
   {
      if (ans + x[i] >= (cnt - ans))
         break;
      ans = ans + x[i];
   }

   cout << (abs(ans - abs(cnt - ans))) << '\n';
}

Measured memory_bytes: 2304
import java.util.*;

public class Main {

    static int mod = 2019;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        long r = sc.nextLong();
        long lmod = l % mod;
        long diff = r - l;
        if(2019 <= lmod + diff) System.out.println(0);
        else{
            long ans = 2019;
            for (long i = l; i < r; i++) {
                for (long j = i+1; j <= r; j++) {
                    ans = Math.min(ans, i * j % mod);
                }
            }
            System.out.println(ans);
        }
        sc.close();

    }

}


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

int main() {
  int A;
  cin >> A;
  if(A > 29){
    cout << "Yes" << endl;
  }
else{
cout << "No" << endl;
}
 
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	int N;
	cin >> N;
	vector<vector<pair<int, int>>> K(N);
	fx(N) {
		int A;
		cin >> A;
		fy(A) {
			pairsp(K[x])
		}
	}
	int ans = 0;
	for (int i = 0; i < 1 << N;i++) {
		vector<int> trues;
		fx(N) {

			if (((1<<x)&i)!=0) {
				trues.push_back(x);
			}
		}
		bool res = true;
		for (int p : trues) {
			for (pair<int,int> a: K[p]) {
				if(((1 << (a.first-1)) & i) == 0) {
					if (a.second==1) {
						res = false;
					}
				}
				else {
					if (a.second == 0) {
						res = false;
					}
				}
			}
		}

		if (res) {
			ans = max(ans, (int)trues.size());
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 256
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 24292
#include<iostream>
#include<string>
#include <cmath>
#include <typeinfo>
#define FOR(i,a,b) for(int i = a;i<=b; i++)
#define days 5*1e15
using namespace std;

string convertString(string a){
    string ans;
    long long b = stoi(a);
    double sum = (pow(10,b) - 1)/9;
    b *= sum;
    ans = to_string(b);
    return ans;
}

int main() {
//    long double sum;
//    for(int i = 0; i<str.length();i++){
//        long long b = str[i] - '0';
//        sum = (pow(10,(long long)pow(2,days)) - 1)/9;
//        b *= sum;
//        ans += to_string(b);
//    }
    string str;
    long long count = 0, i = 0, ans;
    long long k;
    getline(cin, str);
    cin >> k;
    if((str[0]-'0') != 1) cout << str[0];
    else{
        while((str[i]-'0') == 1){
        count++;
        i++;
    }
    if(count >= k) cout << 1;
    else {
        ans = str[count]-'0';
        cout << ans;
        }
    }

}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000000000000000
#define mod 1000000007
#define IO                  \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);// freopen("output.txt","w",stdout);freopen("input.txt","r",stdin);
using namespace std;	
int main()
{
	IO
	int n,k=2;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	ll dp[n];
	for(int i=0;i<n;i++)dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int ii=1;ii<=k&&ii+i<n;ii++)
		{
			dp[i+ii]=min(dp[i+ii],dp[i]+abs(arr[i]-arr[i+ii]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
def main():
    n, m = map(int, input().split())
    if n%2:
        for i in range(1, m+1):
            print(i, n-i+1)
    else:
        for i in range(1, m+1):
            if n-2*i+1 > n//2:
                print(i, n-i+1)
            else:
                print(i, n-i)
            

if __name__ == "__main__":
    main()

Measured memory_bytes: 75296
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>(b);i--)
using namespace std;

int main(void) {
	int count = 0;
	int n;
	int* l;
	int* r;
	cin >> n;
	l = new int[n + 1];
	r = new int[n + 1];
	FOR(i, 1, n + 1) {
		cin >> l[i] >> r[i];
		count = count + (r[i] - l[i]+1);
	}
	cout << count << endl;;
	return 0;
}

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

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> c.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i = 0; i < (1<<H); i++) {
    for(int j = 0; j < (1<<W); j++) {
      int cnt = 0;
      for(int k = 0; k < H; k++) {
        for(int l = 0; l < W; l++) {
          if(c.at(k).at(l) == '#' && (1&i>>k) == 0 && (1&j>>l) == 0) {
            cnt++;
          }
        }
      }
      if(cnt == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


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

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

//~ int v[100100];
vector<vector<ll>> dp(110, vector<ll>(100100, 0));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));
ll w[110], v[110];

ll rec(int N, int W){
    if(dp[N][W] > 0) return dp[N][W];
    if(N==0) return 0;
    
    ll r=0;
    chmax(r, rec(N-1, W));
    if(W-w[N-1] >= 0) chmax(r, rec(N-1, W-w[N-1]) + v[N-1]);
    
    return dp[N][W] = r;
}

int main(){
    int N, W;
    cin >> N >> W;
    
    rep(i, N) cin >> w[i] >> v[i];
    
    cout << rec(N, W) << endl;
    return 0;
}


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

int main() {
	for(int a = 1; a <= 9; ++a) {
		for(int b = 1; b <= 9; ++b) {
			cout << a << "x" << b << "=" << a * b << "\n";
		}
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1112
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    s = []
    flg = False
    onry = False
    tmp_max = 0
    tmp_arr = []
    for i in range(N):
        tmp = inputInt()
        s.append(tmp)
        if tmp % 10 != 0:
            tmp_max += tmp
            tmp_arr.append(tmp)
            flg = True
            if onry == False:
                onry = True
            else:
                onry = None
            
    if flg == False:
        print(0)
        sys.exit()
        
    if onry == True or tmp_max % 10 != 0:
        print(sum(s))
        sys.exit()
        
    print(sum(s)-min(tmp_arr))
        
        
if __name__ == "__main__":
	main()


Measured memory_bytes: 39408
import Control.Applicative
import Data.List

main = do
    [a,b,c,d] <- map read . words <$> getLine
    putStrLn $ if (solve a b c d) then "Yes" else "No"

solve a b c d = e<=d || (f<=d && g<=d)
    where e = abs (a-c)
          f = abs (a-b)
          g = abs (b-c)

Measured memory_bytes: 508
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const long long INF = 1e18;
const double PI = 2 * asin(1);


int main(){
  int N, Q; cin >> N >> Q;
  string S; cin >> S;

  vector <char> T(Q), D(Q);
  for (int i = 0; i < Q; i++){
    cin >> T[i] >> D[i];
  }

  bool flagL = false, flagR = false;

  int num = N - 1;
  for (int i = 0; i < Q; i++){
    if (S[num] == T[i]){
      if (D[i] == 'L') num--;
      else num++;
    }
    if (num >= N){
      flagR = true; break;
    }else if (num < 0){
      cout << 0 << endl;
      return 0;
    }
  }
  num = 0;
  for (int i = 0; i < Q; i++){
    if (S[num] == T[i]){
      if (D[i] == 'L') num--;
      else num++;
    }
    if (num < 0) {
      flagL = true; break;
    }else if (num >= N){
      cout << 0 << endl;
      return 0;
    }
  }
  
  int ansL = 0, ansR = N;

  int L = 0, R = N - 1;
  while (flagL == true){
    const int start = (L + R) / 2;
    int now = start;
    bool flag = true;
    for (int i = 0; i < Q; i++){
      if (T[i] == S[now]){
        if (D[i] == 'L') now--;
        else now++;
      }
      if (now < 0){
        flag = false; break;
      }else if (now >= N){
        break;
      }
    }

    if (flag == true) R = start;
    else L = start;

    if (start == (L + R) / 2){
      if (flagR == false){
        cout << N - R << endl;
        return 0;
      }
      ansL = R; break;
    }
  }

  L = 0, R = N - 1;
  while (flagR == true){
    const int start = (L + R) / 2;
    int now = start;
    bool flag = true;
    for (int i = 0; i < Q; i++){
      if (T[i] == S[now]){
        if (D[i] == 'L') now--;
        else now++;
      }
      if (now < 0){
        break;
      }else if (now >= N){
        flag = false; break;
      }
    }

    if (flag == true) L = start;
    else R = start;

    if (start == (L + R) / 2){
      if (flagL == false){
        cout << L + 1 << endl;
        return 0;
      }
      
      ansR = L; break;
    }
  }
  cout << max(ansR - ansL + 1, 0) << endl;
  

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>

const static int MIN = -1000000;
const static int MAX = 1000000;

int main(void){
    int k, x;
    std::cin >> k >> x;
    int cmax = std::min(MAX, x + k - 1);
    int cmin = std::max(MIN, x - k + 1);
    for(int i = cmin; i <= cmax; i++){
        std::cout << i << " ";
    }
    std::cout << std::endl;
    return 0;
}

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

int main() {
    int input;
    int i = 0;

    while (true) {
        cin >> input;
        if (input == 0) {
            return 0;
        }
        i++;
        cout << "Case " << i << ": " << input << endl;
    }

    return 0;
}


Measured memory_bytes: 2988
import java.util.Scanner;

public class Main {

	final static int Row = 12;
	final static int Col = 12;
	
	static int[][] field = new int[Row+2][Col+2];
	
	enum Direction{
		Right(0,1),Down(1,0),Left(0,-1),Up(-1,0);
		
		int r,c;
		
		Direction(int r,int c){
			this.r=r;
			this.c=c;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while( sc.hasNext()) {
			for(int r=1;r<=Row;r++) {
				String str=sc.nextLine();
				if("".equals(str))str=sc.nextLine();
				char[] value = str.toCharArray();
				for(int c=1;c<=Col;c++) {
					field[r][c]=Character.getNumericValue(value[c-1]);
				}
			}
			System.out.println(CountIslands());
			
		}
	}
	
	static int CountIslands(){
		int islandCount=0;
		for(int r=1;r<=Row;r++) {
			for(int c=1;c<=Col;c++) {
				if(FourDirectionSearch(r,c)) {
					islandCount++;
				}
			}
		}
		return islandCount;
		
	}
	
	static boolean FourDirectionSearch(int r,int c){
		if(field[r][c]==1) {
			field[r][c]=0;
			
			for(Direction d:Direction.values()) {
				FourDirectionSearch(r+d.r,c+d.c);
			}
			
			return true;
		}
		return false;
		
	}

}



Measured memory_bytes: 26456
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;int G=0;long long K=0;vector<long long>H(N);
  for(int X=0;X<N;X++){
    long long J=0;cin>>J;H[X]=abs(J);K+=abs(H[X]);
    if(J>=0)G++;
  }
  sort(H.begin(),H.end());
  if(G%2==N%2)cout<<K<<endl;
  else cout<<K-H[0]*2<<endl;
}

Measured memory_bytes: 4048
#include<stdio.h>

int main(void)
{
    int n, a[10000], kazu;
    int soe = 0;
    int max, min;
    long sum = 0;

    scanf("%d", &n);

    kazu = n;
    while (n != 0){
        scanf(" %d", &a[soe]);
        --n;
        ++soe;
    }

    max = a[0];
    min = a[0];

    soe = 0;

    while (soe != kazu){
        if (min > a[soe]){
            min = a[soe];
        }

        if (max < a[soe]){
            max = a[soe];
        }

        sum += (long)a[soe];

        ++soe;
    }

    printf("%d %d %ld\n", min, max, sum);

    return 0;
}

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

int main(){
    string N;
    cin >> N;
    int a = N[N.length()-1] - '0';
    // printf("%d\n", a);
    if (a == 3){
        cout << "bon" << endl;
    } else if (a == 0 || a == 1 || a == 6 || a == 8){
        cout << "pon" << endl;
    } else{
        cout << "hon" << endl;
    }
    return 0;
}

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

int main()
{
    int a,b,c,d,ans=0;
    cin>>a>>b>>c>>d;
    if(a==1){
        if(b==4){
            if((c==7&&d==9)||(c==9&&d==7)){
                ans=1;
            }
        }
        if(b==7){
            if((c==4&&d==9)||(c==9&&d==4)){
                ans=1;
            }
        }
        if(b==9){
            if((c==7&&d==4)||(c==4&&d==7)){
                ans=1;
            }
        }
    }
    if(a==4){
        if(b==1){
            if((c==7&&d==9)||(c==9&&d==7)){
                ans=1;
            }
        }
        if(b==7){
            if((c==1&&d==9)||(c==9&&d==1)){
                ans=1;
            }
        }
        if(b==9){
            if((c==7&&d==1)||(c==1&&d==7)){
                ans=1;
            }
        }
    }
    if(a==7){
        if(b==4){
            if((c==1&&d==9)||(c==9&&d==1)){
                ans=1;
            }
        }
        if(b==1){
            if((c==4&&d==9)||(c==9&&d==4)){
                ans=1;
            }
        }
        if(b==9){
            if((c==1&&d==4)||(c==4&&d==1)){
                ans=1;
            }
        }
    }
    if(a==9){
        if(b==4){
            if((c==7&&d==1)||(c==1&&d==7)){
                ans=1;
            }
        }
        if(b==7){
            if((c==4&&d==1)||(c==1&&d==4)){
                ans=1;
            }
        }
        if(b==1){
            if((c==7&&d==4)||(c==4&&d==7)){
                ans=1;
            }
        }
    }
    if(ans==1)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[100100],res;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=n;i>=1;i--){
		res+=a[i]/2;
		a[i]%=2;
		if(a[i]&&a[i-1]){
			a[i]--;
			a[i-1]--;
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4408
n = int(input())
A = [int(j) for j in input().split()]
q = int(input())
m = [int(j) for j in input().split()]
total = []
for i in range(2**n):
    bag = []
    for j in range(n):
        if ((i>>j)&1):
            bag.append(A[j])
    total.append(sum(bag))

for m1 in m:
    if m1 in set(total):
        print('yes')
    else:
        print('no') 


Measured memory_bytes: 43084
import java.util.*;

class Main {
	public static void main(String[] args) {
		//int[] ary= {1819, 2003, 876, 2840, 1723, 1673, 3776, 2848, 1592, 922};
		Scanner scan = new Scanner(System.in);
		
		Integer[] ary= new Integer[10]; 
		//ArrayList<Integer> ary = new ArratList<Integer>();
		
		for(int i = 0; i < 10; i++) {
			ary[i] = scan.nextInt();
		}

		int max1 = 0, max2 = 0, max3 = 0, temp = 0;
		
		for(int height:ary) {
			if(max3 < height) {
				if(max2 < height) {
					if(max1 < height) {
						max3 = max2;
						max2 = max1;
						max1 = height;
					}
					else {
						max3 = max2;
						max2 = height;
					}
				}
				else {
					max3 = height;
				}
			}
		}
		/*
		Arrays.sort(ary);
		
		for(int i : ary) {
			System.out.println(i);
		}
		
		
		max1 = ary[9];
		max2 = ary[8];
		max3 = ary[7];
		*/
		System.out.println(max1);
		System.out.println(max2);
		System.out.println(max3);
		
	}
}

Measured memory_bytes: 17176
#include <stdio.h>
int main()
{
    int a[3];
    int i, j;
    int temp;
       
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
       
    for (i = 0; i < 2; i = i + 1){
        for (j = i + 1; j < 3; j = j + 1){
            if (a[i] > a[j]){
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }
       
    printf("%d %d %d\n", a[0], a[1], a[2]);
       
    return 0;
}

Measured memory_bytes: 1776
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int n,tmp;
	vector <int> a;
	vector <int> ans;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >>tmp;
		a.push_back(tmp);
	}
	for(int j=-100;j<=100;j++){
		tmp =0;
		for(int k=0;k<a.size();k++){
			tmp+=(j-a[k])*(j-a[k]);
		}
		ans.push_back(tmp);
	}
	cout << *min_element(ans.begin(),ans.end()) <<endl;
	return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
dp = [False] * 100001
dp[0] = True
food = [100,101,102,103,104,105]
for i in range(1,100001):
    for j in range(len(food)):
        if i - food[j] >= 0:
            dp[i] |= dp[i - food[j]]
X = I()
print('1' if dp[X] else '0')


Measured memory_bytes: 10872
n = int(input())
ans = 10**9
for i in range(1,n//2+1):
    dum1 = n - i
    a = str(i)
    b = str(dum1)
    dum2 = 0
    for j in a:
        dum2 += int(j)
    for j in b:
        dum2 += int(j)
    ans = min(dum2,ans)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  if (A+B<2*C) {
    cout<<A*X+B*Y<<endl;
    return 0;
  }
  int q=(X>Y)? (X-Y)*min(A,2*C) : (Y-X)*min(B,2*C);
 cout<<min(X,Y)*(2*C)+q <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int rooms[120] = {0};

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++)
  {
    int b, f, r, v;
    std::cin >> b >> f >> r >> v;
    rooms[(b - 1) * 30 + (f - 1) * 10 + (r - 1)] += v;
  }
  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      std::cout << " " << rooms[i * 30 + j * 10]
                << " " << rooms[i * 30 + j * 10 + 1]
                << " " << rooms[i * 30 + j * 10 + 2]
                << " " << rooms[i * 30 + j * 10 + 3]
                << " " << rooms[i * 30 + j * 10 + 4]
                << " " << rooms[i * 30 + j * 10 + 5]
                << " " << rooms[i * 30 + j * 10 + 6]
                << " " << rooms[i * 30 + j * 10 + 7]
                << " " << rooms[i * 30 + j * 10 + 8]
                << " " << rooms[i * 30 + j * 10 + 9] << std::endl;
    }
    if (i != 3) std::cout << "####################" << std::endl;
  }
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if (x > y) {
    swap(a, b);
    swap(x, y);
  }
  int tot = min(2 * c, a + b) * x;
  y -= x;
  tot += min(c * 2, b) * y;
  cout << tot << '\n';
  return 0;
}

Measured memory_bytes: 256
import sys
from operator import mul
from functools import reduce
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

def com(n,r):
    r = min(n-r,r)
    if r == 0: return 1 
    return reduce(mul,range(n,n-r,-1))//reduce(mul,range(1,r+1))

n = int(readline())

if n < 3:
    print(0)
    sys.exit()

ans = 0
for i in range(1,n//3+1):
    num = n - i * 3
    ans += com(num+i-1,i-1)
    
print(ans%1000000007)

Measured memory_bytes: 74036
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;

int main() {
    ll N;
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


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

constexpr int MOD = 1e9 + 7;
struct mint {
  long long x;
  mint(long long x = 0) noexcept : x((x + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x -= a.x) < 0) x += MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (t == 0) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
};

vector<int> divisor(int N) {
  vector<int> res;
  for (long long i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      res.push_back(i);
      if (i * i != N) res.push_back(N / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main(){
  int N, K; cin >> N >> K;
  vector<mint> powN(K + 1);
  rep(i, K + 1) powN[i] = ((mint)i).pow(N);
  vector<mint> ans(K + 1);
  for (int i = K; i > 0; i--) {
    ans[i] = powN[K / i];
    for (int t = 2; t * i <= K; t++) ans[i] -= ans[t * i];
  }

  mint sum = 0;
  rep(i, K + 1) sum += ans[i] * i;

  cout << sum.x << endl;
}

Measured memory_bytes: 4840
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

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

	int INF=1<<28;
	double EPS=1e-12;

	int m, n=5;
	int[][] a;
	int[] score;

	void run(){
		for(;;){
			m=sc.nextInt();
			if(m==-1){
				break;
			}
			a=new int[n][n];
			for(int j=0; j<n; j++){
				for(int i=0; i<n; i++){
					a[j][i]=sc.nextInt()-1;
				}
			}
			score=new int[n];
			for(int i=0; i<n; i++){
				score[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		max=0;
		for(int j=0; j<n; j++){
			for(int i=0; i<n; i++){
				rec(i, j, 0);
			}
		}
		println(max+"");
	}

	int max;

	void rec(int x, int y, int depth){
		if(depth>m){
			return;
		}
		eval();
		int[] dx={0, 0, -1, 1};
		int[] dy={-1, 1, 0, 0};
		for(int i=0; i<4; i++){
			int x2=x+dx[i], y2=y+dy[i];
			if(x2>=0&&x2<n&&y2>=0&&y2<n){
				int t=a[y][x];
				a[y][x]=a[y2][x2];
				a[y2][x2]=t;
				rec(x2, y2, depth+1);
				t=a[y][x];
				a[y][x]=a[y2][x2];
				a[y2][x2]=t;
			}
		}
	}

	void eval(){
		int[][] b=new int[n][n];
		for(int j=0; j<n; j++){
			for(int i=0; i<n; i++){
				b[j][i]=a[j][i];
			}
		}
		int tot=0;
		for(int bonus=1;; bonus++){
			boolean[][] clear=new boolean[n][n];
			for(int y=0; y<n; y++){
				for(int x=0; x<n; x++){
					if(b[y][x]==-1){
						continue;
					}
					if(y+2<n&&b[y][x]==b[y+1][x]&&b[y+1][x]==b[y+2][x]){
						clear[y][x]=clear[y+1][x]=clear[y+2][x]=true;
					}
					if(x+2<n&&b[y][x]==b[y][x+1]&&b[y][x+1]==b[y][x+2]){
						clear[y][x]=clear[y][x+1]=clear[y][x+2]=true;
					}
				}
			}
			int block=0;
			boolean updated=false;
			for(int y=0; y<n; y++){
				for(int x=0; x<n; x++){
					if(clear[y][x]){
						block+=score[b[y][x]];
						b[y][x]=-1;
						updated=true;
					}
				}
			}
			for(int x=0; x<n; x++){
				for(int y=n-1; y>=0; y--){
					if(b[y][x]!=-1){
						for(int j=y+1; j<n&&b[j][x]==-1; j++){
							int t=b[j-1][x];
							b[j-1][x]=b[j][x];
							b[j][x]=t;
						}
					}
				}
			}
			tot+=block*bonus;
			if(!updated){
				break;
			}
		}
		max=max(max, tot);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 60720
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。
vector<pair<long long,long long>> prime_factorize(long long p); // 素因数分解

// class
// ------------------------------------------------
class Combi {
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    map<long long, map<long long, long long>> memo;
    long long n_num;
    long long k_num;
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(long long(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(long long(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    string t;
    cin >> t;

    rep(i,sz(t)){
        if(t[i] == '?') t[i] = 'D';
    }

    cout << t << endl;
    return 0;

}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
  int i = 1;
  while(1) {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n) {
  int s = 0;
  while(n) {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(97 <= *itr && *itr <= 122) {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(65 <= *itr && *itr <= 90) {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi() {
  n_num = -1;
  k_num = -1;
};

ll Combi::Combination(ll n, ll k) {

  ll ret;
  if(memo[n][k] != 0) {
    ret = memo[n][k];
  } else if(n == k || k == 0) {
    memo[n][k] = 1;
    ret = 1;
  } else {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

long long Combi::nPk_modp(long long n, long long k, long long p) {
  ll ans = 1;
  for(long long i = k; i <= n; i++) {
    ans = (ans * i) % p;
  }

  return ans;
};

vector<pair<long long,long long>> prime_factorize(long long p) {
    vector<pair<long long,long long>> ret;

    for(long long x = 2; x * x <= p; ++x) {
        if(p % x != 0) continue;
        long long num = 0;
        while(p % x == 0) {
            num++;
            p /= x;
        }
        ret.push_back(make_pair(x,num));
    }

    if(p != 1) ret.push_back(make_pair(p, 1));
    
    return ret;
}



Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename T> class Weighted_UnionFind
{
public:
    vector<int> par,sz;
    vector<T> wd;
    int V;
    Weighted_UnionFind(int node_size){
        V = node_size;
        par.resize(V),wd.resize(V,0),sz.resize(V,1);
        rep(i,V){
            par[i] = i;
        }
    }
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            int parent = find(par[x]);
            wd[x] += wd[par[x]];
            return par[x] = parent;
        }
    }
    T weight(int x){
        find(x);
        return wd[x];
    }
    void unite(int x,int y,T w){
        w += weight(x), w -= weight(y);
        x = find(x),y = find(y);
        if(x == y) return;
    	if(sz[x] < sz[y]){
            swap(x,y);
            w = -w;
        }
        sz[x] += sz[y];
        par[y] = x;
        wd[y] = w;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    T diff(int x,int y){
        return weight(y)-weight(x);
    }
};


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    Weighted_UnionFind<int> wu(n);
    rep(i,m){
        int l,r,d;
        cin >> l >> r >> d;
        --l,--r;
        if(wu.same(l,r)){
            if(wu.diff(l,r) != d){
                cout << "No\n";
                return 0;
            }
        }else{
            wu.unite(l,r,d);
        }
    }
    cout << "Yes\n";
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	int min,max,a;
	long long sum;
	cin >> a;
	min = max = sum = a;
	for(long long i = 0;i < n-1;i++){
		cin >> a;
		if(a <= min)min = a;
		else if(a >= max)max = a;
		sum += a;
	}
	cout << min << " " << max << " " << sum << endl;
	
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<vector<ll>> dp(110, vector<ll>(20,0)); 
  /*0:AA  1:AC  2:AG  3:AT
    4:CA  5:CC  6:CG  7:CT
    8:GA  9:GC  10:GG 11:GT
    12:TA 13:TC 14:TG 15:TT
  */
  rep(j,16){ dp[2][j]=1; }
  for(int i=2; i<n; i++){
    dp[i+1][0] = (dp[i][0]+dp[i][4]+dp[i][8]+dp[i][12])%mod; 
    dp[i+1][1] = (dp[i][0]+dp[i][4]+dp[i][12])%mod; 
    dp[i+1][2] = (dp[i][0]+dp[i][4]+dp[i][8]+dp[i][12])%mod; 
    dp[i+1][3] = (dp[i][0]+dp[i][4]+dp[i][8]+dp[i][12])%mod; 

    dp[i+1][4] = (dp[i][1]+dp[i][5]+dp[i][9]+dp[i][13])%mod; 
    dp[i+1][5] = (dp[i][1]+dp[i][5]+dp[i][9]+dp[i][13])%mod; 
    dp[i+1][6] = (dp[i][5]+dp[i][9]+dp[i][13])%mod; 
    dp[i+1][7] = (dp[i][1]+dp[i][5]+dp[i][9]+dp[i][13])%mod; 
    
    dp[i+1][8] = (dp[i][2]+dp[i][6]+dp[i][10]+dp[i][14])%mod; 
    dp[i+1][9] = (dp[i][6]+dp[i][10]+dp[i][14]              - dp[i-1][3]- dp[i-1][2])%mod; 
    dp[i+1][10] = (dp[i][2]+dp[i][6]+dp[i][10]+dp[i][14])%mod; 
    dp[i+1][11] = (dp[i][2]+dp[i][6]+dp[i][10]+dp[i][14])%mod; 
    
    dp[i+1][12] = (dp[i][3]+dp[i][7]+dp[i][11]+dp[i][15])%mod; 
    dp[i+1][13] = (dp[i][3]+dp[i][7]+dp[i][11]+dp[i][15] - dp[i-1][2])%mod; 
    dp[i+1][14] = (dp[i][3]+dp[i][7]+dp[i][11]+dp[i][15])%mod; 
    dp[i+1][15] = (dp[i][3]+dp[i][7]+dp[i][11]+dp[i][15])%mod; 
  }

  ll ans=0;
  rep(j,16){
    ans += dp[n][j];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    ll inner = 0;
    for (int i=0; i<n; i++) {
        for (int j=i; j<n; j++) {
            if (a[i] > a[j]) inner++;
        }
    }

    ll ans = inner * k % MOD;
    
    ll outer = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (a[i] > a[j]) outer++;
        }
    }
    ll x = k * (k-1) / 2 % MOD;
    ans += x * outer % MOD;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
N=int(input())
a=list((input().split()))
import sys
i=0
count=0
data= int(a[i])

while i<len(a):
    if data%2==0:
        data=data/2
        count+=1
    if data%2!=0:
        i+=1
        if i==len(a):
            print(count)
            sys.exit()
        data=int(a[i])

Measured memory_bytes: 3828
import java.io.*;
import java.util.*;

public class Main{
	static int ans;
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		try{
			while(true){
				int n=scan.nextInt();
				int s=scan.nextInt();
				if(n==0 && s==0){
					break;
				}
				ans=0;
				func(0,n,s);
				System.out.println(ans);
			}
		}catch(NumberFormatException e){
			System.out.println(e);
		}
	}
		
	private static void func(int min,int n,int s){
		//System.out.println("Env:"+min+" "+n+" "+s);
		if(s<min*n){
			return;
		}
		switch(n){
			case 1:
				if(s<10){
					ans+=1;
					//System.out.println("a");
				}
				break;
				/*
			case 2:
				while(min<s-min){
					min+=1;
					ans+=1;
					System.out.println("b");
				}
				break;
				*/
			default:
				for(int i=min;i<=s/n;i++){
					//System.out.println("loop:"+i);
					func(i+1,n-1,s-i);
					
					//System.out.println("Ans:"+ans);
				}
				break;
		}
	}
}

Measured memory_bytes: 26320
#include<iostream>
using namespace std;
 
 
int a[50], b[50], c[50], d[50], e[50];
int n, m, q;
int ret = 0;
 
void dfs(int pos, int val){
    if(pos == n){
        int tmp = 0;
        for(int i = 0; i < q; i++){
            tmp += d[i] * (e[b[i]]-e[a[i]] == c[i]);
        }
        ret = max(ret, tmp);
        return;
    }
    for(int i = val; i <= m; i++){
        e[pos] = i;
        dfs(pos+1, i);
    }
}
 
int main(){
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    dfs(0, 1);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3636
n=int(input())
s=[]
for i in range(n):
    s.append(int(input()))
t=sorted(s)
u=sum(s)
if u%10!=0:
    print(u)
    exit()
for i in range(n):
    v=u-t[i]
    if v %10!=0:
        print(v)
        exit()
print(0)

Measured memory_bytes: 3060
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

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

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


#line 2 "agc044_a.cpp"

ll d;
ll ary[3] = {2, 3, 5};
ll c[3] = {};

ll rec(ll cur, map<ll, ll> &mp) {
  auto itr = mp.find(cur);
  if (itr != mp.end()) {
    return itr->second;
  }
  ll ans = numeric_limits<ll>::max();

  REP(i, 3) {
    ll next, diff, cost;
    if (cur % ary[i] == 0) {
      next = cur / ary[i];
      diff = cur - next;
      cost = diff < (ll)2e9 / d ? min(c[i], d * diff) : c[i];
      chmin(ans, rec(next, mp) + cost);
      continue;
    }
    next = (cur - cur % ary[i]) / ary[i];
    diff = (cur - cur % ary[i]) - next;
    cost = (diff < (ll)2e9 / d ? min(c[i], d * diff) : c[i]) + (cur % ary[i]) * d;
    chmin(ans, rec(next, mp) + cost);

    next = (cur + ary[i] - cur % ary[i]) / ary[i];
    diff = (cur + ary[i] - cur % ary[i]) - next;
    cost = (diff < (ll)2e9 / d ? min(c[i], d * diff) : c[i]) + (ary[i] - (cur % ary[i])) * d;
    chmin(ans, rec(next, mp) + cost);
  }
  mp.insert({cur, ans});
  return mp[cur];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  REP(num, t) {
    ll n;
    cin >> n >> c[0] >> c[1] >> c[2] >> d;
    map<ll, ll> mp;
    mp.insert({0LL, 0LL});
    mp.insert({1LL, d});
    rec(n, mp);
    cout << mp[n] << endl;
  }

  return 0;
}


Measured memory_bytes: 4408
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF : usize = 1000000007;

#[fastout]
fn main() {
  input! {
    s: String,
    t: String,
  };

  let res = s.chars()
    .zip(t.chars())
    .filter(|&(i, j)| i != j )
    .count();
  
  println!("{}", res);
}

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

int main(){
 int N;
 cin >> N;
 vector<int> A(N);
 vector<int> B(N);
 vector<int> C(N-1);
  for(int i =0;i<N;i++){
    cin >> A[i];
  }
  for(int i =0;i<N;i++){
    cin >> B[i];
  }
  for(int i =0;i<N-1;i++){
    cin >> C[i];
  }
  vector<int> newB(N);
  for(int i =0;i<N;i++){
    newB[i] = B[A[i]-1];
  }

  int ans = 0;
  for(int i =0;i<N;i++){
    ans += newB[i];
    if(A[i+1]-A[i] == 1) ans += C[A[i]-1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int n,m,l;
    int i,j,k;
    double a[100][100]={0};
    double b[100][100]={0};
    double c[100][100]={0};
    
    scanf(" %d %d %d",&n,&m,&l);
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%lf",&a[i][j]);
        }
    }
    for(j=0;j<m;j++){
        for(k=0;k<l;k++){
            scanf("%lf",&b[j][k]);
        }
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            printf("%.0f",c[i][j]);
            if(j!=l-1){
                printf(" ");
            }else{
                printf("\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 904