akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
ds = gets.split.map(&:to_i)
ans = 0
ds.each_with_index do |d1, index1|
  ds.each_with_index do |d2, index2|
    if index1 != index2
      ans += d1 * d2
    end
  end
end
puts ans / 2

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == 5 and b == 7 and c == 5){
    cout << "YES" << endl;
  }
  else if (a == 7 and b == 5 and c == 5){
    cout << "YES" << endl;
  }
  else if (a == 5 and b == 5 and c == 7){
    cout << "YES" << endl;
  }
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endlhttps:  // stopwatch.onl.jp/#
#endif
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  cout << max(a+b,max(a-b,a*b));
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

Measured memory_bytes: 256
n = int(input())
A = [int(input()) for i in range(n)]
dict_a = {}
for a in A:
  dict_a.setdefault(a, 0)
  if dict_a[a] == 1:
    dict_a.pop(a)
  else:
    dict_a[a] += 1
print(len(dict_a))

Measured memory_bytes: 16268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

ll d[10][10];

int main(){
    int h,w;
    cin>>h>>w;
    rep(i,10){
        rep(j,10){
            cin>>d[i][j];
        }
    }

    rep(k,10){
        rep(i,10){
            rep(j,10){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

    ll ans=0;
    rep(i,h){
        rep(j,w){
            int a;
            cin>>a;
            if(a==-1) continue;
            ans+=d[a][1];
        }
    }

    cout<<ans<<endl;
}

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

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

  int cnt = 0;
  int sum;

  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        sum = 500*i+100*j+50*k;
        if(sum == x) cnt++;
      }
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,C=0,n,q;
  int S[10000],T[10000];

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++) scanf("%d",&T[i]);

  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      if(S[j] == T[i]){
	C += 1;
	break;
      }
    }
  }
  printf("%d\n",C);
}



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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    cout << N*N*N << endl;
}

Measured memory_bytes: 3608
use std::io;
use std::str::FromStr;

fn input_tuple() -> (i64, i64, i64, i64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2], vec[3])
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, m, x, y) = input_tuple();
    let mut x_vec = input_vec();
    let mut y_vec = input_vec();
    x_vec.sort();
    y_vec.sort();
    if x_vec[n as usize - 1] < y_vec[0] {
        for z in (x_vec[n as usize - 1] + 1)..(y_vec[0]+1) {
            if x < z && z <= y {
                println!("No War");
                return
            }
        }
    }
    println!("War");
}


Measured memory_bytes: 2160
//貪欲法(嘘解法かも…)
#include<iostream>
using namespace std;

int corn1,corn2;
bool flag;

int main(){
	int n,i,j;
	int t;
	
	cin >> n;
	for( i = 0;i < n;i++ ){
		corn1 = 0;
		corn2 = 0;
		flag = true;
		for( j = 0;j < 10;j++ ){
			cin >> t;
			
			if( corn1 < t )
				corn1 = t;
			else if( corn2 < t )
				corn2 = t;
			else
				flag = false;
		}
		if( flag )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
fun main(args: Array<String>) {
    abc081b()
}

fun abc081b() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toLong() }

    val answer = aList.map { a ->
        var curr = a
        var cnt = 0
        while (curr % 2 == 0L && curr > 0) {
            curr /= 2
            cnt++
        }
        cnt
    }.min()

    println(answer)
}


Measured memory_bytes: 37820
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main()
{
	double n;
	int area;
	while (cin >> n)
	{
		area = (pow(n,2.0) + n + 2) / 2;		//area = 1 + n(1+n)/2
		cout << area << endl;
	}
	return 0;
}

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

#define ll long long

using namespace std;

