akhauriyash/Code-Regression huggingface dataset:
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
	while(z[++Z]=x%10+48,x/=10);
	while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
const int mod=998244353,N=2020;
int n,m,f[N*2][N*2],sum[N][2];

int main()
{
	char c=read();
	while (!isdigit(c)) c=read();
	while (isdigit(c))
	{
		n++;
		if (c=='0') sum[n][0]+=2;
		else
		if (c=='1') sum[n][0]++,sum[n][1]++;
		else sum[n][1]+=2;
		sum[n][0]+=sum[n-1][0];
		sum[n][1]+=sum[n-1][1];
		c=read();
	}
	if (sum[1][0]) f[1][0]=1;
	if (sum[1][1]) f[1][1]=1;
	for (int i=2;i<=2*n;i++)
		for (int j=0;j<=i;j++)
		{
			if (j>sum[min(i,n)][1]||i-j>sum[min(i,n)][0]) continue;
			f[i][j]=(f[i][j]+f[i-1][j])%mod;
			if (j) f[i][j]=(f[i][j]+f[i-1][j-1])%mod;
		}
	cout<<f[2*n][sum[n][1]];
	return 0;
}








Measured memory_bytes: 66304
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int Inf = (int) 1e9;
		int[][] dp = new int[2][];
		for(int i=0;i<2;i++){
			dp[i] = new int[N];
			for(int j=0;j<N;j++) dp[i][j] = Inf;
		}
		if(S[0] == '.'){
			dp[0][0] = 0;
			dp[1][0] = 1;
		} else {
			dp[0][0] = 1;
			dp[1][0] = 0;
		}
		for(int i=1;i<N;i++){
			if(S[i] == '.'){
				dp[0][i] = Math.Min(dp[0][i], dp[0][i-1]);
				dp[1][i] = Math.Min(dp[1][i], dp[0][i-1] + 1);
				dp[1][i] = Math.Min(dp[1][i], dp[1][i-1] + 1);
			} else {
				dp[0][i] = Math.Min(dp[0][i], dp[0][i-1] + 1);
				dp[1][i] = Math.Min(dp[1][i], dp[0][i-1]);
				dp[1][i] = Math.Min(dp[1][i], dp[1][i-1]);
			}
		}
		Console.WriteLine(Math.Min(dp[0][N-1], dp[1][N-1]));
		
		
		
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13408
N, Q = map(int, input().split())
S = input()

C=[0]*(N)
c=0
for i in range(len(S)-1):
  if S[i:i+2]=="AC": c += 1
  C[i] = c

#print(C)

for q in range(Q):
  l, r = map(int, input().split())
  l, r = l-1, r-1

  ans = C[r-1] - C[l-1]
  print(ans)

Measured memory_bytes: 6084
s = int(input())
 
a = int(s / 100) #百の位と千の位
b = s - a*100 #下二桁
 
if a > 12:
  if b > 12 or b == 0:
    print("NA")
  else:
    print("YYMM")
elif a == 0:
  if b < 13 and b > 0:
    print("YYMM")
  else:
    print("NA")
elif b > 12 or b == 0:
  print("MMYY")
else:
  print("AMBIGUOUS")

Measured memory_bytes: 3060
#include<stdio.h>

int main() {
	
	int i;
	int q;
	
	int n;
	char s[100001];
	int a[100000],b[100000];
	
	int cnt[100001] = { 0 };
	scanf("%d%d", &n, &q);
	scanf("%s", s);
	
	
	for (i = 0; i < q; i++)scanf("%d%d", &a[i], &b[i]);
	
	for (i = 1; i < n; i++) {

		if (s[i - 1] == 'A' && s[i] == 'C') {
			cnt[i]++;
			
		}cnt[i] = cnt[i] + cnt[i - 1];
	}
	
	

	for (i = 0; i < q; i++)printf("%d\n",cnt[b[i]-1]-cnt[a[i]-1]);
	return 0;
	
}

Measured memory_bytes: 2048
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(input())
d = {'r': p, 's': r, 'p': s}
ans = 0
for i in range(n):
    if i < k:
        ans += d[t[i]]
    elif t[i] == t[i - k]:
        t[i] = None
    else:
        ans += d[t[i]]
