akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}



void oneCase () {
    string l, r;
    int a, b;
    cin >> l >> r >> a >> b;
    string u;
    cin >> u;
    if (u == l) {
        --a;
    } else {
        --b;
    }
    cout << a << " " << b << '\n';
}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
vector<int>v;
int n, a[123456];
signed main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	v.push_back(a[n - 1]);
	for (int i = n - 2; i >= 0; i--) {
		if (v[v.size() - 1] <= a[i]) {
			v.push_back(a[i]);
		}
		else {
			auto ir = upper_bound(v.begin(), v.end(), a[i]);
			v.erase(ir); v.insert(ir, a[i]);
		}
	}
	cout << v.size() << endl;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

bool solve(){
	ll a, b, c, d; cin >> a >> b >> c >> d;
	if(a < b || d < b) return 0;
	if(c >= b - 1) return 1;
	
	a -= (a - c + b - 1) / b * b;
	
	if(a < 0) return 0;
	
	ll g = __gcd(d, b);
	//dbg(a, g, c+1, b-1, (c+1-a+g-1)/g, (b-1-a)/g);
	if((c + 1 - a + g - 1) / g <= (b - 1 - a) / g) return 0;
	return 1;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int t; cin >> t;
	while(t--){
		cout << (solve() ? "Yes":"No") << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

#define PI acos(-1)

double a, b, x;

double f1(double c) {
	return ((c + b) / 2) * a * a;
}

double f2(double c) {
	return ((b * c) / 2) * a;
}

int main() {
	cin >> a >> b >> x;
	double l = 0, r = b;
	bool flag = a * a * b / 2 < x;
	if (!flag) r = a;
	for (int i = 0; i < 300; ++i) {
		double mid = (l + r) / 2;
		double tmp = (flag ? f1(mid) : f2(mid));
		if (tmp < x) l = mid;
		else r = mid;
	}
	double theta = (flag ? atan(a / (b - r)) : atan(r / b));
	double ans = (PI / 2 - theta) * (180 / PI);
	printf("%.10f\n", ans);

	return 0;
}

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

int main()
{
  int N; cin >> N;
  int ans = 0;
  if(N == 1) ans = 1;
  if(N >= 2) ans = 2;
  if(N >= 4) ans = 4;
  if(N >= 8) ans = 8;
  if(N >= 16) ans = 16;
  if(N >= 32) ans = 32;
  if(N >= 64) ans = 64;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// INPUT
		int n = sc.nextInt();
		if(2>n && n<200) System.exit(-1);
		int[][] arr = new int[n][3];
		for(int i=0; i<n; i++) {
			for(int j=0; j<3; j++) {
				arr[i][j] = sc.nextInt();
			}
		}
		
		// PROCESSING
		int[][] work = new int[n][3];
		
		int[] sum = new int[n];
		for(int i=0; i<n; i++) {
			sum[i] = 0;
		}
		
		for(int i=0; i<3; i++) {
			for(int j=0; j<n; j++) {
				work[j][i] = arr[j][i];
				for(int k=0; k<n; k++) {
					if(j != k && arr[j][i] == arr[k][i]) {
						work[j][i] = 0;
					}
				}
			}
		}
		
		for(int i=0; i<n; i++) {
			for(int j=0; j<3; j++) {
				sum[i] += work[i][j];
			}
		}
		
		//OUTPUT
		for(int i=0; i<n; i++) System.out.println(sum[i]);
	}
}

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

// lib/ntz.hpp
#ifndef NTZ_HPP
#define NTZ_HPP


namespace tools {
  std::uint32_t ntz(const std::uint32_t x);
}

#endif

// lib/bitcount.hpp
#ifndef BITCOUNT_HPP
#define BITCOUNT_HPP


namespace tools {
  std::uint32_t bitcount(std::uint32_t x);
}

#endif

// lib/ntz.cpp

namespace tools {
  std::uint32_t ntz(const std::uint32_t x) {
    return bitcount((x & -x) - 1u);
  }
}

// lib/bitcount.cpp

namespace tools {
  std::uint32_t bitcount(std::uint32_t x) {
    x = (x & 0x55555555u) + (x >> 1 & 0x55555555u);
    x = (x & 0x33333333u) + (x >> 2 & 0x33333333u);
    x = (x & 0x0f0f0f0fu) + (x >> 4 & 0x0f0f0f0fu);
    x = (x & 0x00ff00ffu) + (x >> 8 & 0x00ff00ffu);
    return (x & 0x0000ffffu) + (x >> 16 & 0x0000ffffu);
  }
}

// main.cpp

int main() {
  std::size_t n;
  std::cin >> n;
  std::vector<std::uint32_t> a;
  a.reserve(n);
  std::copy_n(std::istream_iterator<std::uint32_t>(std::cin), n, std::back_inserter(a));
  std::transform(a.begin(), a.end(), a.begin(), tools::ntz);
  std::cout << *std::min_element(a.begin(), a.end()) << std::endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
ap = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

n = input()<<ap>>int
print('ABC' if n < 1200 else 'ARC')



Measured memory_bytes: 21660
n   = int(input())
li  = list(map(int,input().split()))
cnt = 0

for i in range(n-2):
  li2 = []
  li2.append(li[i])
  li2.append(li[i+1])
  li2.append(li[i+2])
  li2.sort()
  if li2[1] == li[i+1]:
    cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;

if(s[0]==s[1]&&s[1]==s[2])
{
	ol("Yes");
	return 0;
}
if(s[3]==s[2]&&s[1]==s[2])
{
	ol("Yes");
	return 0;
}
ol("No");

return 0;
}



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

int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long result = 0;
  for (i = 0; i < n; i++) {
    int temp = 0;
    if ((i == 0 ) && (a[i] > x)) {
      temp = a[i] - x;
      result += temp;
      a[i] -= temp;
    } else if ((a[i - 1] + a[i]) > x) {
      temp = (a[i - 1] + a[i]) - x;
      result += temp;
      a[i] -= temp;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll x, y;
    cin >> x >> y;
    REP(p, x + 1) {
        ll q = x - p;
        if (2 * p + 4 * q == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3520
#include<cstdio>
#include<algorithm>
#define MOD 1000000007
#define MAXN 131072
using namespace std;
long long d[41][MAXN],ans,x,y,z,n;
bool check(int p)
{
	if((p&(1<<(x+y+z-1)))&&(p&(1<<(y+z-1))&&(p&(1<<(z-1))))) return 1;
	return 0;
}
long long ksm(long long a,long long m)
{
	if(m==0) return 1;
	long long nex=ksm(a,m/2);
	nex=(nex*nex)%MOD;
	if(m%2==0) return nex;
	else return (nex*a)%MOD;
}
int main()
{
	scanf("%lld%lld%lld%lld",&n,&x,&y,&z);
	d[0][0]=1;
	for(long long i=0;i<n;i++)
		for(long long j=0;j<MAXN;j++)
		{
			if(d[i][j])
			{
				for(long long k=1;k<=10;k++)
				{
					long long jj=((j<<k)+(1<<(k-1)))%MAXN;
					if(check(jj)) ans=(ans+d[i][j]*ksm(10*1ll,n-i-1))%MOD;
					else d[i+1][jj]=(d[i+1][jj]+d[i][j])%MOD;
				}
			}
		}
	printf("%lld",ans);
}

Measured memory_bytes: 40192
n=int(input())
a=list(map(int,input().split()))

l=[0]*(10**6+1)
ans=0
#print(l)
for i in a:
    if l[i]==0:
        for j in range(i,10**6+1,i):
            l[j]+=1
    else:
        l[i]+=1
for i in a:
    if l[i]==1:
        ans+=1
print(ans)

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	ll n, k;
	cin >> n >> k;
	if(k < n){
		n -= ((n-k)/k+1) * k;
		if(k<n) cout << "error" << endl;
	}
	cout << min(abs(n-k), n) << endl;
}


Measured memory_bytes: 3596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  int answer[1000000]={};
  REP(i,1024)
    REP(j,i)
      answer[(i*(i+1)-j*(j+1))/2]++;
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    cout << answer[n]-1 << endl;
  }
}

Measured memory_bytes: 5072
a,b,x=map(int,input().split())
if a%x==0 and b%x==0:
    print(b//x-a//x+1)
elif a%x!=0 and b%x==0:
    print(b//x-a//x)
elif a%x==0 and b%x!=0:
    print(b//x-a//x+1)
else:
    print(b//x-a//x)

Measured memory_bytes: 38584
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9 + 7;
int main() {
    ll n;
    cin >> n;
    ll all = 1, bad0 = 1, bad1 = 2;
    for(int i = 1; i <= n; ++i) all = all * 10 % MOD;
    for(int i = 1; i <= n; ++i) bad0 = bad0 * 8 % MOD;
    for(int i = 1; i <= n; ++i) bad1 = bad1 * 9 % MOD;
    ll bad = (bad1 - bad0 + MOD) % MOD;
    cout << (all - bad + MOD) % MOD << endl;
}

Measured memory_bytes: 3564
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {
	
	int h, w, count = 0;
	char s[60][60];
	rep(i, 60) {
		rep(j, 60)s[i][j] = '.';
	}
	scanf("%d%d%*c", &h, &w);
	rep(i, h) {
		rep(j, w) {
			scanf("%c", &s[i + 1][j + 1]);
		}
		scanf("%*c");
	}
	rep(i, h) rep(j, w) {
		if (s[i + 1][j + 1] == '.') {
			count = 0;
			rep(k, 3) {
				rep(l, 3) {
					if (k == 1 && l == 1)continue;
					else if (s[i + 1 + k - 1][j + 1 + l - 1] == '#')++count;
				}
			}
			s[i + 1][j + 1] = count + '0';
		}
	}
	rep(i, h) {
		rep(j, w) {
			printf("%c", s[i + 1][j + 1]);
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define inver(a) power(a,mod-2)
#define upd(a,b) a=add(a+b)
#define INV(a) ((ll)inv[a]*fac[a-1]%mod)
using namespace std;
inline char gc() {
//	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void rd(T &x) {
	x=0; int f=1,ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=gc();}
	x*=f;
}
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e7+50;
const int maxA=5000+5;
int n,A;
int fac[maxn],inv[maxn];
inline int add(int x) {return x>=mod?x-mod:x;}
inline int sub(int x) {return x<0?x+mod:x;}
ll power(ll x,ll y) {
	ll re=1;
	while(y) {
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
inline int binom(int x,int y) {
	return (ll)fac[x]*inv[y]%mod*inv[x-y]%mod;
}
inline int cal(int a,int b,int c) {
	return (ll)fac[a+b+c]*a%mod*INV(a+b)%mod;
}
void init(int n) {
	fac[0]=1;
	for(int i=1;i<=n;++i) fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=inver(fac[n]);
	for(int i=n;i>=1;--i) inv[i-1]=(ll)inv[i]*i%mod;
}
int main() {
	rd(n),rd(A);
	init(n);
	int an=0;
	for(int t=1;t<=A+1;++t) {
		for(int j=0,f=1;j<t;++j,f=mod-f) {
			an=(an+(ll)cal(t-j-1,n-A,max(0,A-t))*binom(t-1,j)%mod*f)%mod;
		}
	}
	printf("%d\n",an);
	return 0;
}

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

DP=[[-10**16 for i in range(N)]for j in range(3)]

DP[1][0]=0
DP[2][0]=0
DP[2][1]=0
DP[0][0]=A[0]
DP[1][1]=A[1]
if N>=3:
    DP[2][2]=A[2]

for i in range(2,N):
    DP[0][i]=DP[0][i-2]+A[i]
    DP[1][i]=DP[1][i-2]+A[i]
    DP[2][i]=DP[2][i-2]+A[i]
    if i-3>=0:
        DP[1][i]=max(DP[1][i],DP[0][i-3]+A[i])
        DP[2][i]=max(DP[2][i],DP[1][i-3]+A[i])
    if i-4>=0:
        DP[2][i]=max(DP[2][i],DP[0][i-4]+A[i])

if N%2==0:
    print(max(DP[0][-2],DP[1][-1]))
else:
    print(max(DP[0][-3],DP[1][-2],DP[2][-1]))

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

char a[22][22];
//char s[10]="China";   
//s=['C','h',i,n,a,\0,\0,\0,\0,\0]

int n,m;

struct pos{
	int x;
	int y;
	int step;
};

pos make_pos(int a,int b,int c){
	pos ret;
	
	ret.x=a;
	ret.y=b;
	ret.step=c;
	
	return ret;
}

int bfs(int sx,int sy,int ex,int ey){
	bool vis[n+2][m+2];
	
	for(int i=0;i<=n+1;++i)
		for(int j=0;j<=m+1;++j)
			if(a[i][j]=='#')
				vis[i][j]=true;
			else
				vis[i][j]=false;
	
	queue<pos> q;
	q.push(make_pos(sx,sy,0));
	vis[sx][sy]=true;
	int move[2][4]={{0,0,-1,1},{-1,1,0,0}};
	
	while(!q.empty()){
		pos fr=q.front();
		q.pop();
		if(fr.x==ex&&fr.y==ey)
			return fr.step;
			
		pos newpo;
		for(int i=0;i<4;++i){
			int nx=fr.x+move[0][i];
			int ny=fr.y+move[1][i];
			if(vis[nx][ny])
				continue;
			vis[nx][ny]=true;
			newpo=make_pos(nx,ny,fr.step+1);
			q.push(newpo);
		}
	}
	return 0;
}

int main(){
	for(int i=0;i<22;++i)
		for(int j=0;j<22;++j)
			a[i][j]='#';
	
	cin>>n>>m;
	
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			cin>>a[i][j];
	
	int maxv=0;
	
	for(int i1=1;i1<=n;++i1)
		for(int j1=1;j1<=m;++j1){
			if(a[i1][j1]=='#')
				continue;
			for(int i2=1;i2<=n;++i2)
				for(int j2=1;j2<=m;++j2){
					if(a[i2][j2]=='#')
						continue;
					if(i1==i2&&j1==j2)
						continue;
					
					maxv=max(maxv,bfs(i1,j1,i2,j2));
				}
		}
	
	cout<<maxv<<endl;
	return 0;
}

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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 100005;
const ll INF = (ll) 1e15;
struct E {
	int to, a, b;
};
vector<E> g[N];
typedef pair<ll, int> P;
ll d[2][N], ans[N];

void dijkstra(int s, int ord) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d[ord], d[ord] + N, INF);
    d[ord][s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
		int v = p.second;
        if (d[ord][v] < p.first) continue;
		for (auto e : g[v]) {
			ll ncost = d[ord][v] + (ord ? e.b : e.a);
            if (d[ord][e.to] > ncost) {
                d[ord][e.to] = ncost;
                que.push(P(ncost, e.to));
            }
        }
    }
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, m, s, t; cin >> n >> m >> s >> t;
	REPU(i, 0, m) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		g[u].push_back((E) {v, a, b});
		g[v].push_back((E) {u, a, b});
	}

	dijkstra(s, 0);
	dijkstra(t, 1);

	ans[n - 1] = d[0][n] + d[1][n];

	REPD(i, n - 2, -1) {
		ans[i] = min(ans[i + 1], d[0][i + 1] + d[1][i + 1]);
	}

	REPU(i, 0, n) printf("%lld\n", INF - ans[i]);

	return 0;
}


Measured memory_bytes: 10820
#include<iostream>
#include<list>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
typedef long int li;


int main(){
  map<int,int> mp;
  int n; cin >>n;
  rep(i,n){
    int a; cin >>a;
    mp[a]++;
  }
  vector<li> v;
  for(auto itr=mp.rbegin();itr!=mp.rend();itr++){
    if(itr->second < 2) continue;
    v.push_back(itr->first);
    if(itr->second >= 4) v.push_back(itr->first);
    if(v.size()>=2)break;
  }
  if(v.size()<2) printf("0\n");
  else printf("%ld\n",v[0]*v[1]);
}


Measured memory_bytes: 4992
n,k = map(int,input().split())
X = list(map(int,input().split()))

ans = float('inf')
for i in range(n-k+1):
    x = X[i]
    y = X[i+k-1]
    if x==0 and y==0:
        ans = 0
    if x<0 and y<=0:
        ans = min(ans,abs(x))
    if x>=0 and y>0:
        ans = min(ans,y)
    if x<0 and y>0:
        ans = min(ans,min(abs(x),y)*2+max(abs(x),y))
    if X[i]>=0:
        break
print(ans)

Measured memory_bytes: 14224
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by bi16060 on 2019/03/24.
 */
public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String enki = br.readLine();

        String pair = "";
        switch(enki){
            case("A"):
                pair = "T"; break;
            case("T"):
                pair = "A"; break;
            case("G"):
                pair = "C"; break;
            case("C"):
                pair = "G"; break;
        }

        System.out.println(pair);
    }
}


Measured memory_bytes: 21844
#include <iostream>
    #include <vector>
    #include <string>
    #include <algorithm>
    #include <iostream>
    #include <vector>
    #include <numeric>
    #include <string>
    #include <functional>
 
     
    using namespace std;
    int main(){
      	string str;
      	cin>>str;
      
      	const long long size = str.size();
      	vector<long long> vec0(size+1, 0), vec1(size+1, 0);
      	for (int i=0; i<size; i++){
         	if (str[i] == '<'){
             	vec0[i+1] = vec0[i] + 1;
            }     
        }
      
      	for (int i=size-1; i>=0; i--){
         	if (str[i] == '>'){
             	vec1[i] = vec1[i+1] + 1; 
            }      
        }
      
      	long long sum = 0;
      	for (int i=0; i<vec0.size(); i ++){
         	 sum += max(vec0[i], vec1[i]);
        }	
              
      	std::cout<<sum;
      
     	return 0; 
    }

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

int main(){
 string s;
  cin >> s;
 if(s.at(0) == s.at(1) && s.at(1)== s.at(2)) cout << "No" << endl;
 else cout << "Yes" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;

map<ll, ll> Vx, Vy;
ll Wx[4010];
ll Wy[4010];
short mov[5][4010][4010];

int main() {
	ll N, M;
	for (int i = 0;i < 4010;i++) {
		for (int j = 0;j < 4010;j++) {
			for (int k = 0;k < 5;k++)mov[k][i][j] = 0;
		}
		Wx[i] = 0;
		Wy[i] = 0;
	}
	cin >> N >> M;
	ll A, B, C, D, E, F, mxx, mxy;
	vector<tuple<ll, ll, ll>> abc(N), def(M);
	Vx.insert({ 0,0 });
	Vy.insert({ 0,0 });
	for (int i = 0;i < N;i++) {
		cin >> A >> B >> C;
		Vx.insert({ A,0 });
		Vx.insert({ B,0 });
		Vy.insert({ C,0 });
		abc[i] = make_tuple(A, B, C);
	}
	for (int i = 0;i < M;i++) {
		cin >> C >> A >> B;
		Vy.insert({ A,0 });
		Vy.insert({ B,0 });
		Vx.insert({ C,0 });
		def[i] = make_tuple(A, B, C);
	}
	A = 1;
	B = 0;
	for (auto& au : Vx) {
		au.second = A;
		Wx[A - 1] = au.first - B;
		B = au.first;
		A++;
	}
	mxx = Vx.size();
	A = 1;
	B = 0;
	for (auto& au : Vy) {
		au.second = A;
		Wy[A - 1] = au.first - B;
		B = au.first;
		A++;
	}
	mxy = Vy.size();

	for (int i = 0;i < N;i++) {
		tie(A, B, C) = abc[i];
		D = Vx[A];
		E = Vx[B];
		F = Vy[C];
		mov[0][D][F] += 1;
		mov[0][E][F] -= 1;
		mov[1][D][F - 1] += 1;
		mov[1][E][F - 1] -= 1;
	}
	for (int i = 0;i < M;i++) {
		tie(A, B, C) = def[i];
		D = Vy[A];
		E = Vy[B];
		F = Vx[C];
		mov[2][F][D] += 1;
		mov[2][F][E] -= 1;
		mov[3][F - 1][D] += 1;
		mov[3][F - 1][E] -= 1;
	}
	for (int i = 0;i < 4010;i++) {
		for (int j = 1;j < 4010;j++) {
			mov[0][j][i] += mov[0][j - 1][i];
			mov[1][j][i] += mov[1][j - 1][i];

			mov[2][i][j] += mov[2][i][j - 1];
			mov[3][i][j] += mov[3][i][j - 1];
		}
	}

	queue<pair<ll, ll>> Q;
	Q.push({ Vx[0],Vy[0] });
	ll ans = 0;
	while (!Q.empty()) {
		tie(A, B) = Q.front();
		Q.pop();
		if (mov[4][A][B])continue;
		mov[4][A][B] = 1;

		if (A == 0 || A == mxx || B == 0 || B == mxy) {
			cout << "INF" << endl;
			return 0;
		}

		ans += Wx[A] * Wy[B];

		if (mov[0][A][B] == 0) {
			if (mov[4][A][B - 1] == 0)
				Q.push({ A,B - 1 });
		}
		if (mov[1][A][B] == 0) {
			if (mov[4][A][B + 1] == 0)
				Q.push({ A,B + 1 });
		}
		if (mov[2][A][B] == 0) {
			if (mov[4][A - 1][B] == 0)
				Q.push({ A - 1,B });
		}
		if (mov[3][A][B] == 0) {
			if (mov[4][A + 1][B] == 0)
				Q.push({ A + 1,B });
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 161160
#include<stdio.h>

int main(){
  int h;
  int w;
  int i;
  int j;
  
  while(1){
    scanf("%d %d",&h,&w);
    
    if(h == 0 && w == 0){
      break;
    }

    for(i = 1;i <= h;i++){
      for(j = 1;j <=w;j++){
	printf("#");
      }
      printf("\n");
    }    
    printf("\n");
  }
  return(0);
}



Measured memory_bytes: 2024
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

t = STR()
t = t.replace('?', 'D')
print(t)


Measured memory_bytes: 69268
#include <stdio.h>
#define INFTY 1000000
#define M -1
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define N 100
void dijkstra(void);
int n,A[N][N];

int main()
{
  int i,j,u,k,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  A[i][j]=INFTY;
	}
    }
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&u,&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d%d",&v,&c);
	  A[u][v]=c;
	}
    }

  dijkstra();
  return 0;
}

void dijkstra(void)
{
  int d[N],p[N],color[N];
  int i,v,u,mincost;
  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      p[i]=M;
      color[i]=WHITE;
    }
  d[0]=0;
  color[0]=GRAY;
  while(1)
    {
      mincost=INFTY;
      //u=M;
      for(i=0;i<n;i++)
	{
	  if(mincost>d[i]&&color[i]!=BLACK)
	    {
	      u=i;
	      mincost=d[i];
	    }
	}
      if(mincost==INFTY) break;
      
      color[u]=BLACK;
      for(v=0;v<n;v++)
	{
	  if(color[v]!=BLACK&&d[u]+A[u][v]<d[v])
	    {
	      d[v]=d[u]+A[u][v];
	      p[v]=u;
	      color[v]=GRAY;
	    }
	}
    }
  for(i=0;i<n;i++)
    {
      printf("%d %d\n",i,d[i]);
    }
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  cout << h.end() - lower_bound(h.begin(), h.end(), k) << endl;
  return 0;
}


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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()

int minit[50][50];
int m[50][50];
int w, h;
const int W = 1;
const int B = 2;

void reset()
{
	rep(i, 50) rep(j, 50) {
		minit[i][j] = 0;
		m[i][j] = 0;
	}
}

void saiki(int r, int c, int x)
{
	if (!(r < h && r >= 0 && c < w && c >= 0)) return;
	if (minit[r][c] != 0 || (m[r][c] & x) != 0) return;
	m[r][c] += x;
	int dr[] = {-1,  0, 0, 1};
	int dc[] = { 0, -1, 1, 0};
	rep(i, 4) saiki(r+dr[i], c+dc[i], x);
}


int main()
{
	cin >> w >> h;
	while (w) {
		rep(i, h) rep(j, w) {
			char c;
			cin >> c;
			if (c == 'W') minit[i][j] = W;
			if (c == 'B') minit[i][j] = B;
			if (c == '.') minit[i][j] = 0;
		}
		rep(i, h) rep(j, w) {
			if (minit[i][j]) {
				int dr[] = {-1,  0, 0, 1};
				int dc[] = { 0, -1, 1, 0};
				rep (k, 4) saiki(i+dr[k], j+dc[k], minit[i][j]);
			}
		}
		int wn = 0, bn = 0;
		rep(i, h) rep(j, w) {
			if (m[i][j] == W) wn++;
			if (m[i][j] == B) bn++;
		}
		cout << bn << " " << wn << endl;
		cin >> w >> h;
		reset();
	}
}


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
int main(){
 int K;
 char S[101];
 scanf("%d",&K);
 scanf("%s",S);
 for(int i=0;i<strlen(S);i++){
  if(i<K)printf("%c",S[i]);
   else{
   printf("...");
   break;
   }
 }
 return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<int,int> pii;
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define REPb(j, d, c) for (int j = int(d); j >= int(c); j--)
#define ff first
#define ss second
#define pb push_back
#define len(x) int((x).size())

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	
	string s;
	cin>>s;
	
	// o shit this is more complex than I thought :thinking:
	
	if(c<d)
	{
	    // check there's no double rock in between
	    // A and C, and B and D
	    
	    bool works=true;
	    
	    REP(i,a,c-2)
	    {
	        if(s[i]==s[i-1] && s[i]=='#') works=false;
	    }
	
	    REP(i,b,d-2)
	    {
	        if(s[i]==s[i-1] && s[i]=='#') works=false;
	    }
	    
	    if(works) cout << "Yes" << endl;
	    else cout << "No" << endl;
	    return 0;
	}
	
	// A needs to jump over B
	
	bool works=false;
	
	REP(i,b-2,d-2)
	{
	    if(i<=0 || i+2>=n) continue;
	    
	    if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.') works=true;
	}
	
	if(works) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

/*---最大公約数 from 20190929---*/
long long gcd(long long x, long long y) { return y ? gcd(y,x%y) : x;}

int main(){
    int x;
    cin >> x;
    int g = gcd(360,x);
    int ans = 360/g;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int n, a[3][3];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++) cin >> a[i][j];
	cin >> n;
	for(int i = 0; i < n; i++){
		int id;
		cin >> id;
		for(int j = 0; j < 3; j++)
			for(int k = 0; k < 3; k++) a[j][k] = (a[j][k] == id) ? -1 : a[j][k];
	}
	for(int i = 0; i < 3; i++){
		int cntx = 0, cnty = 0;
		for(int j = 0; j < 3; j++){
			if(a[i][j] == -1) cntx++;
			if(a[j][i] == -1) cnty++;
		}
		if(cntx == 3 || cnty == 3){
			cout << "Yes\n";
			return 0;
		}
	}
	int cntx = 0, cnty = 0;
	for(int i = 0; i < 3; i++){
		if(a[i][i] == -1) cntx++;
		if(a[i][2 - i] == -1) cnty++;
	}
	if(cntx == 3 || cnty == 3) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}

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

int main() {
  int N,M,i;
  int64_t s=0;
  cin >> N >> M;
  vector<int> A(N),D(0);
  vector<pair<int,int>> BC(M);
  
  for(i=0; i<N; i++)
    cin >> A.at(i);
  sort(A.begin(),A.end());
  
  for(i=0; i<M; i++)
    cin >> BC.at(i).second >> BC.at(i).first;
  sort(BC.begin(),BC.end());
  
  for(i=M-1; i>=0; ) {
    if(D.size() < N) {
      D.push_back(BC.at(i).first);
      if(--BC.at(i).second<=0)
        i--;
    } else 
      break;
  }
  
  for(i=0; i<D.size(); i++) {
    if(D.at(i) >= A.at(i)) {
      A.at(i) = D.at(i);
      continue;
    }
    break;
  }
  
  for(int n : A)
    s += n;
      
  cout << s << endl;
}

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e9 + 1
ll maxval(ll wt[],ll val[],ll n, ll W)
{
    ll maxvalue = n*1000;
    ll dp[n+1][maxvalue+1];
    for(ll v = 0; v<=maxvalue;v ++)
    {
        dp[1][v] = inf;
    }
    dp[1][0] = 0;
    dp[1][val[0]] = wt[0];
    for(ll i=2;i<=n;i++)
    {
        for(ll v = 0;v<=maxvalue;v++)
        {
            dp[i][v] = dp[i-1][v];
            if(val[i-1] > v)
                continue;
            dp[i][v] = min(dp[i][v],wt[i-1] + dp[i-1][v - val[i-1]]);
        }
    }
    ll ans = 0;

    for(ll x = 0;x<=maxvalue;x++)
    {
        if(dp[n][x] <= W)
            ans = x;
    }
    return ans;
}
int main()
{
    ll n,W;
    cin>>n>>W;
    ll wt[100],val[100];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }

    cout<<maxval(wt,val,n,W);

    return 0;
}


Measured memory_bytes: 78336
def solve(placed, w1, w2):
  n = len(N) - len(placed)
  x = list(set(N) - set(placed))
  if x == []:
    a = tuple(placed)
    D1[a] = w1
    D2[a] = w2
    return
  
  for e in x:
    w = Food[e][0]
    if w2 > Food[e][1]: return
    a = w1 + w * n
    b = w2 + w
    solve(placed+[e], a, b)
  return

while 1:
  n = input()
  if n==0: break
  D1 = {}
  D2 = {}
  Name = {}
  Food = {}
  N = range(n)
  for i in N:
    a = raw_input().split()
    Food[i] = map(int, a[1:])
    Name[i] = a[0]
    
  solve([], 0, 0)
  
  Index, e = sorted(D1.items(), key = lambda x: x[1])[0]
  for e in list(Index)[::-1]:
    print Name[e]

Measured memory_bytes: 100444
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){

	ll n;
	cin >> n;
	ll a[n][3];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<3;j++){
			cin >> a[i][j];
		}
	}
	ll dp[n][3] = {0};
	for(ll j=0;j<3;j++){
		dp[0][j] = a[0][j];
	}

	for(ll i=1;i<n;i++){
		dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = a[i][2] + max(dp[i-1][0],dp[i-1][1]);
	}

	ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	cout << ans;
	return 0;
}

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

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


	string result = "";
	cin >> x >> a >> b;

	int A = x - a;
	if (A < 0)A *= -1;

	int B = x - b;
	if (B < 0)B *= -1;

	if (A < B) {
		result = "A";
	}
	else {
		result = "B";
	}


    cout << result<<endl;
}