int a[100500];

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k,q,x;
    cin >> n >> k >> q;
    for(int i = 1; i <= n; i++)
    {
        a[i] = k;
    }
    for(int i = 1; i <= q; i++)
    {
        cin >> x;
        a[x]++;
    }
    for(int i = 1; i <= n; i++)
    {
        if(a[i] - q > 0)
        {
            cout << "Yes\n";
        } else
            {
                cout << "No\n";
            }
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <stack>
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

/*Xを前から見ていって、Sの１個以上の連続箇所があれば、それ以降の部分で
Tが何個連続しているかを見る
各連続箇所で、連続回数の少ない方*2をカウント
*/
int main(){
  string x;
  cin >> x;
  int n=x.size();
  stack<char> s;
  for(int i=0;i<n;++i){
    if(x[i]=='S'){
      s.push(x[i]);
    }
    else if(x[i]=='T'){
      if(s.empty()){
        s.push(x[i]);
      }else if(s.top()=='S'){
        s.pop();
      }else if(s.top()=='T'){
        s.push(x[i]);
      }
    }
  }
 
  cout << s.size() << endl;

}


Measured memory_bytes: 644
#include <stdio.h>
int main(void){
    // Your code here!
    int N,M,i,j,ans=0;
    scanf("%d%d",&N,&M);
    int a[N];
    for(i=0;i<N;i++) scanf("%d",&a[i]);
    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            if(a[i]<a[j]){
                int tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    for(i=0;i<M;i++){
        ans+=a[i];
    }
    printf("%d",ans);
}


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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 2e5, MOD = 998244353, SIZE = 2e7, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n;
char a[] = "abcdefghijklmnopqrstuvwxyz";
deque<char> s;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(n)
    while(n)
        --n, s.push_front(a[n % 26]), n /= 26;
	FORALL(c, s)
        cout << c;
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 3660
# -*- coding: utf-8 -*-


def get_input() -> str:
    """
    標準入力の取得.

    Returns:\n
        str: 標準入力
    """
    S = input()

    return S


def main(S: str) -> None:
    """
    求解処理.

    Args:
        S (str): 管理状況
    """
    result = str()
    if S == "AAA" or S == "BBB":
        result = "No"
    else:
        result = "Yes"

    # 結果出力
    print(result)


if __name__ == "__main__":
    S = get_input()
    main(S)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
const int MAXN = 1e6 + 50;
int a[MAXN];
int cnt[MAXN];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n;i++)
        cin >> a[i];
    int t = 0;
    for (int i = 0; i < n;i++){
        t = __gcd(t, a[i]);
        ++cnt[a[i]];
    }
    if(t>1){
        cout << "not coprime";
        return 0;
    }

    for (int i = 2; i < MAXN;i++){        //1e6以内质数不到8w个，故这种暴力找倍数的方式没炸
        int num = 0;
        for (int j = i; j < MAXN;j+=i)
            num += cnt[j];
        if(num>1){
            cout << "setwise coprime";
            return 0;
        }
    }
    cout << "pairwise coprime";

    return 0;
}


Measured memory_bytes: 11432
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    string s;
    cin>>s;
    const int n = (s.size() + 1) / 2;
    char cs[n];
    int j = 0;
    for (int i=0; i<s.size(); i+=2) {
        cs[j++] = s[i];
    }
    cs[j] = '\0';
    cout<<cs<<endl;
    return 0;
}


Measured memory_bytes: 576
#include<bits/stdc++.h>
using namespace std;
long long a[100005],n,m,v,p,sum;
bool cmp(long long x,long long y){
    return x>y;
}
bool check(long long x){
    long long val=a[x]+m,num=0;
    if(val<a[p]) return false;
    for(int i=1;i<=x;i++){
        if(a[i]<val){
            num+=val-a[i];
        }
    }
    for(int i=1;i<p;i++){
        if(a[i]>=val) num+=m;
        else num+=a[i]+m-val;
    }
    return num+(n-x)*m>=sum;
}
int main(){
    cin>>n>>m>>v>>p;
    sum=v*m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n,cmp);
    long long l=p,r=n;
    while(r>=l){
        long long mid=(l+r)/2;
        if(check(mid)) l=mid+1;
        else r=mid-1;
    }
    cout<<l-1<<endl;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define INF 20000000000000
#define PI 3.14159265359
#define ull unsigned long long
#define MYPOW_t int

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a*b);
    return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x,i,j,k,cnt=0;
    cin>>a>>b>>c>>x;
    for (i=0;i<=a&&500*i<=x;i++)
        for (j=0;j<=b&&100*j+500*i<=x;j++)
            for (k=0;k<=c&&50*k+100*j+500*i<=x;k++)
                if (500*i+100*j+50*k==x)
                    cnt++;
	cout<<cnt;
}

Measured memory_bytes: 256
N = int(input())
h = input().rstrip().split(' ')
h.insert(0,0)
h = list(map(int,h))

#ここで保存しておく
l = [-1]*(N-1)
l.insert(0,0)
l.insert(0,0)

def cost_min(n):
    #n番目までで最小のコストを考える
    if(l[n] != -1):
        return l[n]
    else:
        l[n] = min([cost_min(n-1) + abs(h[n]-h[n-1]),cost_min(n-2) + abs(h[n]-h[n-2])])
        return l[n]

def cost_min_bottomup(n):
    if(n<2):
        return 0
    t_0 = 0
    t_1 = abs(h[2] - h[1])
    ans_0 = 0
    ans_1 = t_1
    for i in range(n-2):
        t_0 = ans_0 + abs(h[i+3]-h[i+1])
        t_1 = ans_1 + abs(h[i+3]-h[i+2])
        ans_0 = ans_1
        ans_1 = min([t_0,t_1])
    return ans_1

