akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string w;
    cin>>w;
    
    for(int i=0;i<w.size();i++){
        if(w[i]>='A' && w[i]<='Z'){
            w[i]=w[i]+32;
        }
    }
    
    string str;
    int ok=0;
    
    while(cin>>str){
        if(str=="END_OF_TEXT") break;
        
        for(int i=0;i<str.size();i++){
            if(str[i]>='A' && str[i]<='Z'){
                str[i]=str[i]+32;
            }
        }
        if(w==str) ok++;
    }
    
    cout<<ok<<"\n";
    
    return 0;
    
} 


Measured memory_bytes: 3160
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

// vars
int n, m;
vector<int> a;
void input(){
    cin >> n >> m;
    a.resize(n);
    REP(i, n){
        cin >> a[i];
    }
}

void solve(){
    int s = 0;
    REP(i, n){
        s += a[i];
    }
    int cnt = 0;
    if(s % 4 == 0){
        int k = s / (4 * m);
        REP(i, n){
            if(a[i] >= k){
                cnt++;
            }
        }
    }
    else {
        int k = s / (4 * m);
        REP(i, n){
            if(a[i] > k){
                cnt++;
            }
        }
    }
    if(cnt >= m){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;
ll h[100005];

ll myceil(ll a, ll b){
    if(a<0)
        return 0;
    return (a/b)+((a%b)>0);
}

int main(){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    a-=b;
    for(int i = 0; i<n; i++)
        scanf("%lld",&h[i]);
    int s = 1,e=1000000000,ans=-1;
    while(s<=e){
        ll m = (s+e)/2;
        ll amt = 0;
        for(int i = 0; i<n; i++)
            amt+=myceil(h[i]-(m*b),a);
        if(amt<=m){
            ans = m;
            e = m-1;
        }else
            s = m+1;
    }
    printf("%d\n",ans);
    return 0;
}

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

void fnInput(vector<int> &rvnTrg, vector<int> &rvnSch)
{
  int nTrgCnt;
  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];

  int nSchCnt;
  cin >> nSchCnt;

  rvnSch.resize(nSchCnt);
  for (int i = 0; i < nSchCnt; i++)
    cin >> rvnSch[i];
}

void fnBinSch(const vector<int> &cnrvnTrg, const vector<int> &cnrvnSch, int &rnFnd)
{
  for (int i = 0; i < cnrvnSch.size(); i++)
  {
    int nLow  = 0;
    int nHigh = cnrvnTrg.size();
    while (nLow < nHigh)
    {
      int nMid = (nLow + nHigh) / 2;
      if (cnrvnSch[i] == cnrvnTrg[nMid])
      {
        rnFnd++;
        break;
      }
      else if (cnrvnSch[i] < cnrvnTrg[nMid])
        nHigh = nMid;
      else
        nLow  = nMid + 1;
    }
  }
}

void fnResult(int nFnd)
{
  cout << nFnd << endl;
}

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

  vector<int> vnTrg, vnSch;
  int nFnd = 0;

  fnInput(vnTrg, vnSch);
  fnBinSch(vnTrg, vnSch, nFnd);
  fnResult(nFnd);

  return 0;
}

Measured memory_bytes: 1588
#include <stdio.h>

