akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>

using namespace std;

int main() {
    int n;  cin >> n;
    map<string,int> m;
    int c = 0;
    for (int i = 0; i < n; i++) {
        string s;   cin >> s;
        m[s]++;
        if (m[s] > c)
            c = m[s];
    }

    for (auto ite = m.begin(); ite != m.end(); ite++) {
        if ((*ite).second == c)
            cout << (*ite).first << endl;
    }

    return 0;
}

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

const int maxn=1e2+10;
int n;
char a[maxn],b[maxn];

int main(){
	cin>>n>>a>>b;
	for(int i=0;i<=n;++i){
		for(int j=i;j<n;++j)
			if(a[j]!=b[j-i])
				goto wrong;
		cout<<n+i<<endl;
		return 0;
		wrong:;
	}
	return 0;
}

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

int main() {
    Int a, b, c; cin >> a >> b >> c;
    Int d = c - a - b;
    if ((Int)4 * a * b < (Int)d*d && d>0)
        puts("Yes");
    else
        puts("No");
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

		if (b - a + 1 >= k * 2) {
			for (int index = a ; index < a + k ; index++) {
				System.out.println(index);
			}
			for (int index = k ; index > 0 ; index--) {
				System.out.println(b - index + 1);
			}
		} else {
			for (int index = a ; index < b + 1; index++) {
				System.out.println(index);
			}
		}
	}
}

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

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {

            //int[] line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int n = int.Parse(Console.ReadLine());
            var list = new List<int>();

            for(int i = 0;i < n; i++)
            {
                int p = int.Parse(Console.ReadLine());
                list.Add(p);
            }
            int sum = list.Sum();
            sum -= list.Max() / 2;
            Console.WriteLine(sum);

            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 11220
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int d[1 << 22];
void p(int s, int n)
{
	for (int i = n-1; i >= 0; --i)
	{
		int t = (s & (3 << 2*i)) >> 2*i;
		if (t == 1)
			putchar('r');
		else if (t == 2)
			putchar('g');
		else if (t == 3)
			putchar('b');
		else
			putchar('*');
	}
}
int main()
{
	char buf[16];
	while (cin.getline(buf, sizeof(buf)), *buf != '0')
	{
		int n = strlen(buf);
		int initial = 0;
		for (int i = 0; i < n; ++i)
		{
			int t;
			if (buf[i] == 'r')
				t = 1;
			else if (buf[i] == 'g')
				t = 2;
			else
				t = 3;

			initial = (initial << 2) | t;
		}

		memset(d, -1, sizeof(d));
		d[initial] = 0;
		queue<int> state;
		state.push(initial);
		int ans = -1;
		while (!state.empty())
		{
			int s = state.front();
			state.pop();
			bool ok = true;
			for (int i = 0; i < n-1; ++i)
			{
				int r = (s & (3 << 2*i)) >> 2*i;
				int l = (s & (3 << 2*(i+1))) >> 2*(i+1);
				bool same = l == r;
				ok &= same;
				if (!same)
				{
					int color = -1;
					for (int j = 1; j <= 3; ++j)
						if (j != l && j != r)
							color = j;
					int next = s & ~(15 << 2*i) | (5*color << 2*i);
					if (d[next] == -1)
					{
						d[next] = d[s] + 1;
						state.push(next);
					}
				}
			}
			if (ok)
			{
				ans = d[s];
				break;
			}
		}
		if (ans != -1)
			printf("%d\n", ans);
		else
			puts("NA");
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long A = scan.nextInt();
        long V = scan.nextInt();
        long B = scan.nextInt();
        long W = scan.nextInt();
        long T = scan.nextInt();
        long diff = Math.abs(A-B);
        long speed = V - W;
        if (speed <= 0) {
            System.out.println("NO");
            return;
        }
        long time = diff / speed;
        if (diff % speed != 0) {
            time += 1;
        }
        String ans = time <= T ? "YES" : "NO";
        System.out.println(ans);
    }
}


Measured memory_bytes: 35512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a=0,b=0,c=0,d=0;
  cin>>n;
  string s;
  for(int i=0;i<n;i++) {
    cin>>s;
    if(s=="AC") a++;
    else if(s=="WA") b++;
    else if(s=="TLE") c++;
    else d++;
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
}

Measured memory_bytes: 3572
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    int N,K;
    cin>>N>>K;
    int c=0;
    while(N!=0){
        N/=K;
        c++;
    }
    cout<<c<<endl;

}


Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