Measured memory_bytes: 256
n, m = map(int, input().split())

student = []
for i in range(n):
    student.append(tuple(map(int, input().split())))

check = []
for i in range(m):
    check.append(tuple(map(int, input().split())))

for i in student:
    min_idx = 0
    min_k = abs(i[0]-check[0][0]) + abs(i[1]-check[0][1])
    for j in range(1, len(check)):
        k = abs(i[0]-check[j][0]) + abs(i[1]-check[j][1])
        if k < min_k:
            min_k = k
            min_idx = j

    print(min_idx+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n;
string s;

int main(){
       cin >> n;
       int ans = 0;
       for(int i = 0; i < 4; i++){
              if(n%10 == 2) ++ans;
              n /= 10;
       }

       cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
using namespace boost::multiprecision; // for use cpp_int
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    cpp_dec_float_100 a;
    cpp_dec_float_100 b;
    cin >> a >> b;
    a *= b;
    string s = a.str();
    string ans = "";
    rep(i, len(s)) {
        if (s[i] == '.') {
            break;
        }
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}


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

#define ALL(x) x.begin(), x.end()

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

	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];

	sort(ALL(v));

	int ans = v[n / 2] - v[n / 2 - 1];
	
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
  int X,A,B,i;
  cin>>B>>X>>A;
  i=A-B;
  if(i<=0)
    {
      cout<<"delicious"<<endl;
    }
  if(i>0 && i<=X)
    {
      cout<<"safe"<<endl;
    }
  if(i>X)
    {
      cout<<"dangerous"<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, time;
  cin >> n >> time;
  int t[n];
  cin >> t[0];
  int total = 0;
  for(int i = 0; i < n -1; i++){
    cin >> t[i + 1];
    total += min(time, t[i + 1] - t[i]);
  }
  cout << total + time << endl;
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
S = input()

pos = 0
minpos = 0
mini = 0

for i in range(N):
  if S[i] == "W":
    pos += 1
  else:
    pos -= 1
  if pos < minpos:
    minpos = pos
    mini = i

s1 = S[0:mini].count("W")
s2 = S[mini+1:N].count("E")
print(s1+s2)

Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int y = 1;
	for (int i = 1; i <= x; i++)y *= i;
	return y;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}
int two(int x) {
	int cnt = 0;
	if (x == 0)return 1;
	while (x > 1) {
		x /= 2;
		cnt++;
	}
	return cnt;
}
int combi(int x, int y) {
	int cnt = 1;
	for (int i = x; x - i < y; i--)cnt *= i;
	return cnt / kai(y);
}
/*Library End!*/

signed main() {
	int n[3];
	cin >> n[0] >> n[1] >> n[2];
	sort(n, n + 3);
	cout << n[2] * 10 + n[1] + n[0] << endl;
end:;
	system("PAUSE");
	return 0;
}



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


int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double Ax = A * cos(-(H/12.0+M/720.0)*2*acos(-1));
  double Ay = A * sin(-(H/12.0+M/720.0)*2*acos(-1));
  double Bx = B * cos(-M/60.0*2*acos(-1));
  double By = B * sin(-M/60.0*2*acos(-1));
  cout << fixed << setprecision(10) << sqrt(pow(Ax-Bx, 2.0) + pow(Ay-By, 2.0)) << endl;
  return 0;
}