void Hantei(int a[3])
{
	int max, zako1, zako2;

	if (a[0]>a[1] && a[0]>a[2]) {
		max = a[0];
		zako1 = a[1];
		zako2 = a[2];
	}
	else if (a[1]>a[0] && a[1]>a[2]) {
		max = a[1];
		zako1 = a[0];
		zako2 = a[2];
	}
	else {
		max = a[2];
		zako1 = a[0];
		zako2 = a[1];
	}

	if (max*max == zako1*zako1 + zako2*zako2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

}

int main(void)
{
	int n;
	scanf("%d", &n);

	int len[n][3];

	for (int i = 0; i<n; i++) {
		scanf("%d %d %d", &len[i][0], &len[i][1], &len[i][2]);
	}

	for (int i = 0; i<n; i++) {
		Hantei(len[i]);
	}



	return 0;

}

Measured memory_bytes: 1016
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

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


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
#define myp pair<int,int>
#define myv vector<myp>
using namespace std;
const int N=310,MOD=1e9+7;
int n,m,can[N];
ll f[N][N][N],ans;
myv v[N];
int main(){
	int t1,t2,t3,nowl,nowx;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&t1,&t2,&t3);
		v[t2].push_back(myp(t1,t3));
	}
	f[1][0][0]=3;
	for(int i=1;i<=n;i++)
		for(int j=0;j<i;j++){
			memset(can,0,sizeof(can));
			for(int k=0;k<v[i].size();k++){
				nowl=v[i][k].first,nowx=v[i][k].second;
				if(nowx==1&&nowl<=j) can[0]+=1,can[n+1]-=1;
				if(nowx==2){
					if(nowl>j) can[0]+=1,can[n+1]-=1;
					else can[nowl]+=1,can[j]-=1;
				}
				if(nowx==3){
					if(nowl>=j) can[0]+=1,can[n+1]-=1;
					else can[0]+=1,can[nowl]-=1;
				}
			}
			for(int k=1;k<=n;k++) can[k]+=can[k-1];
			for(int k=0;k<=j;k++){
				if(j==k&&j&&k||can[k]) continue;
//				if(!f[i][j][k]) f[i][j][k]=6-3*(!j||!k);
				if(i==n) ans=(ans+f[i][j][k])%MOD;
				f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%MOD;
				f[i+1][i][k]=(f[i+1][i][k]+f[i][j][k])%MOD;
				f[i+1][i][j]=(f[i+1][i][j]+f[i][j][k])%MOD;
			}
		}
	cout<<ans<<endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        ll n,d;
        cin>>n>>d;
        d*=d;
        ll ans=0;
        ll x,y;
        rep(i,n){
            cin>>x>>y;
            if((x*x+y*y)<=d) ans++;
        }
        cout<<ans<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3804
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

//Restaurant
public class Main{

	class R implements Comparable<R>{
		int oid, id;
		public R(int oid, int id) {
			this.oid = oid;
			this.id = id;
		}
		public int compareTo(R o) {
			return oid!=o.oid?oid-o.oid:p[id]!=p[o.id]?p[o.id]-p[id]:id-o.id;
		}
		@Override
		public String toString() {
			return oid+","+id;
		}
	}

	int n, m;
	int[] p, limit, T, K, res;
	Map<String, Integer> ref;
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(boolean head = true;;head = false){
			n = sc.nextInt(); m = sc.nextInt();
			if((n|m)==0)break;
			if(!head)System.out.println();
			ref = new HashMap<String, Integer>();
			limit = new int[n];
			p = new int[n];
			T = new int[m];
			K = new int[m];
			for(int i=0;i<n;i++){
				ref.put(sc.next(), i);
				limit[i] = sc.nextInt();
				p[i] = sc.nextInt();
			}
			List<R>[] l = new List[m];
			for(int i=0;i<m;i++){
				l[i] = new ArrayList<R>();
				T[i] = sc.nextInt();
				K[i] = sc.nextInt();
				for(int j=0;j<K[i];j++)l[i].add(new R(i, ref.get(sc.next())));
			}
			res = new int[m];
			int f = 0, t = 0;
			LinkedList<R> list = new LinkedList<R>();
			while(f<m||!list.isEmpty()){
				while(f<m&&T[f]<=t){
					list.addAll(l[f++]);
				}
				if(list.isEmpty()&&f<m){
					t = T[f]; list.addAll(l[f++]);
				}
				Collections.sort(list);
				R r = list.get(0);
				t += p[r.id];
				int L = limit[r.id];
				for(int i=0;i<list.size()&&0<L;i++){
					R d = list.get(i);
					if(d.id!=r.id)continue;
					--L;
					if(--K[d.oid]==0)res[d.oid] = t;
					list.remove(i--);
				}
			}
			for(int r:res)System.out.println(r);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

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

	int n, a, b;
	cin >> n >> a >> b;

	cout << min(a * n, b) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,d;
char c[52][52];
int main(){
    cin>>a>>b;
    for(int i=0;i<a;i++)
        for(int j=0;j<b;j++)cin>>c[i][j];
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            d=0;
            if(c[i][j]=='#')cout<<"#";
            else{
                if(c[i-1][j-1]=='#')d++;
                if(c[i-1][j]=='#')d++;
                if(c[i-1][j+1]=='#')d++;
                if(c[i][j-1]=='#')d++;
                if(c[i][j+1]=='#')d++;
                if(c[i+1][j-1]=='#')d++;
                if(c[i+1][j]=='#')d++;
                if(c[i+1][j+1]=='#')d++;
                cout<<d;
            }
        }
        cout<<endl;
    }
return 0;
}