#print(cost_min(N))
print(cost_min_bottomup(N))

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

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

int main() {
    int x; cin >> x;
    cout << (x == 7 || x == 5 || x == 3 ? "YES" : "NO") << endl;
    return 0;
}


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

bool oddDigit(int i){
    int count = 1;
    while(i>=10){
        i /= 10;
        count++;
    }
    return count%2==1;
}

void solve(){
    int n;
    cin >> n;
    int count = 0;
    for(int i=n; i>=1; i--){
        if(oddDigit(i)) count++;
    }
    cout << count << endl;
}

int main(){
  solve();
  return 0;
}


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

#define pb push_back
#define mp make_pair
#define ll long long
#define inf 10e8

using namespace std;

int inDegree[100005];
bool visited[100005];
int dp[100005];

void init(int *a, int size){
	for (int i = 0; i <= size; ++i)
	{
		a[i] = 0;
	}
}

void init(bool *a, int size){
	for (int i = 0; i <= size; ++i)
	{
		a[i] = false;
	}
}

void maxdp(vector<int>* g, int inDegreeSize){
	queue<int> q;
	for (int i = 1; i <= inDegreeSize; ++i)
	{
		if(!visited[i] && inDegree[i] ==0){
			q.push(i);
		}
	}

	while(!q.empty()){
		int t =q.front();
		q.pop();
		for(auto s : g[t]){
			if(!visited[s]){
				if(dp[s] < dp[t] +1){
					dp[s]  = dp[t]+1;
				}
				inDegree[s]--;
				if(!inDegree[s]){
					q.push(s);
					visited[s] =0;
				}
			}
		}
	}
	// int nax = -01;
	// for (int i = 1; i <= inDegreeSize; ++i)
	// {
	// 	nax = max(dp[i], nax);
	// }
	// printf("%d\n", nax);
}

void dfs(vector<int> *g, int a){
	visited[a] = true;
	// vector<int>::iterator it;
	// for(it = g[a].begin(); it !=g[a].end(); it++){
	for (int i = 0; i < g[a].size(); ++i){
		inDegree[g[a][i]]--;
		dp[g[a][i]] = max(dp[g[a][i]], 1+dp[a]);
		if (inDegree[g[a][i]] == 0)
		{
			dfs(g, g[a][i]);
		}
	}
}

void addEdge(vector<int> adj[], int start, int end/*, int wt*/){
	// printf("pusing start %d in end %d\n", start, end);
	adj[start].pb(end);
	inDegree[end]++;
	// adj[end].pb(start);
}

void printGraph(vector<int> g[], int nodes){
	printf("nodes \n");
	for (int i = 0; i <= nodes; ++i)
	{
		for (int j = 0; j < g[i].size(); ++j)
		{
			printf("%d, %d \n",i, g[i][j]);
		}
	}
}

void takeEntry(vector<int>*g/*, int nodes*/){
	int start, end;
	scanf("%d%d", &start, &end);
	addEdge(g, start, end);
	// printGraph(g, nodes);
}

// EDIT INPUT IN graphInput.txt

int main(int argc, char const *argv[])
{
	int nodes, edges,  wt;
	
	cin>>nodes>>edges;


	init(inDegree, nodes+1);
	init(dp,  nodes+1);
	init(visited,  nodes+1);

	vector<int> g[nodes+1];

	// vector<pair<int, int> >	adj[nodes+1];
	
	for (int i = 0; i < edges; ++i)
	{
		takeEntry(g /*, nodes*/);
	}

	// printGraph(g, nodes);

	// for (int i = 1; i <= nodes; ++i){
	// 	if (!visited[i] && inDegree[i] ==0){
	// 		dfs(g, i);
	// 	}		
	// }	
	// printf("entry done\n");
	int nax = -1;
	maxdp(g, nodes);
	for (int i = 1; i <= nodes; ++i)
	{
		if (dp[i] > nax)
		{
			nax = dp[i];
		}
	}
	printf("%d\n", nax);
	return 0;
}




Measured memory_bytes: 6656
program ABC_064_A_RGBCards
   implicit none
   integer r, g, b
   read(*, *) r, g, b
   if(mod(r*100+g*10+b,4) == 0) then
       write(*, *) 'YES'
   else
       write(*, *) 'NO'
   end if