Measured memory_bytes: 4100
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

struct edge{long long to,cost;};
const long long INF=1e17;
const int MAX_V=100000;
int V,E,r;
vector<edge> G[MAX_V];
long long d[MAX_V];
typedef pair<long,long>P;

void dijkstra(int s){
    priority_queue<pair<long,long>,vector<pair<long,long>>,greater<pair<long,long>>> que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(pair<long,long>(0,s));
    
    while(!que.empty()){
        pair<long,long> p=que.top();que.pop();
        long long v=p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pair<long,long>(d[e.to],e.to));
            }
        }
    }
}

int main(){
    cin>>V>>E>>r;
    int s,t,dist;
    for(int i=0;i<E;i++){
        cin>>s>>t>>dist;
        edge j;
        j.to=t;j.cost=dist;
        G[s].push_back(j);
    }
    //fill(d,d+V,INF);
    //cout<<d[0]<<endl;
    dijkstra(r);
    
    for(int i=0;i<V;i++){
        if(d[i]==INF)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    
    return 0;
    
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	cin >> S;
	string T;
	vector<ll> kan, kan2;
	REP(i, S.size()){
		if(S[i]!='x') T.push_back(S[i]), kan.push_back(i);
	}
	REP(i, T.size()/2){
		if(T[i]!=T[T.size()-1-i]){
			cout << -1 << endl;
			return 0;
		}
	}
	ll res = 0;
	if(kan.empty()){
		cout << 0 << endl;
		return 0;
	}
	kan2.push_back(kan[0]);
	REP(i, kan.size()-1){
		kan2.push_back(kan[i+1]-kan[i]-1);
	}
	kan2.push_back(S.size() - 1 - kan[kan.size()-1]);
	REP(i, kan2.size()/2){
		res += abs(kan2[i] - kan2[kan2.size()-1-i]);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	static long a,b;
	static Scanner cin = new Scanner(System.in);
	public static void main(String[] args) {
		while(read()){
			System.out.println(gcd(a,b)+" "+lcm(a,b));
		}
	}

	private static boolean read() {
		if(!cin.hasNext())
        	return false;
        a = cin.nextLong();
        b = cin.nextLong();
		return true;
	}

	private static long gcd(long a, long b) {
		if(b == 0)
			return a;
		else
			return gcd(b,a%b);
	}

	private static long lcm(long a, long b) {
		return a*b/gcd(a,b);
	}
}

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			final int Q = sc.nextInt();
			
			int[][] from_x_to = new int[N][N];
			
			for(int i = 0; i < M; i++) {
				final int l = sc.nextInt() - 1;
				final int r = sc.nextInt() - 1;
				
				from_x_to[l][r]++;
			}
			
			for(int i = 0; i < N; i++) {
				for(int j = 1; j < N; j++) {
					from_x_to[i][j] += from_x_to[i][j - 1];
				}
			}
			
			for(int q = 0; q < Q; q++) {
				final int l = sc.nextInt() - 1;
				final int r = sc.nextInt() - 1;
				
				long cnt = 0;
				for(int x = l; x <= r; x++) {
					cnt += from_x_to[x][r];
				}
				System.out.println(cnt);
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

int main(){
	int n,x,t;
	cin >> n >> x >> t;
	int ans = t* ((n + x - 1) / x);
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3616