Measured memory_bytes: 256
# read Explanation
# https://img.atcoder.jp/abc169/editorial.pdf

MOD = 998244353

N, S = gets.chomp.split.map(&:to_i)
AS = gets.chomp.split.map(&:to_i)

dp = Array.new(S + 1, 0)
dp[0] = 1
AS.each do |a|
  S.downto(a) { |s| dp[s] = (dp[s] * 2 + dp[s - a]) % MOD }
  [S, (a - 1)].min.downto(0) { |s| dp[s] = (dp[s] * 2) % MOD }
end

puts dp[S]


Measured memory_bytes: 14368
import math
def solve():
  a,b,c,x,y = (int(i) for i in input().split())
  ans = 10**15
  for ab in range(max(x,y)+15):
    cost = 0
    buyab = ab*2
    cost += buyab*c
    cost += a*max(x-ab,0) + b*max(y-ab,0)
    
    ans = min(cost,ans)
  print(ans)
solve()

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

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

class Sol{
	public void Solve(){
		var d = ria();
		Console.WriteLine(d[1] * 2 == d[0] + d[2] ? "YES" : "NO");
	}

	public Sol(){
		
	}

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


Measured memory_bytes: 11092
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
min_ = a[0]
max_ = a[-1]
if min_ == max_:
    if n == 2:
        print(0)
        print(max_, max_)
        exit()
    if min_ < 0:
        print(-min_ * (n - 2))
        print(min_, min_)
        for i in range(n - 2):
            print(i * min_, min_)
    else:
        print(min_ * (n - 2))
        print(max_, max_)
        for i in range(n - 3):
            print(i * min_, min_)
        print(max_, -(n - 3) * max_)
else:
    ans = ''
    if min_ >= 0:
        for i in range(1, n - 1):
            ans += str(min_) + ' ' + str(a[i]) + '\n'
            min_ -= a[i]
        ans += str(a[-1]) + ' ' + str(min_) + '\n'
        print(a[-1] - min_)
        print(ans, end='')
    elif max_ <= 0:
        for i in range(n - 1):
            ans += str(max_) + ' ' + str(a[i]) + '\n'
            max_ -= a[i]
        print(max_)
        print(ans, end='')
    else:
        for i in range(1, n - 1):
            if a[i] < 0:
                continue
            else:
                ans += str(min_) + ' ' + str(a[i]) + '\n'
                min_ -= a[i]
        ans += str(max_) + ' ' + str(min_) + '\n'
        max_ -= min_
        for i in range(1, n - 1):
            if a[i] >= 0:
                break
            else:
                ans += str(max_) + ' ' + str(a[i]) + '\n'
                max_ -= a[i]
        print(max_)
        print(ans, end='')


Measured memory_bytes: 14216
#!/usr/bin/env python3
import math
n,p = map(int,input().split())
a = list(map(int,input().split()))
dp = [[0,0] for _ in range(n)]
if a[0] & 1:
    dp[0][0] = 1
    dp[0][1] = 1
else:
    dp[0][0] = 2
    dp[0][1] = 0
for i in range(1,n):
    if a[i] & 1:
        dp[i][0] = dp[i-1][0]+dp[i-1][1]
        dp[i][1] = dp[i-1][0]+dp[i-1][1]
    else:
        dp[i][0] = dp[i-1][0]*2
        dp[i][1] = dp[i-1][1]*2
print(dp[n-1][p])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;

//nのp乗
ll power(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*power(n,(p-1)/2)*power(n,(p-1)/2);}
    else{return power(n,p/2)*power(n,p/2);}
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
    //#define ll long long
    using namespace std;
    #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
    #define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
    #define ll long long
    #define pb push_back
    #define pll pair<ll,ll>
    #define ff first
    #define ss second
    #define mp make_pair
    #define N 2000001
    #define M 998244353
    #define INF 1000000000000000
  ll gcd(ll a,ll b)
  {
    if(b==0)return a;
    else return(gcd(b,a%b));
  }

int main()
{
  SPEED;
ll i,x,y;
cin>>x>>y;
if(y%2!=0){cout<<"No";return 0;}
y=y/2;
if(y<x || y>2*x)
cout<<"No";
else
cout<<"Yes";
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    char s[200005];
    ll n,ans=0;
    scanf("%s",s);
    n=strlen(s);
    if(n<3){
        printf("0\n");
        return 0;
    }
    ll as=0;
    rep(i,0,n-2){
        if(s[i]=='B' || s[i]=='C'){
            as=0;
            continue;
        }else{
            if(s[i+1]=='B'&&s[i+2]=='C'){
                as++;
                ans+=as;
                s[i+2]='A';
                as--;
                i+=1;
            }else{
                as++;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int kazu = int.Parse(ReadLine());
        int[] even = new int[kazu/2];
        int[] odd = new int[kazu/2];
        string[] suretu = ReadLine().Split(' ');
        for(int i=0;i<kazu;i++){
            int temp = int.Parse(suretu[i]);
            if(i%2==0){
                even[i/2] = temp;
            }else{
                odd[i/2] = temp;
            }
        }
        
        int[] counttemp = new int[110000];
        int[] saihine = new int[2];
        int[] countse = new int[2];
        for(int i=0;i<kazu/2;i++){
            int temp = even[i];
            counttemp[temp]++;
        }
        for(int i=0;i<=100001;i++){
            if(counttemp[i] > countse[1]){
                if(counttemp[i] > countse[0]){
                    countse[1] = countse[0];
                    countse[0] = counttemp[i];
                    saihine[1] = saihine[0];
                    saihine[0] = i;
                }else{
                    countse[1] = counttemp[i];
                    saihine[1] = i;
                }
            }
        }
        
        int[] counttemp2 = new int[110000];
        int[] saihino = new int[2];
        int[] countso = new int[2];
        for(int i=0;i<kazu/2;i++){
            int temp = odd[i];
            counttemp2[temp]++;
        }
        for(int i=0;i<=100001;i++){
            if(counttemp2[i] > countso[1]){
                if(counttemp2[i] > countso[0]){
                    countso[1] = countso[0];
                    countso[0] = counttemp2[i];
                    saihino[1] = saihino[0];
                    saihino[0] = i;
                }else{
                    countso[1] = counttemp2[i];
                    saihino[1] = i;
                }
            }
        }
        
        if(saihine[0] == saihino[0]){
            int ans1 = kazu-(countse[0]+countso[1]);
            int ans2 = kazu-(countse[1]+countso[0]);
            WriteLine(Min(ans1,ans2));
        }else{
            int ans = kazu-(countse[0]+countso[0]);
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 21600
#include<stdio.h>
int main(){
	int i,a,b;
	for(a=1;a<=9;++a){
		for(b=1;b<=9;++b){
			i=a*b;
			printf("%dx%d=%d",a,b,i);
			printf("\n");
		}
	}
    return 0;
}


Measured memory_bytes: 2044
import java.util.*;

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

        int K = Integer.parseInt(SC.next());
        int N = Integer.parseInt(SC.next());

        int[] A = new int[2*N];

        for(int i=0;i<N;i++){
            A[i]   = Integer.parseInt(SC.next());
            A[N+i] = A[i] + K;
        }

        int min = Integer.MAX_VALUE;

        for(int i=0;i<N;i++){
            min = Math.min(min, A[N+i-1] - A[i]);
        }
        if(min == K) min = 0;
        System.out.println(min);
    }

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


Measured memory_bytes: 63812
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>
#include<unordered_map>


using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int ma = min(a, b), mi = b - (n - a);
    mi = max(0, mi);
    cout << ma << ' ' << mi << endl;
    return 0;
}

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

#define fs first
#define sc second

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
    string s, t; cin >> s >> t;

    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();  //  1
      int B = sc.nextInt();  //  0
      int C = sc.nextInt();  // -1
      int K = sc.nextInt();  // 選ぶ枚数
      int max = -100;
      
      if ( A >= K){
      	System.out.println(K);
      }
      else{
        int L = K - A;
     	 if ( B >= L){
        	System.out.println(A);
      	}
      	else
      	{
      		System.out.println(1*A + 0*B+ (L-B)*(-1) );
      	}
      }
    }
}

Measured memory_bytes: 35752
import java.util.Scanner;

public class Main{	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==0) break;
				int[] c=new int[27];
				for(int i=0; i<=26; i++) {
					c[i]=0;
				}//初期化
				char first='A';
				char second='A'+1;
				int mi=0;
				for(int i=1; i<=n; i++) {
					String str=sc.next();
					c[str.charAt(0)-'A']++;
					if(i==1){
						first=str.charAt(0);
						second=(char) (first+1);
						mi=i;
					}
					else if(first!=str.charAt(0)) {
						if(c[first-'A']<c[str.charAt(0)-'A']) {
							second=first;
							first=str.charAt(0);
						}
						else if(c[second-'A']<c[str.charAt(0)-'A']) {
							second=str.charAt(0);
						}
					}
					if(c[first-'A']-c[second-'A']>n-i) {
						for(int j=i+1; j<=n; j++) {
							String str2=sc.next();
						}
						mi=i;
						break;
					}
				}
				if(c[first-'A']==c[second-'A']) {
					System.out.println("TIE");
				}
				else {
					System.out.println(first+" "+mi);
				}
			}
		}
	}
}