int main () {
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> v[i];
    }
    std::sort(v.begin(), v.end());
    double ans = (v[0] + v[1]) / 2.0;
    for (int i = 2; i < n; i++)
    {
        ans = (ans + v[i]) / 2;
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;
typedef vector<vi> vvi;

int lp;
vi dist;

int dfs(vvi &gf, int n) {
	int p = 0;
	for (int i = 0; i < gf[n].size(); i++) {
		if (dist[gf[n][i]] == -1)
			p = max(p, 1 + dfs(gf, gf[n][i]));
		else
			p = max(p, 1 + dist[gf[n][i]]);
	}
	dist[n] = p;
	return dist[n];
}

int main() {FIN

	int n, m, x, y, i;
	cin >> n >> m;
	vvi gf(n);
	vi in(n);

	for (i = 0; i < m; i++) {
		cin >> x >> y;
		x--, y--;
		gf[x].push_back(y);
		in[y]++;
	}

	lp = 0;
	dist = vi(n, -1);
	for (i = 0; i < n; i++) {
		if (in[i] == 0)
			lp = max(lp, dfs(gf, i));
	}

	cout << lp << "\n";

	return 0;
}

Measured memory_bytes: 14096
import java.util.Scanner;


public class Main {
	
	public static final double EPS = 1e-06;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int v1 = sc.nextInt();
			
			if(v1 == 0){
				break;
			}
			
			int[] degs1 = new int[v1];
			int sum1 = 0;
			for(int i = 0; i < v1 - 1; i++){
				final int d = sc.nextInt();
				sum1 += d;
				degs1[i] = d;
			}
			degs1[v1 - 1] = 360 - sum1;
			
			final int v2 = sc.nextInt();
						
			int[] degs2 = new int[v2];
			int sum2 = 0;
			for(int i = 0; i < v2 - 1; i++){
				final int d = sc.nextInt();
				sum2 += d;
				degs2[i] = d;
			}
			degs2[v2 - 1] = 360 - sum2;
			
			double menseki1 = 0;
			for(int i = 0; i < v1; i++){
				menseki1 += (Math.sin((degs1[i] / 360.0) * Math.PI) * (Math.cos((degs1[i] / 360.0) * Math.PI)));
			}
			
			double menseki2 = 0;
			for(int i = 0; i < v2; i++){
				menseki2 += (Math.sin((degs2[i] / 360.0) * Math.PI) * (Math.cos((degs2[i] / 360.0) * Math.PI)));
			}
			
			if(Math.abs(menseki1 - menseki2) < EPS){
				System.out.println("0");
			}else if(menseki1 > menseki2){
				System.out.println("1");
			}else{
				System.out.println("2");
			}
		}
		
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define N 40001
using namespace std;
typedef long long ll;
struct po{ll h,a,d,s;};

ll n;
po A[N];
ll hp,a,d,s,sum;
bool compare(po x,po y){
  if(a-x.d<=0||a-y.d<=0)return 0;

  ll cnt1=1+(x.h-1)/(a-x.d),cnt2=1+(y.h-1)/(a-y.d);
  ll X=cnt1*(x.a-d)+(cnt1+cnt2)*(y.a-d);
  ll Y=cnt2*(y.a-d)+(cnt1+cnt2)*(x.a-d);
  return X<Y;
}


ll solve(){
  sort(A,A+n,compare);
  for(int i=0;i<n;i++){
    po t=A[i];
    if(hp<=0)return -1;
    if(a-t.d<=0) return -1;
    ll cost=((t.h-1)/(a-t.d))*sum;
    sum-=t.a-d;
    hp-=(cost+sum);
    
  }
  if(hp<=0)return -1;
  return hp;
}

int main(){
  cin>>n;
  cin>>hp>>a>>d>>s;
  
  ll ofs=0;
  for(int i=0;i<n;i++){
    po &t=A[i];
    cin>>t.h>>t.a>>t.d>>t.s;
    if(t.a-d<=0){n--,i--;continue;};
    if(t.s>s) ofs+=(t.a-d);
    sum+=(t.a-d);
  }
  
  ll H = hp;
  hp-=ofs;
  ll ans= H-solve();
  if(H<ans)cout<<-1<<endl;
  else cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
/*
ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}*/

int n;
vl a;

int main(){
	cin>>n;
	a=vl(n);
	for(auto &i:a) cin>>i;
	ll t=1000;
	for(int i=1;i<n;i++) if(a[i-1]<a[i]){
		t=t%a[i-1]+t/a[i-1]*a[i];
	}
	cout<<t<<endl;
}

Measured memory_bytes: 3588
#include <string>
#include <iostream>
using namespace std;
int main()
{
  int n;
  string s;
  cin>>n;
  cin>>s;
  int occurrences = 0;
  std::string::size_type pos = 0;
  std::string target = "ABC";
   while ((pos = s.find(target, pos )) != std::string::npos) {
          ++ occurrences;
          pos += target.length();
   }
   std::cout << occurrences << std::endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int a,b; cin>>a>>b;
  int ans = 0;
  if(b % a == 0) {
    ans = a + b;
  } else {
    ans = b - a;
  }
  cout << ans << endl;
}


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

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

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

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  int sizeA = a.length();
  int sizeB = b.length();

  if (a == b) {
    cout << "EQUAL" << endl;
  } else if (sizeA == sizeB) {
    if (a > b) {
      cout << "GREATER" << endl;
    } else {
      cout << "LESS" << endl;
    }

  } else if (sizeA > sizeB) {
    cout << "GREATER" << endl;
  } else {
    cout << "LESS" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N = d_in()

cand = [[i,j,0] for i in range(0, 101) for j in range(0, 101)]

info = []
for _ in range(N):
    info.append(ds_in())

info.sort(key=lambda x: x[2], reverse=True)

for i in range(len(cand)):
    x, y, h = info[0]
    cand[i][2] = h + abs(x-cand[i][0]) + abs(y-cand[i][1])

if N > 1:
    idx = 1
    while len(cand) > 1 and idx < N:
        temp = []
        x, y, h = info[idx]
        for c in cand:
            if h == max(0, c[2] - abs(x-c[0]) - abs(y-c[1])):
                temp.append(c)
        cand = temp.copy()
        idx += 1

print(cand[0][0], cand[0][1], cand[0][2])


Measured memory_bytes: 4464
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))

using namespace std;

using pii =  pair<int, int>;
using ll = long long;

#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int N;
int a[100004];

int main(){
  cin.tie(0);
  
  cin>>N;
  REP(i, N)cin>>a[i];

  int p=0, q=0, r=0; // 1 3, 2, 4

  REP(i, N) {
    if(a[i]%2==1)p++;
    else if(a[i]%4==0)r++;
    else q++;
  }
  
  if(q>0)p++;

  if(p-1<=r)cout<<"Yes";
  else cout<<"No";
  
  cout<<endl;

  return 0;
}


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

typedef long long ll;

int main(void)
{
    string s1,s2,s3;
    int num1,num2;
    cin>>s1>>s2;
    cin>>num1>>num2;
    cin>>s3;

    if(s3.compare(s1) == 0)
        cout<<num1-1<<" "<<num2<<"\n";
    else
        cout<<num1<<" "<<num2-1<<"\n";

    return 0;
}


Measured memory_bytes: 256
def sieve(n):
    is_prime = [True for _ in range(n + 1)]
    is_prime[0] = False

    for i in range(2, n + 1):
        if is_prime[i - 1]:
            j = 2 * i
            while j <= n:
                is_prime[j - 1] = False
                j += i
    table = [i for i in range(1, n + 1) if is_prime[i - 1]]
    return is_prime, table


X = int(input())
table = sieve(100003 + 100)[1]
for t in table:
    if t >= X:
        print(t)
        break


Measured memory_bytes: 4324
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 300005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,n,d;
	cin>>n>>d;
	ll ar[n+1][2];
	for(i=1;i<=n;i++){
		cin>>ar[i][0]>>ar[i][1];
	}

	ll an=0;
	for(i=1;i<=n;i++){
		if(ar[i][0]*ar[i][0]+ar[i][1]*ar[i][1]<=d*d){
			an++;
		}
	}
	cout<<an;

	return 0;	
}