print(ans)

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()
#define BETWEEN(a, x, b) (a) <= (x) && (x) <= (b) 

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;


void solve()
{
    int n, l;
    cin >> n >> l;
    vs s(n);
    REP(i, n)
    {
        cin >> s[i];
    }
    sort(ALL(s));
    REP(i, n)
    {
        cout << s[i];
    } 
    cout << endl;
}

int main()
{
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    if(a < b){
    cout << "a < b";
    }
    else if(a > b){
    cout << "a > b";
    }
    else{
    cout << "a == b";
    }
    cout << endl;
  
    
}


Measured memory_bytes: 3024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define fi first
#define se second
#define pb push_back
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
#define L(i,u) for (int i=head[u]; i!=0; i=edge[i].nxt)
#define abs(a) ((a)>0 ? (a) : -(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef long long ll;
typedef long double ld;
int n,a[3][555],f[3][555];


inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=10*x+c-'0'; c=getchar();} x*=f;
}

int main() {
	read(n); rep(i,1,2)rep(j,1,n) read(a[i][j]);
	rep(i,1,2) rep(j,1,n) f[i][j]=a[i][j]+max(f[i][j-1],f[i-1][j]);
	printf("%d",f[2][n]);
	return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >h(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (h[i] == 0) {
			continue;
		}
		int w = h[i];
		ans += w;
		for (int j = i; j < N; j++) {
			if (h[j] < w) {
				w = h[j];
			}
			h[j] -= w;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() 
{
    short int n;

    cin >> n;

    short int a[n];

    for( short int i = 0; i < n; i++ )      //入力
        cin >> a[i];

    for( short int i = n - 1; i > 0; i--)   //出力
        cout << a[i] << " ";
    
    cout << a[0] << endl;

    return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,K;
int ans;
int A[15],B[15];
vint vec;
void dfs(int n,int k){
    if(n==N){
        vint v=vec;
        rep(i,v.size()){
            for(int j=i+1;j<v.size();j++){
                if(A[v[i]]<A[v[j]])swap(v[i],v[j]);
            }
        }
        int cur=M;
        int sum=0;
        rep(i,v.size()){
            sum+=min(cur,B[v[i]])*A[v[i]];
            cur-=min(cur,B[v[i]]);
        }
        sum+=cur;
        chmax(ans,sum);
        return;
    }

    dfs(n+1,k);
    if(k<K){
        vec.pb(n);
        dfs(n+1,k+1);
        vec.pop_back();
    }
}
signed main(){
    cin>>N>>M>>K;
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];

    dfs(0,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	string s;
	cin >> s;

	int cnt1 = 0, cnt2 = 0;

	rep(i, 0, s.size() - 1) {
		rep(j, i + 1, s.size()) {
			if (s[i] == s[j]) cnt1++;
			else cnt2++;
		}
	}

	if (cnt1 == 2 && cnt2 == 4) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll, ll>
#define mii         map<pii, ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a + b + p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    string s;
    cin>>s;
    int a,b;
    a = b = 0;
    rep(i, 0, sz(s)) {
        if(s[i] == '1') {
            if(i%2 == 0)
                a++;
            else
                b++;
        }
        else {
            if(i%2)
                a++;
            else
                b++;
        }
    }
    cout<<min(a,b)<<endl;

}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}




Measured memory_bytes: 512
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t calc_height(int64_t x, int64_t y, int64_t Cx, int64_t Cy, int64_t H)
{
	return std::max((int64_t)0, H - std::abs(x - Cx) - std::abs(y - Cy));
}

void solve()
{
    int64_t N;
	std::cin >> N;
	std::vector<int64_t> x(N), y(N), h(N);
	for (int64_t i = 0; i < N; i++) {
		std::cin >> x[i] >> y[i] >> h[i];
	}

	if (N == 1) {
		std::cout << x[0] << " " << y[0] << " " << h[0] << std::endl;
		return;
	}

	int64_t target;
	for(int64_t i = 0; i < N; i++) {
		if(h[i] != 0) {
			target = i;
			break;
		}
	}

	for (int64_t cx = 0; cx <= 100; cx++) {
		for (int64_t cy = 0; cy <= 100; cy++) {
			bool ok = true;
			int64_t H = h[target] + std::abs(x[target] - cx) + std::abs(y[target] - cy);
			if (H < 1) {
				ok = false;
			}
			for (int i = 0; i < N; i++) {
				if (calc_height(x[i], y[i], cx, cy, H) != h[i]) {
					ok = false;
				}
			}
			if(ok) {
				std::cout << cx << " " << cy << " " << H << std::endl;
				return;
			}
		}
	}

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
Sum = 0

if N >= M:
    print(0)
else:
    Dist = [0]*(M-1)
    for i in range(M-1):
        Dist[i] = X[i+1] - X[i]
        Sum += Dist[i]

    Dist.sort(reverse=True)
    for j in range(N-1):
        Sum -= Dist[j]

    print(Sum)


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define all(a) a.begin(), a.end()

int main() {
    int K, X;
    scanf("%d%d", &K, &X);
    rep(i, (K - 1) * 2 + 1) printf("%d ", X - K + 1 + i);
    printf("\n");
}



Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, input().split())
P = list(map(int, input().split()))

def f(n):
    return (n * (n + 1) // 2) / n

acc = [0 for _ in range(N + 1)]

for i in range(N):
    acc[i + 1] = acc[i] + f(P[i])

ans = 0
for i in range(N - K + 1):
    ans = max(ans, acc[i + K] - acc[i])
print(ans)
# print(acc)

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

int main() {
    int X, N;
    cin >> X >> N;
    map<int, int> mp;
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        mp[a]++;
    }
    for(int i = 0; i < 1010; ++i) {
        if(!mp[X - i]) {
            cout << X - i << '\n';
            return 0;
        }
        if(!mp[X + i]) {
            cout << X + i << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        List<edge>[] edges = Enumerable.Repeat(0, n).Select(_ => new List<edge>()).ToArray();
        for (int i = 0; i < n - 1; i++)
        {
            int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            edges[abc[0] - 1].Add(new edge(abc[1] - 1, abc[2]));
            edges[abc[1] - 1].Add(new edge(abc[0] - 1, abc[2]));
        }
        int[] qk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[] totalCost = Enumerable.Repeat(long.MaxValue, n).ToArray();
        totalCost[qk[1] - 1] = 0;
        Queue<int> queue = new Queue<int>();
        queue.Enqueue(qk[1] - 1);
        while (queue.Count != 0)
        {
            int ind = queue.Dequeue();
            List<edge> list = edges[ind];
            for (int i = 0; i < list.Count; i++)
            {
                if (totalCost[list[i].to] > totalCost[ind])
                {
                    totalCost[list[i].to] = totalCost[ind] + list[i].cost;
                    queue.Enqueue(list[i].to);
                }
            }
        }
        for (int i = 0; i < qk[0]; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(totalCost[ab[0] - 1] + totalCost[ab[1] - 1]);
        }
    }
}
struct edge
{
    public int to;
    public long cost;
    public edge(int to, long cost)
    {
        this.to = to;
        this.cost = cost;
    }
}

Measured memory_bytes: 38216
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

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

	int n;
	cin >> n;

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

	long long rui[n+1] = {};
	for(int i=1;i<n+1;i++){
		rui[i] = rui[i-1] + a[i-1];
	}
	sort(rui,rui+n+1);

	long long ans=0;
	for(int i=0;i<n+1;){
		auto up = upper_bound(rui+i,rui+n+1,rui[i]);
		for(int j=up-(rui+i)-1;j>0;j--){
			ans += j;
		}
		i = up-rui;
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  long long A, B;
  cin >> A >> B;
  for(int i = 1; i <= B; i++) {
    if((A * i) % B == 0) {
      cout << A * i << endl;
      break;
    }
  }
}

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

using namespace std;

const char *f = "MARCH";

bool isLegal(char ch){
    for(int i = 0; i < 5; i++)
        if(f[i] == ch) return true;
    return false;
}


int main(){
    int n;
    string name;
    map<char, long long> cnt;
    cin >> n;
    while(n --){
        cin >> name;
        if(isLegal(name[0])) cnt[name[0]] ++;
    }
    long long sum = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                sum += (1LL)*(cnt[f[i]] * cnt[f[j]] * cnt[f[k]]);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  if(A < 10 && B < 10){
    myout(A * B);
  }else{
    myout(-1);
  }
}


Measured memory_bytes: 30400
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#define INF 0x3f3f3f3f
#define maxn 105000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
 
#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define rs(str) scanf("%s",str)
#define pr(n) cout << n << endl
#define ll long long
#define int64 __int64

using namespace std;

const ll mod = 1e9 + 7;

//Date:2018-8-5
//Author：HarryBlackCat

int arr[maxn];

void init(){
	mem(arr,0);
}

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	int n;
	while(~ri(n)){
		init();
		
		for(int i = 0;i < n;i++)
			ri(arr[i]);
		
		sort(arr,arr + n);
		
		pr(arr[n - 1] - arr[0]);
	} 
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
	char s[4];
	char t[4];
	int i, c=0;
	scanf("%s",s);
	scanf("%s",t);
	
	for(i=0;i<3;i++) if(s[i] == t[i]) c++;
	
	printf("%d\n",c);
	
	return 0;
}

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

int main()
{
  	int n, k;
    cin >> n >> k;
    
    int *arr = new int[n];
    for(int i = 0; i < n; i++)
    {
       	cin >> arr[i];
    }
    
    int dp[n];
    for(int i = 0; i < n; i++)
    {
        dp[i] = INT_MAX;
    } 
    
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
  
    for(int i = 2; i < n; i++)
    {
        int res = INT_MAX;
        for(int j = 1; j <= k; j++)
        {
            if(i-j >= 0) res = min(res, dp[i-j] + abs(arr[i-j] - arr[i]));
        }
        dp[i] = res;
    }
    
    cout<<dp[n-1]<<"\n";
    return 0;
}

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

int main(){

    int n,d;
    cin >>n >> d;
    vector<vector<int>> a(n,vector<int>(d));

    rep(i,n){
        rep(j,d){
            cin >> a[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int su=0;
            for(int k=0;k<d;k++){
                su+=pow(a[i][k]-a[j][k],2);
            }
            int sq=sqrt(su);
            sq*=sq;
            if(sq==su){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
class nUnbalanced:
	def searchStrings(self,s):
		if len(s)==2:
			x_f=s[0]; x_s=s[1]
			if x_f==x_s: print 1,2; return
			else: print -1,-1; return
		for base in range(len(s)-2):
			x_f=s[base]; x_s=s[base+1]; x_t=s[base+2]
			if x_f==x_s or x_s==x_t or x_f==x_t: print base+1,base+3; return
		print -1,-1

if __name__ == "__main__":
	s=raw_input()
	u=nUnbalanced()
	u.searchStrings(s)

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, a[111], b[111];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	
	int ans = 0, cnt = 0;
	for(int i = 0; i < n; i++){
		cnt += b[i];
	}
	cnt+= a[0];
	ans = cnt;
	for(int i = 1; i < n; i++){
		cnt += a[i] - b[i-1];
		chmax(ans,cnt);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

using namespace std;

using ll = long long;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    ll ans = 0;
    if (a[0] > x) ans += a[0] - x, a[0] = x;
    for (int i = 1; i < N; ++i) {
        if (a[i-1] + a[i] > x) {
            ans += a[i-1] + a[i] - x;
            a[i] = x - a[i-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}

// 面積の最大値と最小値を出す(一つ向きが違う割り方)
long int check_S(long int a, long int b, long int a1){
  long long int s1, s2, s3, smax, smin;
  s1 = (a1 * b);
  s2 = (a - a1) * (b / 2);
  s3 = (a - a1) * (b - (b / 2));
  smax = MAX(MAX(s1, s2), s3);
  smin = MIN(MIN(s1, s2), s3);
  return smax - smin;
}

// 面積の最大値と最小値を出す(全て同じ向きな割り方)
long int check_S2(long int a, long int b, long int a1){
  long long int s1, s2, s3, smax, smin;
  s1 = (a1 * b);
  s2 = ((a - a1)/2) * b;
  s3 = (a - a1 -((a - a1)/2)) * b;
  smax = MAX(MAX(s1, s2), s3);
  smin = MIN(MIN(s1, s2), s3);
  return smax - smin;
}


// min
int main(void){
  long long int h, w;
  long long int ans = 0;
  long long int a, b;
  long long int s1, s2, s3, smax, smin;

  scanf("%lld%lld", &h, &w);

  if(h % 3 == 0 || w % 3 == 0){
    ans = 0;
    printf("%lld\n", ans);
    return 0;
  }

  // wを/3する
  ans = check_S(w, h, w/3);
  //  printf("ans = %lld\n", ans);

  // w を/3 + 1
  if(ans > check_S(w, h, w/3 + 1)){
    ans = check_S(w, h, w/3 + 1);
  }
  //  printf("ans = %lld\n", ans);

  // w を三分割(切り捨て)
  if(ans > check_S2(w, h, w/3)){
    ans = check_S2(w, h, w/3);
  }

  // w を三分割(+1)
  if(ans > check_S2(w, h, w/3 + 1)){
    ans = check_S2(w, h, w/3 + 1);
  }

  // hを/3する
  if(ans > check_S(h, w, h/3)){
    ans = check_S(h, w, h/3);
  }

  // hを/3 + 1する
  if(ans > check_S(h, w, h/3 + 1)){
    ans = check_S(h, w, h/3 + 1);
  }

  // h を三分割(切り捨て)
  if(ans > check_S2(h, w, h/3)){
    ans = check_S2(h, w, h/3);
  }

  // h を三分割(+1)
  if(ans > check_S2(h, w, h/3 + 1)){
    ans = check_S2(h, w, h/3 + 1);
  }

  printf("%lld\n", ans);
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)(n); i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)(n); i++)
#define ALL(v) v.begin(), v.end()

int main() {
  int n;cin>>n;
  vector<int> p(n);
  REP(i,n) {
    cin>>p[i];
  }
  int ans=0;
  FOR(i,1,n-1){
    if((p[i]<p[i-1]&&p[i]>p[i+1])||
       (p[i]>p[i-1]&&p[i]<p[i+1])){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod (1000000007)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
int64_t power(int64_t x,int64_t n)
{
    int64_t res=1;
    while(n){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
//B=lcm*(1/Aの和)
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    vector<ll>lcm(1000010,0);
    ll n,ans=0;cin>>n;
    ll a[n];REP(i,n)cin>>a[i],(ans+=power(a[i],mod-2))%=mod;//ans=Aの逆元の和
    REP(i,n){
        ll tmp=a[i];
        for(int j=2;j*j<=tmp;j++){//lcmを素因数分解してからansに掛け算
            if(tmp==1)break;
            if(tmp%j==0){
                ll cnt=0;
                while(tmp%j==0)tmp/=j,cnt++;
                while(lcm[j]<cnt)(ans*=j)%=mod,lcm[j]++;
            }
        }
        while(tmp&&!lcm[tmp])(ans*=tmp)%=mod,lcm[tmp]++;//a[i]は素数
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8192
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
	stringstream ss;
	ss << f;
	ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x)
#define debug(x)
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain() {
	int n;
	cin >> n;
	set<pair<int, pii>> se;
	vint v(n);
	rep(i, n) cin >> v[i];
	rep(i, n) {
		int p = i;
		while(p < v.size() && v[p] == v[i]) p++;
		se.insert(mkp(v[i], pii(i, p)));
		i = p - 1;
	}
	int ans = 0;
	while(1) {
		if(se.size() == 1) {
			ans++;
			break;
		}
		auto it1 = se.rbegin();
		auto it2 = it1++;
		if(it1->F == it2->F && it1->S.S == it2->S.F) {
			auto t = *it1;
			t.S.S = it2->S.S;
			se.erase(*it1);
			se.erase(*it2);
			se.insert(t);
		}
		else {
			auto t = *se.rbegin();
			int m = 0;
			if(t.S.F) maxs(m, v[t.S.F - 1]);
			if(t.S.S < n) maxs(m, v[t.S.S]);
			se.erase(*se.rbegin());
			t.F = m;
			ans++;
			se.insert(t);
			v[t.S.F] = m;
			v[t.S.S - 1] = m;
		}
	}
	cout << ans << endl;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	mainmain();
}

Measured memory_bytes: 16028
using System;

namespace C___Exception_Handling
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var max = int.Parse(Console.ReadLine());
            var maxIndex = 1;
            var second = 0;
            for (int i = 1; i < N; i++)
            {
                var Ai = int.Parse(Console.ReadLine());
                if (second <= Ai)
                {
                    if (max <= Ai)
                    {
                        second = max;
                        max = Ai;
                        maxIndex = i+1;
                    }
                    else
                    {
                        second = Ai;
                    }
                }
            }
            for (int i = 1; i <= N; i++)
            {
                Console.WriteLine(i == maxIndex ? second : max);
            }
        }
    }
}


Measured memory_bytes: 16584
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1000000007;
int a[100010];
int main(){
    int n , k;
    while (~scanf("%d%d", &n, &k)){
        k --;
        int id;
        for (int i=0; i<n; i++)  {
            scanf("%d", &a[i]);
            if (a[i] == 1)  id = i;
        }

        int ans = 0, num = 0;
        for (int i=id-1; i>=0; i--){
            num ++;
            if (num % k == 0)  ans ++;
        }
        for (int i=id+1; i<n; i++){
            num ++;
            if (num % k == 0)  ans ++;
        }
        if (num % k != 0)  ans ++;

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


Measured memory_bytes: 640
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
#include<stdio.h>

using namespace std;

int main() {
	string S;
	int flag = 0;
	cin >> S;

	for (int i = 0; (unsigned int)i <S.size(); i += 2) {
		if (S[i] == 'L') {
			++flag;
		}
		
	}

	for (int j = 1; (unsigned int)j < S.size(); j += 2) {
		if (S[j] == 'R') {
			++flag;
		}
	}

	if (flag == 0) {
		cout << "Yes" << endl;
	}
	else if (flag != 0) {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);
            int S = int.Parse(s[2]);

            StringBuilder answer = new StringBuilder();

            for(int i = 0; i < K; i++)
            {
                answer.Append(S);
                answer.Append(" ");
            }

            for(int i = K; i < N; i++)
            {
                if (S == 1e9)
                {
                    answer.Append("1 ");
                }
                else
                {
                    answer.Append(1e9);
                    answer.Append(" ");
                }
            }

            Console.WriteLine(answer.ToString().Substring(0,answer.ToString().Length - 1));
        }
    }
}

Measured memory_bytes: 29020
N,M,C=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]

def ac(A):
    s=0
    for a,b in zip(A,B):
        s+=a*b
    return s+C>0

retval=0
for i in range(N):
    A=[int(i) for i in input().split(" ")]
    retval+=ac(A)

print(retval)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define lk (k<<1)
#define rk (k<<|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf=0x3f3f3f3f;
const int N=1e2+10;
int main()
{
    long long x,k,d;
    cin>>x>>k>>d;
    long long num=labs(x/d),ans;
    if(num>=k) ans=labs(labs(x)-k*d);
    else {
        long long now=labs(labs(x)-num*d);
        k-=num;
        if(labs(now-d)<labs(now)) k--,now-=d,now=labs(now);
        if(k%2==0) ans=now;
        else ans=min(labs(now-d),labs(now+d));
    }
    cout<<labs(ans)<<endl;
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;
// Segment Tree {{{
template <typename T>
class SegTree {
 private:
    int _n;
    T _init_val;
    std::vector<T> _data;
    std::function<T(T, T)> _f;

    T _query(int a, int b, int k, int l, int r) {
        // [a b)と[l r]が交差しない
        if (r <= a || b <= l) return _init_val;

        // [a b)が[l r]を含む
        if (a <= l && r <= b) return _data[k];

        T vl = _query(a, b, k*2+1, l, (l+r)/2);
        T vr = _query(a, b, k*2+2, (l+r)/2, r);

        return _f(vl, vr);
    }

 public:
    SegTree(int n, T init_val, std::function<T(T, T)> f) {
        _init_val = init_val;
        _n = 1;
        _f = f;

        while (_n < n)
            _n *= 2;
        _data.resize(2 * _n, init_val);
    }

    T get(int k) {
        return _data[k + _n - 1];
    }

    void update(int k, T a) {
        k += _n-1;
        _data[k] = a;
        while (k > 0) {
            k = (k-1)/2;
            _data[k] = _f(_data[k*2+1], _data[k*2+2]);
        }
    }

    // [a b)の範囲でfを適用
    T query(int a, int b) {
        return _query(a, b, 0, 0, _n);
    }

    // 先頭からチェックし，はじめてxを満たしたインデックス
    int lower_bound(T x) {
        return _lower_bound(x, 0);
    }

    int _lower_bound(T x, int k) {
        if (k >= _n-1) {
            return k - (_n - 1);  // 葉
        } else if (_data[k] < x) {
            return _n;  // 該当なし
        } else if (x <= _data[k * 2 + 1]) {
            return _lower_bound(x, k * 2 + 1);
        } else {
            return _lower_bound(x - _data[k * 2 + 1] , k * 2 + 2);
        }
    }
};
// }}}

ll N;
string s;
vector<SegTree<ll>> st(30, SegTree<ll>(5000, 0, [](const ll x, const ll y) {return x+y;}));

signed main() {
  cin >> N >> s;
  rep(i, N) {
    st[s[i]-'A'].update(i, 1);
  }
  ll ans = 0;
  for (ll i=0; i<N; i++) for (ll j=i+1; j<N; j++) {
    if (s[i] == s[j]) continue;
    ans += st[0+'R'+'G'+'B'-s[i]-s[j]-'A'].query(j+1, N);
    if (2*j-i < N && s[2*j-i] == 0+'R'+'G'+'B'-s[i]-s[j]) ans--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7276
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

class Check{
public:
	int i, j, k, r;
	Check() : i(0), j(0), k(0), r(0) {}
};

int main(){
	int a, b, c, n;
	vector< Check > checklist;
	vector< int > result;
	
	while(cin >> a >> b >> c, a){
		int x, y, z, r;
				
		cin >> n;
		
		checklist.RS(n);
		result.RS(a+b+c);
		
		REP(i, a+b+c) result[i] = 2;
		
		REP(i, n){
			cin >> x >> y >> z >> r;
			checklist[i].i = x;
			checklist[i].j = y;
			checklist[i].k = z;
			checklist[i].r = r;			
		}
		
		REP(i, n){
			if(checklist[i].r == 1){
				result[checklist[i].i - 1] = 1;
				result[checklist[i].j - 1] = 1;
				result[checklist[i].k - 1] = 1;
			}
		}
		
		REP(i, n){
			if(checklist[i].r == 0){
				if(result[checklist[i].i - 1] == 1 && result[checklist[i].j - 1] == 1 && result[checklist[i].k - 1] != 1) result[checklist[i].k - 1] = 0;
				else if(result[checklist[i].j - 1] == 1 && result[checklist[i].k - 1] == 1 && result[checklist[i].i - 1] != 1) result[checklist[i].i - 1] = 0;
				else if(result[checklist[i].k - 1] == 1 && result[checklist[i].i - 1] == 1 && result[checklist[i].j - 1] != 1) result[checklist[i].j - 1] = 0;
			}
		}		
		
		REP(i, a+b+c){
			cout << result[i] << endl;
		}
		
	}	
	
	return 0;
}

Measured memory_bytes: 1244
#
N = int(input())
A = []
A.append(list(map(int, input().rstrip().split())))
A.append(list(map(int, input().rstrip().split())))

#
ans = 0
for i in range(N):
    tmp = sum(A[0][:i+1]) + sum(A[1][i:])
    ans = max(ans, tmp)

#
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC135
{
    class Program2
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var missedNum = 0;
            for (int i = 0; i < p.Length; i++)
                if (p[i] != i + 1)
                    missedNum++;

            if (missedNum == 0 || missedNum == 2)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        tmp--;
        a[tmp]++;
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    for (int i = 0; i < n - k; i++) {
        if (a[i] == 0) {
            continue;
        }
        // cout << a[i] << endl;
        cnt += a[i];
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
N = int(input())
T, A = map(int, input().split())
H = input().split()

HA = (T-A)/0.006

dH = 100000
point = 100000

for i in range(N):
  if dH > abs(float(H[i]) - HA):
    dH = abs(float(H[i]) - HA)
    point = i+1

print(point)

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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MAXN 100005
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define pb push_back
#define int long long
#define endl '\n'

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <vi> matriz;
typedef vector <pair <string, int>> vis;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// auto timer_start = chrono::steady_clock::now().time_since_epoch().count();

int a, b, c, l, m, n, k;
string s, t;

int32_t main(){
    fastio
    cin >> a;
    cout << (a + (a * a) + (a * a * a)) << endl;    

    return 0;
}

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

using namespace std;

int main(void){
    int L, ans = 0;
    string s;
    cin >> L >> s;
    for(int i=0;i<L;i++){
        if(s[i] != '.') continue;
        s[i] = 'W';
        int l = i, r = i;
        while(l > 0 && s[l] == 'W') l--;
        while(r < L-1 && s[r] == 'W') r++;
        if(s[l] == 'B' && s[r] == 'B'){
            s[i] = '.';
            continue;
        }
        int cnt = -1, sum = 0;
        for(int j=0;j<L;j++){
            if(s[j] == 'W'){
                sum += max(0, cnt);
                cnt = 0;
            }
            if(s[j] == 'B' && cnt >= 0) cnt++;
            if(s[j] == '.') cnt = -1;
        }
        s[i] = '.';
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX (300000+10)
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vector<int>v;
    for(int i=0;7*i+6<MAX;i++){
        if(!i){v.push_back(6); continue;}
        v.push_back(7*i+1);
        v.push_back(7*i+6);
    }
    vector<int>p;
    p.push_back(6);
    vector<bool>flag(MAX,true);
    for(int i=0;i<v.size();i++){
        if(!flag[v[i]])continue;
        for(int j=0; v[j]*v[i]<MAX;j++)
            flag[v[i]*v[j]]=false;
    }
    
    int n;
    while(cin>>n,n!=1){
        vector<int>ans;
        int  range=(int)(upper_bound(all(v),n)-v.begin());
        for(int i=range; i>=0;i--){
            if(v[i]>n)continue;
            if(!(n%v[i]))if(flag[v[i]])ans.push_back(v[i]);
        }
        reverse(all(ans));
        cout<<n<<": ";
        rep(i,ans.size())if(i)cout<<" "<<ans[i];else cout<<ans[i];
        cout<<endl;
    }
}

Measured memory_bytes: 3268
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;

struct _3D
{
  double x,y,z;
  _3D(double x=-1,double y=-1,double z=-1):x(x),y(y),z(z){}
};
int N;
bool used[600];

double get3Dangle(_3D A,_3D B,_3D C)
{
  double a = sqrt(pow(B.x-C.x,2)+pow(B.y-C.y,2)+pow(B.z-C.z,2));
  double b = sqrt(pow(A.x-C.x,2)+pow(A.y-C.y,2)+pow(A.z-C.z,2));
  double c = sqrt(pow(B.x-A.x,2)+pow(B.y-A.y,2)+pow(B.z-A.z,2));
  return acos((a*a+c*c-b*b)/(2.0*a*c));
}

int main()
{
  _3D a[3];
  a[0].x = 0,a[0].y = 0,a[0].z = 1;
  a[1].x = 0,a[1].y = 0,a[1].z = 0;
  a[2].x = 1,a[2].y = 0,a[2].z = 0;
  //cout << get3Dangle(a[0],a[1],a[2]) << endl;

  while(cin >> N,N)
    {
      vector<_3D> vec;
      if(true)
	{
	  rep(i,600)used[i] = false;
	  double x,y,z;
	  rep(i,N)
	    {
	      cin >> x >> y >> z;
	      vec.push_back(_3D(x,y,z));
	    }
	}
	  int M;
	  cin >> M;
	  double x,y,z,agl;
	  int cnt = 0;
	  rep(i,M)
	    {
	      cin >> x >> y >> z >> agl;
	      rep(j,N)
		{
		  if(used[j])continue;
		  double agr = fabs(get3Dangle(vec[j],_3D(0,0,0),_3D(x,y,z)));
		  if(equals(agr,agl) || agr < agl)
		    {
		      cnt++;
		      used[j] = true;
		    }
		}
	    }

	  cout << cnt << endl;
	
	  
    }
  return 0;
}

Measured memory_bytes: 1332