Measured memory_bytes: 48136
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}
int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    ll n;
    rep(i, N) {
        cin >> n;
        ans += n - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}

func Solve() {
  N := NextInt()
  if N % 10 < 1 { N-- }
  Nstr := strconv.Itoa(N)
  Head, _ := strconv.Atoi(Nstr[:1])
  Tail, _ := strconv.Atoi(Nstr[len(Nstr) - 1:])
  if N < 10 {
    Write(N)
    return
  }
  cnt := 9
  M := MinInt(Head, Tail)
  Inner := 1
  for i := 0; i < len(Nstr) - 2; i++ {
    Inner = Inner * 10
  }
  Inner2, _ := strconv.Atoi(Nstr[1:len(Nstr) - 1])
  Inner2++
  cnt += (M - 1) * Inner * Inner * (M - 1)
  cnt += 2 * Inner * (M - 1)
  if M < Head {
    cnt += (2 * M - 1) * Inner * Inner
    cnt += 2 * Inner
  } else {
    cnt += Inner2 * Inner2
    cnt += 2 * (Inner2 * (M - 1) * Inner)
    cnt += 2 * Inner2
  }
  if 100 < N {
    Inner3 := 1
    for i := 0; i < len(Nstr) - 3; i++ {
      Inner3 = Inner3 * 10 + 1
    }
    cnt += 9 * Inner3 * 9 * Inner3
    cnt += 2 * 9 * Inner3
    cnt += 2 * (M - 1) * Inner * 9 * Inner3
    if M < Head {
      cnt += 2 * Inner * 9 * Inner3
    } else {
      cnt += 2 * (Inner2 - 1) * 9 * Inner3
      cnt += 2 * Tail * Inner3
    }
  }
  Write(cnt)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 640
#include<cmath>
#include<cstdio>
#include<vector>

#define	EPS		1e-9
#define	pb(a)	push_back(a);

using namespace std;

class Point{
public:
	double x,y;
	Point(){}
	Point(double xx,double yy) : x(xx),y(yy){}
};

class Line : public vector<Point>{
public:
	Line(const Point &a,const Point &b){
		pb(a);
		pb(b);
	}
};

Point &operator -=(Point &a,const Point &b)
{
	a.x-=b.x;
	a.y-=b.y;
	return a;
}

Point operator -(const Point &a,const Point &b)
{
	Point c=a;
	c-=b;
	return c;
}

double dot(const Point &a,const Point &b)
{
	return a.x*b.x+a.y*b.y;
}

bool orthogonal(const Line &l,const Line &m)
{
	return abs(dot(l[1]-l[0],m[1]-m[0]))<EPS;
}

int main()
{
	for(Point a,b,c,d;~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y);){
		Line l(a,b),m(c,d);
		puts(orthogonal(l,m)?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main(){
    ll N; cin >> N;
    vll d(N+1);
    d[0] = 0;
    for(int i=1; i<N+1; i++){
        cin >> d[i];
    }
    if(N + 1 > 24){
        cout << 0;
    }else if(N + 1 == 24){
        vll p(13, 0);
        for(int i=1; i<N+1; i++){
            p[d[i]]++;
        }
        bool m = true;
        for(int i=1; i<12; i++){
            if(p[i] != 2){
                m = false;
            }
        }
        if(m){
            if(p[12] != 1){
                m = false;
            }
        }
        if(m){cout << 1;}
        else{cout << 0;}
    }else{
        ll mini = 0;
        for(int i=0; i<pow(2,N); i++){
            Radix r;
            string s = r.to(i, 2);
            if(s.size() < N){
                ll m = N - s.size();
                string p = "";
                for(int i=0; i<m; i++){
                    p += '0';
                }
                s = p + s;
            }
            vll D(N+1); D[0] = 0;
            for(int j=1; j<N+1; j++){
                if(s[j-1] == '0'){
                    D[j] = d[j];
                }else{
                    D[j] = 24 - d[j];
                }
            }
            ll mi = 10000;
            for(int j=0; j<N+1; j++){
                for(int k=j+1; k<N+1; k++){
                    ll g = min(abs(D[j] - D[k]), 24-abs(D[j] - D[k]));
                    if(g < mi){
                        mi = g;
                    }
                }
            }
            if(mi > mini){
                mini = mi;
            }
        }
        cout << mini;
    }
}

Measured memory_bytes: 384
S = input()
N = 2 ** (len(S)-1)
sum = 0
for i in range(0, N):
	m = i
	k = S[0]
	minisum = 0
	for j in range(1, len(S)):
		if m % 2 == 1:
			minisum += int(k)
			k = S[j]
		else:
			k = k + S[j]
		m //= 2
	minisum += int(k)
	sum += minisum
print(sum)

Measured memory_bytes: 40688
# include <iostream>
using namespace std;
int main(){
  int a,b;
  while( cin >> a >> b){
  int N = a+b;
  int num_digit = 0;
  while (true){
    num_digit++;
    N = N/10;
    if(N<1) break;
    }
  cout << num_digit << endl;
  }
}

Measured memory_bytes: 2940
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 410;
const ll INF = 1e18;

ll sm[MAXN];
ll a[MAXN];
ll dp[MAXN][MAXN];
int n;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i], sm[i + 1] = sm[i] + a[i];
	for (int i = n - 1; i >= 0; --i) {
		for (int j = i + 2; j <= n; ++j) {
			dp[i][j] = INF;
			for (int k = i + 1; k < j; ++k)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + sm[j] - sm[i]);
		}
	}
	cout << dp[0][n] << "\n";
	return 0;
}