end program ABC_064_A_RGBCards

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> l(n+1),r(n+1);
    for(int i=1; i<=n-1; i++){
        if(s[i-1]=='W') l[i] = l[i-1]+1;
        else l[i] = l[i-1];
    }
    for(int i=n; i>=1; --i){
        if(s[i-1]=='E') r[n-i+1] = r[n-i]+1;
        else r[n-i+1] = r[n-i]; 
    }
    int ans = 1e9;
    for(int i=0; i<=n-1; i++){
        ans = min(ans,l[i]+r[n-i-1]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main (){
    int k ,a , b;
    cin >> k;
    cin >> a;
    cin >> b;
    //cout << "k " << k << " a " << a << " b " << b << endl;
    int start = a/k;
    int end = b/k + 1;
    for(int i = start; i <= end; i++){
        if(((i*k)>=a)&&((i*k)<=b)){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := readint()
	P := make([]int, N)
	minv := 2*pow(10, 5) + 1
	ans := 0
	for i := 0; i < N; i++ {
		P[i] = readint()
		if P[i] <= minv {
			minv = P[i]
			ans++
		}
	}
	fmt.Println(ans)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  double n,t,a;
  cin >> n >> t >> a;
  double h[(int)n];
  for(ll i=0;i<n;i++)cin >> h[i];
  double m=inf;
  ll ans;
  for(ll i=0;i<n;i++){
    if(abs(a-(t-h[i]*6/1000))<m){
      ans=i;
      m=abs(a-(t-h[i]*6/1000));
    }
  }

  cout << ans+1 << endl;

}

Measured memory_bytes: 3784
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll N,A[100007];

int main(){
    ll A,B,C,X,Y,N,M;
    string S,T;
    cin >> A;
    cout << A*A << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
ps = n.times.map { gets.chomp.to_i }

max = 0
max_i = -1
ps.each.with_index do |p, i|
  if max < p
    max = p
    max_i = i
  end
end

total = max / 2
ps.each.with_index do |p, i|
  next if i == max_i
  total += p
end

p total


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

sys.setrecursionlimit(100000)

N, M = (int(i) for i in input().split())
L = []
for i in range(M):
    a, b = (int(j) for j in input().split())
    L.append((a-1, b-1))
L.reverse()

uf = [-1]*N
def parent(v):
    if uf[v] < 0:
        return v
    else:
        uf[v] = parent(uf[v])
        return uf[v]

res = [0]*M
ans = (N*(N-1))//2
res[0] = ans

for i in range(1, M):
    a, b = L[i-1]
    pa = parent(a)
    pb = parent(b)
    if pa != pb:
        sa = -uf[pa]
        sb = -uf[pb]
        ans -= sa * sb
        uf[pb] = pa
        uf[pa] = -(sa + sb)
    res[i] = ans

res.reverse()
for i in range(M):
    print(res[i])

Measured memory_bytes: 34448
import javax.sound.midi.Soundbank;
import java.util.*;
import java.lang.*;

public class Main
{
    static boolean isThere(int[] a, int x)
    {
        for(int i=0; i<a.length; i++)
        {
            if(a[i]==x)
                return true;
        }
        return false;
    }
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a = 0, w = 0, t = 0, r = 0;
        for(int i=0; i<n; i++)
        {
            String x = s.next();
            if(x.equals("AC"))
                a++;
            else if(x.equals("WA"))
                w++;
            else if(x.equals("TLE"))
                t++;
            else if(x.equals("RE"))
                r++;
        }
        System.out.println("AC x "+a);
        System.out.println("WA x "+w);
        System.out.println("TLE x "+t);
        System.out.println("RE x "+r);
    }
}


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

int main() {
	int n;
	cin >> n;
	vector<int> num(n, 0);
	int sum = 0;
	int all_10 = 1;
	int min_ = INT32_MAX;
	for (int i = 0; i < n; i++) {
		cin >> num[i];
		sum += num[i];
		if (num[i] % 10 != 0) {
			all_10 = 0;
			min_ = min(min_, num[i]);
		}
	}
	if (sum % 10 != 0) cout << sum << endl;
	else if (all_10) cout << 0 << endl;
	else cout << sum - min_ << endl;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

po = 0

po += n//500 * 1000

n %= 500

po += n//5 * 5

print(po)





Measured memory_bytes: 38384
a=input()
n=len(a)

for i in range(1<<n):
    sum=0
    st=''
    for j in range(n):

        # if i & (1 <<j):sum +=int(a[j]); st+= '+' + a[j] 
        # else: sum -=int(a[j]); st+= '-' + a[j]
        if i & (1 <<j):st+= '+' + a[j] 
        else:  st+= '-' + a[j]

    # if sum==7:break
    if eval(st[1:]) == 7:break

print(st[1:] + '=7')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  string s, t;
  cin >> s >> t;
  int n = 2 * a;
  rep(i, 0, n){
    if(i % 2 == 0){
      cout << s[i / 2];
    }
    else{
      cout << t[i / 2];
    }
  }
  cout << "\n";
}


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

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
using ll = long long;

const int maxn = 1e5 + 10; 
const int INF = 0x3f3f3f3f;

int n,m,k;
vector<int>f[maxn],b[maxn];
int vis[maxn],cnt[maxn],ans[maxn];

void dfs(int u,int bz)
{
	vis[u] = bz;
	cnt[bz]++;

	for(int i = 0; i < f[u].size(); ++i){
		int v = f[u][i];
		if(!vis[v]) dfs(v,bz);
	}
}

int main()
{
	fastIO;
	cin >> n >> m >> k;
	for(int i = 0; i < m; ++i) {
		int u,v;
		cin >> u >> v;
		f[u].push_back(v);
		f[v].push_back(u);
	}		
	for(int i = 0; i < k; ++i) {
		int u,v;
		cin >> u >> v;
		b[u].push_back(v);
		b[v].push_back(u);
	}	
	int cntt = 0;
	for(int i = 1; i <= n; ++i) {
		if(!vis[i]) {
			dfs(i,++cntt);
		}
	}
	for(int i = 1; i <= n; ++i) {
		int num = cnt[vis[i]];
		ans[i] = num - 1;
		for(int j = 0; j < f[i].size(); ++j) {
			int v = f[i][j];
			if(vis[v] == vis[i]) ans[i]--;
		}
		for(int j = 0; j < b[i].size(); ++j) {
			int v = b[i][j];
			if(vis[v] == vis[i]) ans[i]--;
		}
	}
	for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
	return 0;
}

Measured memory_bytes: 13184
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];

    for(int i = 0; i < N; i++){
      a[i]= sc.nextInt();
    }

    sortDesc(a);

    int pointA = 0;
    int pointB = 0;

    for(int j = 0; j < N; j++){
      if(j % 2 == 0){
        pointA += a[j];
      }else{
        pointB += a[j];
      }
    }

    int ans = pointA - pointB;
    System.out.println(ans);

  }

  private static void sortDesc(int[] nums) {

        Arrays.sort(nums);

        int[] numsTemp = new int[nums.length];

        for (int i = 0; i < nums.length; i++) {
            numsTemp[i] = nums[nums.length - 1 - i];
        }

        for (int i = 0; i < nums.length; i++) {
            nums[i] = numsTemp[i];
        }

    }
}

Measured memory_bytes: 21460
N = int(input())

c10 = 10
c9 = 2*9
c8 = 8

BIG_M = 10**9+7

for i in range(N-1):
    c10 = (c10*10)%BIG_M
    c9 = (c9*9)%BIG_M
    c8 = (c8*8)%BIG_M
    
print((c10 - c9 + c8)%BIG_M)

Measured memory_bytes: 9184
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, y, ans[3] = {};

	cin >> n >> y;

	if (n * 10000 < y) {
		cout << "-1 -1 -1" << endl;
		return 0;
	}

	ans[2] = y / 1000;
	while(ans[0] + ans[1] + ans[2] - 4 >= n && ans[2] >= 5) {
		ans[2] -= 5;
		ans[1]++;
	}

	while (ans[0] + ans[1] + ans[2] - 1 >= n && ans[1] >= 2) {
		ans[1] -= 2;
		ans[0]++;
	}

	if (ans[0] + ans[1] + ans[2] == n) {
		cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
	}
	else {
		cout << "-1 -1 -1" << endl;
	}
}

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