Measured memory_bytes: 6764
#include<stack>
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
	while(1){
		char s[128]; fgets(s,128,stdin);
		int n=strlen(s);
		if(s[n-1]=='\n') s[--n]='\0';
		if(strcmp(s,".")==0) break;

		bool ok=true;
		stack<char> St;
		for(int i=0;i<n;i++){
			if(s[i]=='(') St.push(s[i]);
			if(s[i]=='[') St.push(s[i]);
			if(s[i]==')') if(St.empty() || St.top()=='['){ ok=false; break; } else St.pop();
			if(s[i]==']') if(St.empty() || St.top()=='('){ ok=false; break; } else St.pop();
		}
		if(!St.empty()) ok=false;

		puts(ok?"yes":"no");
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define pb(z) push_back(z)
#define ff first
#define ss second
#define pi(a,b) make_pair(a,b)
#define pii pair<ll,ll>
#define T int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define input(v,n) vector<int>v;for(int i=0;i<n;i++){int x;cin>>x;v.push_back(x);}
#define debugg(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;


const int inf    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 1e9+7;
const int mx     = 2e5+5;
//vector<int>v;
//for(int i=0; i<n; i++)
//{
//    int x;
//    cin>>x;
//    v.push_back(x);
//}


int main()
{
    IOS
    vector<int>a,b,c;
    map<int,int>mp;
    int n,k;
    cin>>n;
    int cnt1=0,cnt2=0;
    rep(i,0,n)
    {
        int t,x,y;
        cin>>t;
        a.pb(t);
    }
    rep(i,0,n)
    {
        int t,x,y;
        cin>>t;
        b.pb(t);
    }
    rep(i,0,n-1)
    {
        int t,x,y;
        cin>>t;
        c.pb(t);
    }
    int tmp=-2,sum=0;
    rep(i,0,n)
    {
        sum+=b[a[i]-1];
        if(tmp+1==a[i])
            sum+=c[tmp-1];
        tmp=a[i];
    }
    cout<<sum<<endl;

}



Measured memory_bytes: 3628
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=924844033;
#define N 1055050

ll n,m,k;
ll a,b;
char c[410][410];
ll mem[710][710];
vector<vector<ll>> dp(410,vector<ll>(410,-1));
ll dfs(int x,int y);
ll calc(int x){
    rep(i,n*2+2)rep(j,n+2)mem[i][j]=0;
    rep2(i,1,n){
        rep2(j,1,n){
            if(c[x][i]==c[x+1][j]){
                mem[i-j+n][i]++;
            }
        }
    }
    rep(i,2*n+2){
        rep(j,n+2){
            mem[i][j+1]+=mem[i][j];
        }
    }
    rep(i,410){
        dp[i]=vector<ll>(410,-1);
    }
    return dfs(n,n);
}
ll dfs(int x,int y){
    if(x<0||y<0)return 0;
    if(x==0&&y==0)return 0;
    ll now=mem[y-x+n][n]-mem[y-x+n][n-x];
    if(dp[x][y]!=-1)return dp[x][y];
    return dp[x][y]=now+min(dfs(x-1,y),dfs(x,y-1));
}
main(){
    n=in(),m=in();
    rep(i,n){
        string s;
        cin>>s;
        rep(j,m)c[j][n-i]=s[j];
    }
    ll ans=0;
    rep(i,m-1){
        ans+=calc(i);
    }
    cout<<ans;
}


Measured memory_bytes: 5760
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
void solve(){

}

int main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int n,k;
    cin>>n>>k;
    vi vec(n+1,0);
    while(k--){
        int d;
        cin>>d;
        while(d--) {
            int a;
            cin>>a;
            vec[a]=1;
        }
    }
    int cnt=0;
    rep1(i,1,n) cnt+=(vec[i]==0);
    cout<<cnt<<endl;

     return 0;

}
///Alhamdulillah



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
  int ans=10000000;
  vector<int>w(n);
  for(int i=0;i<n;i++)
    cin>>w.at(i);
  for(int i=1;i<n;i++)
  {
    int ans1=0,ans2=0;
    for(int j=0;j<i;j++)
    {
      ans1+=w.at(j);
      
    }
    for(int l=i;l<n;l++)
    {
      ans2+=w.at(l);
     
    }
    ans=min(ans,abs(ans1-ans2));
  }
  cout<<ans<<endl;
}
    
    
      
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int sum (int n) {
    int ret = 0;
    while (n != 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << (n % sum(n) == 0 ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int n, d, x;
	std::cin >> n >> d >> x;
	std::vector<int> a(n);
	int sum = x;
	for (int i = 0;i < n;++i) {
		std::cin >> a[i];
		if (d % a[i] == 0) {
			sum += (d / a[i]);
		}
		else {
			sum += d / a[i] + 1;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 256
#if 0

#endif
#include <iostream>
#include <memory>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <queue>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define INF (1 << 30)
using namespace std;
using ll = long long;
int A, B, C;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> A >> B >> C;

    cout << min(B / A, C) << endl;

    return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

int main()
{
  fastio;
  int x; cin >> x;
  long res = 0;
  res += (x / 500) * 1000;
  x %= 500;
  res += (x / 5) * 5;
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int K, A, B;
  cin >> K >> A >> B;
  
  rep(i, 1001) {
    if(A <= K * i && K * i <= B) {
      fin("OK");
      return 0;
    }
  }
  fin("NG");
  return 0;
}

Measured memory_bytes: 3648
#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() {
  int x, y, z;
  cin >> x >> y >> z;

  cout << z << " " << x << " " << y;

  return 0;
}


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

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    long long ans;
    ans = (long long)(N / K) * (N / K) * (N / K);
    if (K % 2 == 0) {
        int k = K / 2;
        int l = N / k - N / K;
        ans += (long long)l * l * l;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    vector<int> a(3);
    REP(i, 3) cin >> a[i];
    
    sort(ALL(a));

    cout << (a[1] - a[0]) + (a[2] - a[1]) << endl;

    return 0;    

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int g[100]={0};
int main()
{
	for(int i=1;i<=3;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x]++;
		g[y]++;
	}
	for(int i=1;i<=4;i++)
	{
		if(g[i]==3)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES";
}

Measured memory_bytes: 256
#line 2 "solve.cpp"
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, int> pii;
typedef tuple<int, int, int> iii;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
void check_input(){
    assert(cin.eof() == 0);
    int tmp; cin >> tmp; 
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H *//*}}}*/

signed main() {
    //input
    int a,b,c,d;cin>>a>>b>>c>>d;
    check_input();

    //solve
    while(1){
        c -= b;
        if (c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a<=0){
            cout << "No" << endl;
            return 0;
        }
    }

    return 0; 
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    int n;cin>>n;
    vector<ll> h(n+10),dp(n+10,LINF);
    for(int i=0;i<n;i++)cin>>h[i];
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1)dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}   


Measured memory_bytes: 1792
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,r;
    cin>>n>>r;
    if(n<10)
        r+=(10-n)*100;
    cout<<r;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int N;
        cin >> N;
        vector<Int> H(N);
        vector<Int> d(N - 1);
        for (int i = 0; i < N; ++i) {
            cin >> H[i];
        }
        for (int i = 0; i + 1 < N; ++i) {
            d[i] = H[i + 1] - H[i];
        }

        int ans = 0;
        int L = 0;
        int R = 0;
        int p = 0, m = 0, z = 0;
        while (R + 1 < N) {
            if (L == R) {
                if (H[L] < H[L + 1]) {
                    L++;
                    R++;
                } else {
                    R++;
                }
            } else {
                if (H[R] < H[R + 1]) {
                    L++;
                } else {
                    R++;
                }
            }
            chmax(ans, R - L);
        }

        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1792
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ",trim(fgets(STDIN)));
  $b = explode(" ",trim(fgets(STDIN)));
  $c = explode(" ",trim(fgets(STDIN)));
  
  $happy = 0;
  for($i=0; $i<$n; $i++){
    $happy += $b[$a[$i]-1];
    if($i > 0 && $a[$i]-1 == $a[$i-1]){
      $happy += $c[$a[$i]-2];
    }
  }

  echo $happy."\n";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for(ll i = (ll)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
using namespace std;
int main(){
    ll a, b;
    cin >> a >> b;
    ll c[a];
    ll d = 0;
    rep(i , a){
        cin >> c[i];
        d += c[i];
    }
    sort(c, c + a);
    ll cnt = 0;
    repd(i, a){
        if(cnt < b){
            d -= c[i];
            cnt++;
        }
        else break;
    }
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char mark = s.charAt(0);
        int count = 0;
        for(int i = 1;i < s.length();i++){
            if(mark != s.charAt(i)){
                count++;
                mark = s.charAt(i);
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 24404
package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
)

const (
	WHITE = "."
	BLACK = "#"
)

type Surface []Line
type Line string

func (surface Surface) deleteLine() Surface {
	var stringSlice Surface
	for _,val := range surface {
		if val.contains("#") {
			stringSlice = append(stringSlice,val)
		}
	}
	return stringSlice
}

func (surface Surface) horizonToVertical() Surface {
	vertical := make(Surface,len(surface.String()))
	for _,val := range surface {
		str := strings.Split(val.String(),"")
		for i,v := range str {
			vertical[i] += Line(v)
		}
	}

	return vertical
}

func (surface Surface) String() string {
	var str string
	for _,val := range surface {
		str += fmt.Sprintln(val)
	}
	return strings.Join(strings.Split(str,"")[:len(str)-1],"")
}

func (line Line) contains(str string) bool {
	return strings.Contains(line.String(),str)
}


func (line Line) String() string{
	return fmt.Sprint(string(line))
}

func main() {
	var H,W int
	var stringSlice Surface

	fmt.Scan(&H)
	fmt.Scan(&W)

	input := bufio.NewScanner(os.Stdin)
	
	for index := 0; index < H; index++ {
		input.Scan()
		stringSlice = append(stringSlice,Line(input.Text()))
	}
	
	fmt.Println(stringSlice.deleteLine().horizonToVertical().deleteLine().horizonToVertical())
}


Measured memory_bytes: 6400
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

const int mxn = 100005;
const int mod = 1000000007;

int n, m, ans;

signed main() {
	scanf("%d%d", &n, &m);

	if (abs(n - m) > 1)
		return puts("0"), 0;

	if (n == m)
		ans = 2;
	else
		ans = 1;

	for (int i = 1; i <= n; ++i)
		ans = 1LL * ans * i % mod;

	for (int j = 1; j <= m; ++j)
		ans = 1LL * ans * j % mod;

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[N];
  int B[N];
  int C[N-1];
  int ansB=0;
  int ansC=0;
  for(int i=1;i<N+1;i++){
    cin>>A[i];
  }
  for(int i=1;i<N+1;i++){
    cin>>B[i];
    ansB+=B[i];
  }
  for(int i=1;i<N+1;i++){
    cin>>C[i];
  }
  
  for(int i=1;i<N;i++)
    if(A[i+1]-A[i]==1){
      ansC+=C[A[i]];
    }
  int ans=ansB+ansC;
  cout<<ans<<endl;
}
  

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int s,w;
    cin>>s>>w;
    if(s<=w) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		char[] a=fs.next().toCharArray();
		System.out.println(a[2]==a[3] && a[4]==a[5] ? "Yes":"No");
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

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

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

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

	}

}


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

int main(){
  int N; cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++) cin>>a.at(i);
  
  int count4=0;
  int count2=0;
  for(int i=0;i<N;i++){
    int a_i=a.at(i);
    if(a_i%4==0)
      count4++;
    else if(a_i%2==0)
      count2++;
  }
  
  N-=count4*2;
  N-=count2;
  
  if(N==1 && count2==0)
    cout<<"Yes";
  else if(N>0)
    cout<<"No";
  else
    cout<<"Yes";
}
    

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){
  string S;
  cin>>S;
  if(S[0]=='Y'&&S[1]=='A'&&S[2]=='K'&&S[3]=='I')
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

vector<vector<int> > g;

void go(int u, int w, vector<int> &d, int p = -1) {
    d[u] = w;
    for(auto v : g[u]) {
        if(v != p) {
            go(v, w+1, d, u);
        }
    }
}

int main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif

    int n; cin >> n;
//    cout << "asdasd" << endl;
    g.assign(n+1, vector<int>());
    for(int i = 1; i < n; i++) {
        int a, b; cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> d1(n+1), d2(n+1);
    go(1, 0, d1);
    go(n, 0, d2);

    int wina = 0, winb = 0;
    for(int i = 1; i <= n; i++) {
        if(d1[i] <= d2[i])
            wina++;
        else
            winb++;
    }

//    cout << wina << " " << winb << endl;

    if(wina > winb) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

}


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

const int MAXN = 400010;
const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
struct P { int v, t; } ps[MAXN];
int bak;
int n, m, xs[MAXN], ys[MAXN];
int li[MAXN], tb;
typedef std::vector<int> VI;
VI hav[MAXN];
int tree[MAXN];
void mdf(int x, int v) {
	for (; x <= tb; x += x & -x) reduce(tree[x] += v - mod);
}
int qry(int x) {
	int res = 0;
	for (; x; x &= x - 1) reduce(res += tree[x] - mod);
	return res;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1, t; i <= n; ++i)
		std::cin >> t, ps[++bak] = (P) {t, 0};
	for (int i = 1, t; i <= m; ++i)
		std::cin >> t, ps[++bak] = (P) {t, 1};
	std::sort(ps + 1, ps + 1 + bak, [] (P a, P b) { return a.v < b.v; });
	int lst = 0;
	memset(xs, -1, bak + 1 << 2);
	memset(ys, -1, bak + 1 << 2);
	for (int i = 1; i <= bak; ++i)
		if (ps[i].t == 1) lst = ps[i].v;
		else if (lst) xs[i] = ps[i].v - lst;
	lst = 0;
	for (int i = bak; i; --i)
		if (ps[i].t == 1) lst = ps[i].v;
		else if (lst) ys[i] = lst - ps[i].v;
	for (int i = 1; i <= bak; ++i)
		if (xs[i] != -1 && ys[i] != -1)
			li[++tb] = xs[i], li[++tb] = ys[i];
	li[++tb] = 0;
	std::sort(li + 1, li + 1 + tb);
	tb = std::unique(li + 1, li + 1 + tb) - li - 1;
	for (int i = 1; i <= bak; ++i)
		if (xs[i] != -1 && ys[i] != -1)
			hav[std::lower_bound(li + 1, li + 1 + tb, xs[i]) - li].push_back(ys[i]);
	mdf(1, 1);
	for (int i = 1; i <= tb; ++i) {
		std::sort(hav[i].begin(), hav[i].end(), std::greater<int> ());
		hav[i].erase(std::unique(hav[i].begin(), hav[i].end()), hav[i].end());
		for (auto t : hav[i]) {
			int at = std::lower_bound(li + 1, li + 1 + tb, t) - li;
			mdf(at, qry(at - 1));
		}
	}
	std::cout << qry(tb) << std::endl;
	return 0;
}


Measured memory_bytes: 20992
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[2100];

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	printf("%d\n",c*10+b+a);
}


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

using namespace std;
typedef long long ll;

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

  ll a[N][3];
  for (int i = 0; i < N; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }

  ll maxv = 0;
  for (int i = 0; i < 8; i++) {
    vector<ll> vec;
    for (int j = 0; j < N; j++) {
      ll S = 0;
      for (int k = 0; k < 3; k++) {
        if (i / (1 <<k) % 2 == 0) {
          S += a[j][k];
        } else {
          S -= a[j][k];
        }
      }
      vec.push_back(S);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    ll total = 0;
    for (int l = 0; l < M; l++) {
      total += vec[l];
    }
    maxv = max(maxv, total);
  }

  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 256
//
// Created by watemus on 09.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    cout << fixed << setprecision(228);
    ld r;
    cin >> r;
    cout << acos(-1) * r * 2 << endl;
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }



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

	if (n == 1) {
		cout << "Yes" << endl;
		cout << 2 << endl;
		cout << 1 << " " << 1 << endl;
		cout << 1 << " " << 1 << endl;
		return 0;
	}
	int k = 2;
	while (k*k < n*2) {
		if (k*(k + 1) == n*2) {
			cout << "Yes" << endl;
			int a = k + 1;
			int b = k;
			vector<vector<int>> x(a);
			int r = 0;
			int s = 0;
			FOR(i, 1, n + 1) {
				x[r].push_back(i);
				x[s + 1].push_back(i);
				s++;
				if (s == b) {
					if (i == n) {
						break;
					}
					r++;
					s = x[r].size();
				}
			}
			cout << a << endl;
			rep(i, a) {
				printf("%d ", x[i].size());
				rep(j, b) {
					if (j != b - 1) {
						printf("%d ", x[i][j]);
						//cout << x[i][j]<<" ";
					}
					else {
						printf("%d\n", x[i][j]);
						//cout << x[i][j] << endl;
					}
				}
			}
			
			return 0;
		}
		k++;
	}
	cout << "No" << endl;
	return 0;




}

Measured memory_bytes: 2304