Measured memory_bytes: 1536
S=input()
N=len(S)
result=[0]*N
R_flag=True
L_flag=False
start=0
for i in range(1,N):
    if S[i]=="L" and L_flag==False:
        L_flag=True
        mid=i
    elif S[i]=="R" and L_flag:
        L_flag=False
        end=i
        if (end-start)%2==0:
            result[mid-1]=(end-start)//2
            result[mid]=(end-start)//2
        else:
            if (start-mid)%2==0:
                result[mid-1]=(end-start)//2
                result[mid]=(end-start)//2+1
            else:
                result[mid-1]=(end-start)//2+1
                result[mid]=(end-start)//2
        start=end

    if i==N-1:
        end=N
        if (end-start)%2==0:
            result[mid-1]=(end-start)//2
            result[mid]=(end-start)//2
        else:
            if (start-mid)%2==0:
                result[mid-1]=(end-start)//2
                result[mid]=(end-start)//2+1
            else:
                result[mid-1]=(end-start)//2+1
                result[mid]=(end-start)//2

print(" ".join(list(map(str,result))))

Measured memory_bytes: 10740
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    auto x1 = (int)count(s.begin(), s.end(), 'R');
    auto x2 = (int)count(s.begin(), s.end(), 'W');

    auto i = 0;
    auto j = n - 1;
    while (i < n && s[i] == 'R') // skip left 'R'
        ++i;
    while (j >= 0 && s[j] == 'W') // skip right 'W'
        --j;

    auto x3 = 0;
    while (i < j) {
        x3++;
        ++i, --j;
        while (i < n && s[i] == 'R')
            ++i;
        while (j >= 0 && s[j] == 'W')
            --j;
    }

    cout << min({x1, x2, x3}) << endl;
    return 0;
}