int main()
{
    int Q, N, index, flag, posl, posr;
    int prime[100005];
    int sum[100005];
    int l[100005], r[100005];
    cin >> Q;
    REP(i, Q)
        cin >> l[i] >> r[i];
    N = 100000;
    prime[0] = 2;
    prime[1] = 3;
    index = 2;
    for(int i=4;i<=N;i++){
        flag = 0;
        for(int j=2;j<=(int)sqrt(i);j++){
            if(i%j == 0){
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            prime[index] = i;
            index++;
        }
    }
    sum[0] = 0;
    REP(i, index){
        if(binary_search(prime, prime+index, (prime[i]+1)/2))
            sum[i+1] = sum[i] + 1;
        else
            sum[i+1] = sum[i];
    }
    REP(i, Q){
        posl = (int)(lower_bound(prime, prime+index, l[i]) - prime);
        posr = (int)(upper_bound(prime, prime+index, r[i]) - prime);
        cout << sum[posr-1+1] - sum[posl-1+1] << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 1536
def main():
    N=int(input())
    a=list(map(int,input().strip().split()))
    
    a.sort(reverse=True)
    
    alice=sum(a[n] for n in range(N) if n%2==0)
    bob=sum(a[n] for n in range(N) if n%2==1)
    return alice-bob

if __name__=="__main__":
    print(main())

Measured memory_bytes: 3060
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    long long x, y;
    cin >> x >> y;

    long long cnt = 0;
    while (x <= y) {
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    ll n,t=0;
	cin>>n;
	vector<char>v(n);
	rep(i,n){
		cin>>v[i];
		if(v[i]=='R')
			t++;
	}
	i = 0 ;
	j = 0 ;
	ll cnt = 0 ;
	rep(i,t)
		if(v[i]=='W')
			cnt++;

	cout<<cnt;	


}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3588
N = int(input())
A = list(map(int, input().split()))

from collections import defaultdict
cnts = defaultdict(int)
for a in A:
    if a != 0:
        cnts[a-1] += 1
    cnts[a] += 1
    cnts[a+1] += 1

print(max(cnts.values()))


Measured memory_bytes: 19900
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

vector<vector<int>> card(3, vector<int>(3));
int n;

void mark(int x){
    rep(i, 0, 3) rep(j, 0, 3) if(card[i][j] == x) card[i][j] = INF;
}

int main(){
    rep(i, 0, 3) rep(j, 0, 3) cin >> card[i][j];
    cin >> n;
    rep(_, 0, n){
        int t; cin >> t;
        mark(t);
    }

    rep(i, 0, 3){
        int suc = 0;
        rep(j, 0, 3) if(card[i][j] == INF) suc++;
        if(suc >= 3) {
            cout << "Yes" << el;
            return 0;
        }
    }

    rep(j, 0, 3){
        int suc = 0;
        rep(i, 0, 3) if(card[i][j] == INF) suc++;
        if(suc >= 3) {
            cout << "Yes" << el;
            return 0;
        }
    }

    if(card[0][0] == INF && card[1][1] == INF && card[2][2] == INF){
        cout << "Yes" << el;
        return 0;
    }
    if(card[0][2] == INF && card[1][1] == INF && card[2][0] == INF){
        cout << "Yes" << el;
        return 0;
    }

    cout << "No" << el;

    return 0;
}


Measured memory_bytes: 3092
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	int A[200000];
	int B[200000] = { 0 };
	for (int i = 0;i < N-1;i++) {
		cin >> A[i];
	}
	for (int i = 0;i < N-1;i++) {
		B[A[i] - 1]++;
	}
	for (int i = 0;i < N;i++) {
		cout << B[i] << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  double ans = 0.0, num;
  for (int i = 0; i < N; i++) {
    cin >> num;
    ans += 1.0 / num;
  }
  cout << fixed << setprecision(10);
  cout << 1.0 / ans << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  int a, b, c, k ;
  cin >> a >> b >> c >> k ;
  int d = max({a,b,c}) ;
  int tmp = d ;
  int ans ;
  
  REP(i,k){
    d = d*2 ;
  }
  ans = a+b+c+d-tmp ;
  
  cout << ans <<endl;
  

  return 0 ;
}


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

int main() {
int X,Y;
  cin >> X >> Y;
  int result = 1;
  if(Y < 2 * X||Y > 4 * X||(Y - (2 * X)) % 2 == 1||(4 * X - Y) % 2 == 1){
    result = 0;
  }
if(result == 0)cout << "No" << endl;
  if(result == 1)cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   	int a;
   	while(1){
	cin >> a;
	if (a == 0) break;
	
	vector<int> v(a);
	for (int i = 0; i < a; i++) cin >> v[i];
	sort(all(v));
	int sum = 0;
	for (int i = 1; i < a - 1; i++) sum += v[i];
	cout << sum / (a - 2) << endl;	
  }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}




Measured memory_bytes: 3048
//
//  abc169_a.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll INF = 1000000007;
#define PI 3.14159265


int main() {
  int a, b;
  std::cin >> a >> b;
  std::cout << a*b << std::endl;

  return 0;
}

Measured memory_bytes: 3620
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;
const int MAX = 510000;
const int MOD = 1000000007;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int d[401][401];
int N, M;
int i, j;
char S[401][401];
ll bfs(int sx, int sy) {
	if (d[sx][sy] == 0) {
		return 0;
	}
	queue<P> que;
	que.push(P(sx, sy));
  d[sx][sy]=0;
	ll white = 0;
	ll black = 0;
	ll ans = 0;
	while (que.size()) {
		P p = que.front();
		que.pop();
      
      if (S[p.first][p.second] == '#') {
					black++;
				}
				else {
					white++;
				}
		REP(i, 0, 4) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx && nx < N && 0 <= ny && ny < M&&d[nx][ny] == MOD && S[nx][ny] != S[p.first][p.second]) {
				que.push(P(nx, ny));
				d[nx][ny] = 0;
			}
		}
	}
	ans = black * white;
	return ans;

}

int main()
{

	ll k, l, m, flag, K, H, W, X, P, B, C;
	cin >> N >> M;

	REP(i, 0, N) {
			cin >> S[i];
	}
	REP(i, 0, N) {
		REP(j, 0, M) {
			d[i][j] = MOD;
		}
	}
	ll finans;
	finans = 0;
	int tempi;
	int tempj;
	for (k = 0; k<N; k++) {
		REP(j, 0, M) {
			tempi = k;
			tempj = j;
			finans+=bfs(k,j);
			k = tempi;
			j = tempj;
		}
	}
	output(finans);
	return 0;
}









Measured memory_bytes: 1024
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

// SCC Strongly Connected Component 強連結成分分解
struct SCC {
	typedef vector<vector<int>> graph;

	int V;
	int cV;
	graph G;
	graph cG;
	vector<int> cmp;
	vector<int> vs;
	vector<bool> used;

	SCC(int V_):V(V_), G(V_), cmp(V_), used(V_) {}
	SCC(const graph &G_):V(G_.size()), G(G_), cmp(V), used(V) {}

	void add_edge(int from, int to) {
		G[from].emplace_back(to);
	}

	void dfs(int v) {
		used[v] = true;
		for(const auto &to : G[v]) {
			if(!used[to]) dfs(to);
		}
		vs.emplace_back(v);
	}

	void rdfs(int v, int k, graph &rG) {
		used[v] = true;
		cmp[v] = k;
		for(const auto &to : rG[v]) {
			if(!used[to]) rdfs(to, k, rG);
		}
	}

	int scc() {
		vs.clear();
		fill(used.begin(), used.end(), false);

		for(int v = 0; v < V; ++v) {
			if(!used[v]) dfs(v);
		}

		graph rG(V);
		for(int v = 0; v < V; ++v) {
			for(const auto &to : G[v]) {
				rG[to].emplace_back(v);
			}
		}

		fill(used.begin(), used.end(), false);
		int k = 0;
		for(int i = static_cast<int>(vs.size()) - 1; i >= 0; --i) {
			if(!used[vs[i]]) rdfs(vs[i], k++, rG);
		}
		return k;
	}

	void construct() {
		cV = scc();
		cG.clear();
		cG.resize(cV);

		for(int v = 0; v < V; ++v) {
			for(const auto &to : G[v]) {
				if(cmp[v] != cmp[to]) cG[cmp[v]].emplace_back(cmp[to]);
			}
		}

		for(auto &es : cG) {
			sort(es.begin(), es.end());
			es.erase(unique(es.begin(), es.end()), es.end());
		}
	}
};

typedef int weight;
constexpr weight INF = (1 << 28);

struct edge {
	int to;
	weight cost;
	edge(int to_, weight cost_):to(to_), cost(cost_){}
};

typedef vector<vector<edge>> weighted_graph;

weight minimum_spanning_arborescence(int r, const weighted_graph &G, weight sum = 0) {
	const int n = G.size();

	vector<int> rev(n, -1);
	vector<weight> minimum_weight(n, INF);
	for(int v = 0; v < n; ++v) {
		for(const auto &e : G[v]) {
			if(minimum_weight[e.to] > e.cost) {
				minimum_weight[e.to] = e.cost;
				rev[e.to] = v;
			}
		}
	}

	SCC scc(n);
	for(int v = 0; v < n; ++v) {
		if(v == r) continue;
		if(rev[v] == -1) return INF;
		scc.add_edge(rev[v], v);
		sum += minimum_weight[v];
	}

	const int num = scc.scc();
	if(num == n) return sum;

	weighted_graph next_G(num);
	for(int v = 0; v < n; ++v) {
		const int from = scc.cmp[v];
		for(const auto &e : G[v]) {
			const int to = scc.cmp[e.to];
			if(from == to) continue;

			const int cost = e.cost - minimum_weight[e.to];
			next_G[from].emplace_back(to, cost);
		}
	}

	return minimum_spanning_arborescence(scc.cmp[r], next_G, sum);
}

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

	int n, m, r;
	cin >> n >> m >> r;

	weighted_graph G(n);
	for(int i = 0; i < m; ++i) {
		int from, to, cost;
		cin >> from >> to >> cost;
		G[from].emplace_back(to, cost);
	}

	cout << minimum_spanning_arborescence(r, G) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1692
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char S1[] = S.toCharArray();
		int max_count = 0;
		int count = 0;
		for(int i = 0; i<S.length(); i++) {
			if(S1[i] == 'A' || S1[i] == 'C' ||S1[i] == 'G' ||S1[i] == 'T') {
				count++;
			}
			else {
				count = 0;
			}
			if(count > max_count) {
				max_count = count;
				
			}
			
		}
		System.out.println(max_count);
		
		
		
    }

}

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