Measured memory_bytes: 3772
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		Integer p[] = new Integer [N];
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		/*for(int i=0;i<N;i++) {
			System.out.println(p[i]);
		}*/
	    int min=Integer.MAX_VALUE;
		for(int j=-1000;j<1000;j++) {
			if(Arrays.asList(p).contains(j)) {
				//System.out.println(j);
				continue;
			}
			//System.out.println(j);
		  min = Math.min(min, Math.abs(X-j));
		}
		int a = X-min;
		if(Arrays.asList(p).contains(a)) {
			System.out.println(X+min);
		}else {
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 37068
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = Integer.parseInt(scan.next());
        int K = Integer.parseInt(scan.next());
        int X = Integer.parseInt(scan.next());
        int Y = Integer.parseInt(scan.next());

        if(N-K<=0 ){
            System.out.println(N*X);
        }else{
            System.out.println(K*X+(N-K)*Y);
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int H,W,K; cin >> H >> W >> K;
    char S[H][W];
    bool f[H]; rep(i,H) f[i] = true;
    rep(i,H) rep(j,W) cin >> S[i][j];
    rep(i,H){
        rep(j,W){
            if(S[i][j]=='#') {f[i] = false; break;}
        }
    }
    int ans[H][W];
    rep(i,H) rep(j,W) ans[i][j]=0;
    int cnt=1; bool frag=false;
    rep(i,H){
        if((i==0 && f[i]) || (ans[i-1][0]==0 && f[i])) continue;
        rep(j,W){
            if(!f[i]){
                if(S[i][j]=='#'){
                    if(frag) {cnt++;}
                    else frag=true;
                }
                ans[i][j]=cnt;
            }
            else {
                ans[i][j]=ans[i-1][j];
            }
        }
        if(!f[i]) {cnt++; frag=false;}
    }
    per(i,H){
        if(ans[i][0]!=0) continue;
        rep(j,W){
            ans[i][j]=ans[i+1][j];
        }
    }
    rep(i,H){
        rep(j,W){
            cout << ans[i][j] <<(j==W-1?"":" ");
        }
        cout << endl;
    }
}   

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

#define MAXN 100005

int n;
int dp[MAXN][3];
int a[MAXN];
int b[MAXN];
int c[MAXN];

int solve(int x, int s){
    if (x >= n) return 0;
    if (dp[x][s] != 0) return dp[x][s];
    else if (x > 0){
        if (s == 0){
            return dp[x][s] = max(b[x]+solve(x+1,1),c[x]+solve(x+1,2));
        } else if (s == 1){
            return dp[x][s] = max(a[x]+solve(x+1,0),c[x]+solve(x+1,2));
        } else {
            return dp[x][s] = max(a[x]+solve(x+1,0),b[x]+solve(x+1,1));
        }
    } else {
        return max(max(a[0]+solve(1,0),b[0]+solve(1,1)),c[0]+solve(1,2));
    }
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    cout << solve(0,0) << endl;
    return 0;
}

Measured memory_bytes: 7296
import heapq
from collections import deque

N,M = map(int,input().split())

dic = {}

for i in range(M):

    u,v = map(int,input().split())
    u -= 1
    v -= 1

    if u not in dic:
        dic[u] = []

    dic[u].append(v)


far = [[float("inf")] * 3 for i in range(N)]
nend = [ [True] * 3 for i in range(N) ]

S,T = map(int,input().split())
S -= 1
T -= 1

q = deque([])
q.append([0,S])

while len(q) > 0:

    now = q.popleft()

    nd = now[0]
    np = now[1]
    nend[np][nd % 3] = False

    far[np][nd % 3] = min(far[np][nd % 3],nd)

    if np in dic:
        for i in dic[np]:

            if nend[i][(nd + 1) % 3] and far[i][(nd+1)%3] > far[np][nd%3] + 1:
                q.append([nd + 1 , i])
                nend[i][(nd+1)%3] = False

if far[T][0] == float("inf"):
    print (-1)
else:
    print (far[T][0] // 3)
    



Measured memory_bytes: 108248
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
#include<map>
using namespace std;

int main(){
  int n; cin >> n;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    bool flg = true;
    for(int j = 2; j*j <= a; j++){
      if(a % j == 0) flg = false;
    }
    if(flg) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[123456], uiop[123456];
signed main() {
	int n, a, b, sum = 0, num = 0; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = a;
	}
	for (int h = 0; h < n; h++) {
		cin >> b; uiop[h] = b;
	}
	for (int h = 0; h < n; h++) {
		if (test[h] > uiop[h]) { num += test[h] - uiop[h]; }
		if (test[h] < uiop[h]) { sum += (uiop[h] - test[h]) / 2 * 2; }
	}
	if (sum >= num * 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-eps)return CLOCKWISE;
  if(dot(a,b)<-eps)return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

Point getCrossPointLL(Line a,Line b){
  double A=cross(a.p2-a.p1,b.p2-b.p1);
  double B=cross(a.p2-a.p1,a.p2-b.p1);
  if(abs(A)<eps || abs(B)<eps)return b.p1;
  return b.p1+(b.p2-b.p1)*(B/A);
}

double getPolygonArea(Polygon p){
  double area=0.0;
  int n=p.size();
  for(int i=0;i<n;i++)area+=cross(p[i%n],p[(i+1)%n]);
  return area/2;
}

Polygon convex_cut(Polygon p,Line l){
  Polygon ans;
  for(int i=0;i<p.size();i++){
    Point A=p[i],B=p[(i+1)%p.size()];
    if(ccw(l.p1,l.p2,A)!=-1)ans.push_back(A);
    if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0)
      ans.push_back(getCrossPointLL(l,Segment(A,B)));
  }
  return ans;
}

Line getPerpendicularBisector(Segment s){
  Point m=s.p1+(s.p2-s.p1)/2.0;
  Vector v1=s.p1-m,v2=s.p2-m;
  swap(v1.x,v1.y);
  v1.x=-v1.x;
  swap(v2.x,v2.y);
  v2.x=-v2.x;
  return Line(m+v1,m+v2);
}

int main()
{
  int a,b,c,d,e,f,count=1;

  while(1){
    cin>>a>>b>>c>>d>>e>>f;
    if(a+b+c+d+e+f==0)break;
    Polygon p;
    p.push_back(Point(0,0));
    p.push_back(Point(0,10000));
    p.push_back(Point(10000,10000));
    p.push_back(Point(10000,0));
    double area=getPolygonArea(p);
    Point ic(a,b),pc(c,d),acm(e,f);

    Line L1=getPerpendicularBisector(Segment(ic,pc));
    p=convex_cut(p,L1);
    L1=getPerpendicularBisector(Segment(ic,acm));
    p=convex_cut(p,L1);

    printf("%d %.10f\n",count,getPolygonArea(p)/area);
    count++;
  }
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

const long long INF = 10e9;

int main() {
	string str;
	cin >> str;
	long long ans = INF;
	for (int i = 0; i < str.size() - 2; i++) {
		int c = (int)((str[i] - '0') * 100) + (int)((str[i + 1] - '0') * 10) + (int)((str[i + 2] - '0'));
		int d = abs(c - 753);
		if (d < ans)
			ans = d;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
    int n,a,sum;
    scanf("%d",&n);
    scanf("%d",&a);
    sum=pow(n,2);
    printf("%d\n",sum-a);
    return 0;
}

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

int main(){
    long long int n,d,p,q,m,fl=0;
    cin >> n >>d;
    for(int i=0;i<n;i++){
        cin >> p >> q;
        m = p*p+q*q;
        if(sqrt(m) <= d){
            fl++;
        }
    }
    cout <<fl;
}

Measured memory_bytes: 3676
program march
  implicit none
  integer :: n, i, j, k
  integer(8) :: cnt(5) = 0_8, ans = 0_8
  character(10) :: s
  read(*,*) n
  do i = 1, n
    read(*,*) s
    select case (s(1:1))
    case ("M")
      cnt(1) = cnt(1)+1_8
    case ("A")
      cnt(2) = cnt(2)+1_8
    case ("R")
      cnt(3) = cnt(3)+1_8
    case ("C")
      cnt(4) = cnt(4)+1_8
    case ("H")
      cnt(5) = cnt(5)+1_8
    end select
  end do
  do i = 1, 3
    do j = i+1, 4
      do k = j+1, 5
        ans = ans+cnt(i)*cnt(j)*cnt(k)
      end do
    end do
  end do
  write(*,'(i0)') ans
end program march

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static Common;

public static class Common
{
    public static int BinSearchIndex<T>(T v, IEnumerable<T> list)
        where T : IComparable
    {
        int minRange = 0;
        int maxRange = list.Count();
        while (minRange != maxRange)
        {
            var center = (minRange + maxRange) / 2;
            if (list.ElementAt(center).CompareTo(v) < 0)
            {
                minRange = center + 1;
            }
            else
            {
                maxRange = center;
            }
        }

        return minRange;
    }
}

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(Console.ReadLine());
        }

        var list = new List<int>();
        foreach (var a in A.Reverse())
        {
            var index = BinSearchIndex(a + 1, list);
            if (index < list.Count)
            {
                list[index] = a;
            }
            else
            {
                list.Add(a);
            }
        }

        Console.WriteLine(list.Count);
    }
}

Measured memory_bytes: 17504