int main()
{
	int x,y,ans=0;
	cin>>x>>y;
	if(x>y) ans+=x,x--;
	else ans+=y,y--;
	if(x>y) ans+=x,x--;
	else ans+=y,y--;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int P   =1e9+7;
const int INF =2147483647;
int qread(){
	int w=1,c,ret;
	while((c=getchar())> '9'||c< '0')
	w=(c=='-'?-1:1); ret=c-'0';
	while((c=getchar())>='0'&&c<='9')
	ret=ret*10+c-'0';
	return ret*w;
}
const int MAXN =1e5+3;
int n,tot,head[MAXN],nxt[MAXN*2],ver[MAXN*2];
void add(int u,int v){
	ver[++tot]=v,nxt[tot]=head[u],head[u]=tot;
}
int F[MAXN],G[MAXN],fa[MAXN];
bool lf[MAXN];
void init(int u){
	for(int i=head[u];i;i=nxt[i]){
		if(!fa[ver[i]]) lf[u]=false,fa[ver[i]]=u,init(ver[i]);
	}
}
int f(int u);	//将u涂黑 
int g(int u);	//不将u涂黑 
int f(int u){
	if(F[u]!=-1) return F[u]; else F[u]=1;
	for(int i=head[u];i;i=nxt[i])
	if(ver[i]!=fa[u])F[u]=((LL)F[u]*g(ver[i]))%P;
	return F[u];
}
int g(int u){
	if(G[u]!=-1) return G[u]; else G[u]=1;
	for(int i=head[u];i;i=nxt[i])
	if(ver[i]!=fa[u])G[u]=((LL)G[u]*((LL)f(ver[i])+g(ver[i]))%P);
	return G[u];
}
int main(){
	n=qread(),memset(lf,true,sizeof(lf));
	up(1,n,i) F[i]=G[i]=-1;
	up(1,n-1,i){
		int u=qread(),v=qread();
		add(u,v),add(v,u);
	}
	fa[1]=1,init(1);
	printf("%d\n",((LL)f(1)+g(1))%P);
	return 0;
}


Measured memory_bytes: 7680
n=int(input())
a=[]
for i in range(n):
    b,c=input().split()
    c=int(c)
    a.append([b,c])
sa=sorted(a)
sa.append(["STOP"])
ssa=[]
ssaa=[]
while len(sa)>1:
    while True:
        ssa.append(sa[0])
        sa=sa[1:]
        if ssa[-1][0]!=sa[0][0] or sa[0]=="STOP":
            break
    ssa=ssa[::-1]
    for i in ssa:
        ssaa.append(i)
    ssa=[]
for i in ssaa:
    print(a.index(i)+1)

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

const int bB = 7;
const int B = 1 << bB;

int up(int x) {
	return (x + (1 << bB) - 1) >> bB;
}

int down(int x) {
	return x >> bB;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	const int H = up(n);
	vector<int> bv(H, INT_MAX), v(n, INT_MAX);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			v[x] = y;
			int p = down(x);
			bv[p] = INT_MAX;
			for (int i = p << bB; i < n && i < (p << bB) + B; i++) {
				bv[p] = min(bv[p], v[i]);
			}
		}
		else {
			y++;
			int res = INT_MAX;
			for (int i = x; i < y && i < (up(x) << bB); i++) {
				res = min(res, v[i]);
			}
			if (up(x) <= down(y)) {
				for (int i = up(x); i < down(y); i++) {
					res = min(res, bv[i]);
				}
				for (int i = down(y) << bB; i < y; i++) {
					res = min(res, v[i]);
				}
			}
			printf("%d\n", res);
		}
	}
	return 0;
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll N,K,Q; cin >> N >> K >> Q;
    vector<ll> A(N, K-Q);
    REP(i,Q){
        int a; cin >> a;
        a--;
        A[a] ++;
    }
    REP(i,N){
        cout << (A[i]>0?"Yes":"No") << endl;
    }

    return 0;
}

Measured memory_bytes: 4048