akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = LI()
    if sum(s) ==  2*max(s):
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39024
# -*- coding: utf-8 -*-
N = int(input())

div_num = []
for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        div_num.append(i)
        if i != N // i:
            div_num.append(N//i)

print(min([i+j for i,j in zip(sorted(div_num),sorted(div_num)[::-1])])-2)


Measured memory_bytes: 3552
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){ 
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    rep(i,0,tx-sx)cout<<"R";
    rep(i,0,ty-sy)cout<<"U";
    rep(i,0,tx-sx)cout<<"L";
    rep(i,0,ty-sy)cout<<"D";
    cout<<"D";
    rep(i,0,tx-sx+1)cout<<"R";
    rep(i,0,ty-sy+1)cout<<"U";
    cout<<"LU";
    rep(i,0,tx-sx+1)cout<<"L";
    rep(i,0,ty-sy+1)cout<<"D";
    cout<<"R";
    cout<<endl;
    

    return 0;
}


/*
10
9 4
4 3
1 1
4 2
2 4
5 8
4 0
5 3
0 5
5 2
0

*/


Measured memory_bytes: 256
#include<iomanip>
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<set>
using namespace std;
set<string> ss;
int main(){
	int n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		ss.insert(s);
	}
	cout<<ss.size();
    return 0;
}


Measured memory_bytes: 19204
#include <iostream>
#include <cstdio>

#include <vector>

#include <algorithm>

using namespace std;

#define repeat(n) for(int _ = 1; _ <= n; _++)

int main()
{
	ios::sync_with_stdio(false);
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
#endif
	
	int n, a, b;
	cin >> n >> a >> b;
	
	cout << min(a,b) << ' ' << max(0, a+b-n);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<set>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
set<int>s;
typedef set<int>::iterator It;
int n,a[100010],cnt[100010];
int top,ans[100010];
inline bool dfs(int limit)
{
	if(top==n){for(int i=1;i<=n;i++)pr1(ans[i]);return true;}
	if(n-top-1==cnt[limit] && s.find(limit)!=s.end())return false;
	for(It i=s.begin();i!=s.end();i++)
	{
		int p=*i;
		if(p==limit)continue;
		ans[++top]=p,cnt[a[p]]--;s.erase(i);
		if(dfs(a[p])==true)return true;
		top--,cnt[a[p]]++;s.insert(p);
	}return false;
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),cnt[a[i]]++,s.insert(i);
	if(dfs(0)==false)puts("-1");
	return 0;
}

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

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

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
  int m;
  cin >> m;
  cout << 48 - m << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;

int dp[3001][3001];
string li, ne;

int f(int i, int j) {
    if(i == li.size() || j == ne.size()) return 0;
    if(dp[i][j] != -1) return dp[i][j];
    if(li[i] == ne[j]) return dp[i][j] = 1 + f(i + 1, j + 1);
    return dp[i][j] = max(f(i + 1, j), f(i, j + 1));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    memset(dp, -1, sizeof dp);
    cin >> li >> ne;
    f(0, 0);
    int i = 0, j = 0;
    while(dp[i][j] > 0) {
        if(li[i] == ne[j]) cout << li[i], ++i, ++j;
        else if(dp[i][j + 1] < dp[i + 1][j]) ++i;
        else ++j;
    }
    
    return 0;
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define X first
#define Y second
signed main(){
  int n;
  while(cin>>n,n){
    P p[n];
    char d[n];
    for(int i=0;i<n;i++) cin>>p[i].X>>p[i].Y>>d[i];
    map<P,int> m;
    for(int i=0;i<n;i++) m[p[i]]=i;
    int used[n],visit[n];
    memset(used,0,sizeof(used));
    bool f=1;

    int ax1[]={-1, 0, 1, 2,-2,-1, 0, 1};
    int ay1[]={-1,-1,-1, 0, 0, 1, 1, 1};
    int ad1[]={ 1, 0, 1, 1, 1, 1, 0, 1};
    
    int ax2[]={-1, 0, 1, 2, 2, 1, 0,-1};
    int ay2[]={ 0, 1, 1, 0,-1,-2,-2,-1};
    int ad2[]={ 0, 0, 1, 1, 0, 0, 1, 1};
    
    int ax3[]={ 0, 1, 1, 1, 0,-1,-1,-1};
    int ay3[]={ 2, 1, 0,-1,-2,-1, 0, 1};
    int ad3[]={ 1, 1, 0, 1, 1, 1, 0, 1};
    
    int ax4[]={-1, 0, 1, 1, 0,-1,-2,-2};
    int ay4[]={-1,-1, 0, 1, 2, 2, 1, 0};
    int ad4[]={ 1, 0, 0, 1, 1, 0, 0, 1};
    
    for(int i=0;i<n;i++){
      if(used[i]) continue;
      bool ff=0;
      for(int k=0;k<2;k++){
	bool fff=1;
	
	memset(visit,-1,sizeof(visit));
	queue<int> q;
	q.push(i);
	visit[i]=k;
	
	while(!q.empty()){
	  int t=q.front();q.pop();
	  //cout<<t<<" "<<visit[t]<<endl;
	  if(d[t]=='x'){
	    for(int j=0;j<8;j++){
	      int nx=p[t].X+ax1[j],ny=p[t].Y+ay1[j],nv=visit[t];
	      if(!m.count(P(nx,ny))) continue;
	      int u=m[P(nx,ny)];
	      if(d[u]=='y') continue;
	      //cout<<"a1:"<<u<<endl;
	      if(ad1[j]) nv=!nv;
	      if(~visit[u]){
		if(visit[u]!=nv){
		  fff=0;
		  goto END;
		}
	      }else{
		visit[u]=nv;
		q.push(u);
	      }
	    }
	    for(int j=0;j<8;j++){
	      int nx=p[t].X+ax2[j],ny=p[t].Y+ay2[j],nv=visit[t];
	      if(!m.count(P(nx,ny))) continue;
	      int u=m[P(nx,ny)];
	      if(d[u]=='x') continue;
	      //cout<<"a2:"<<u<<endl;
	      if(ad2[j]) nv=!nv;
	      if(~visit[u]){
		if(visit[u]!=nv){
		  fff=0;
		  goto END;
		}
	      }else{
		visit[u]=nv;
		q.push(u);
	      }
	    }
	  }
	  
	  if(d[t]=='y'){
	    for(int j=0;j<8;j++){
	      int nx=p[t].X+ax3[j],ny=p[t].Y+ay3[j],nv=visit[t];
	      if(!m.count(P(nx,ny))) continue;
	      int u=m[P(nx,ny)];
	      if(d[u]=='x') continue;
	      //cout<<"a3:"<<u<<endl;
	      if(ad3[j]) nv=!nv;
	      if(~visit[u]){
		if(visit[u]!=nv){
		  fff=0;
		  goto END;
		}
	      }else{
		visit[u]=nv;
		q.push(u);
	      }
	    }
	    for(int j=0;j<8;j++){
	      int nx=p[t].X+ax4[j],ny=p[t].Y+ay4[j],nv=visit[t];
	      if(!m.count(P(nx,ny))) continue;
	      int u=m[P(nx,ny)];
	      if(d[u]=='y') continue;
	      //cout<<"a4:"<<u<<endl;
	      if(ad4[j]) nv=!nv;
	      if(~visit[u]){
		if(visit[u]!=nv){
		  fff=0;
		  goto END;
		}
	      }else{
		visit[u]=nv;
		q.push(u);
	      }
	    }
	  }
	}
	
      END:

	//cout<<"fff:"<<fff<<endl;
	
	if(fff){
	  for(int j=0;j<n;j++) if(~visit[j]) used[j]=1;
	  ff=1;
	  break;
	}
      }
      if(!ff){
	f=0;
	break;
      }
    }
    cout<<(f?"Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 4864
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

const int MAX_N = 10000;
const int MAX_K = 10;

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

    string s;

    cin >> s;

    char clr = s[0];

    int ans = 0;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] != clr) {
            ans++;
            clr = s[i];
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <cstdio>
using namespace std;
int a,b;
int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return f*x;
}
int main()
{
	a=read();
	b=read();
	if(a%b==0) printf("%d",a/b);
	else printf("%d",a/b+1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  ll n, ans = 0;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  } else {
    ans += n / 10;
    n /= 10;
    while (n > 0) {
      ans += n / 5;
      n /= 5;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline().rstrip())

grid_r = [[0] * 2 * N for _ in range(2 * N)]

for _ in range(N):
    a, b = tuple(map(int, sys.stdin.readline().rstrip().split()))
    grid_r[a][b] = 1

b = [tuple(map(int, sys.stdin.readline().rstrip().split())) for _ in range(N)]
b = sorted(b, key=lambda x: x[1])

ans = 0
for b_x, b_y in b:
    for x in range(b_x + 1)[::-1]:
        for y in range(b_y + 1):
            if grid_r[x][y] and (x != b_x or y != b_y):
                grid_r[x][y] = 0
                ans += 1
                break
        else:
            continue
        break
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b){
		printf("a < b\n");
	}
	else if (a > b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>
int main(void){
    int a1, a2, a3;
    scanf("%d %d %d", &a1, &a2, &a3);
    int Ten = a1 + a2 + a3;
        if (Ten >= 22){
        printf("bust\n");
    }
        else {
        printf("win\n");
        }
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int kap[12][6]={
    {4,2,0,9,7},
    {1,10,8,6,4},
    {9,7,5,3,1},
    {6,4,2,0,9},
    {3,1,10,8,6},
    {0,9,7,5,3},
    {8,6,4,2,0},
    {5,3,1,10,8},
    {2,0,9,7,5},
    {10,8,6,4,2},
    {7,5,3,1,10}};
int main()
{
	int n,k,ans=0,p;
	cin>>n>>k;
	n--,n--;
	p=n%11;
	n/=11;
    ans=n*5;
	for(int i=0;i<p;i++)
		for(int j=0;j<5;j++)
		{
			if(kap[i][j]==k)ans++;
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
gets
l=gets.split.map{|c|[c.to_i]}
i=0
l.sort.map{|a|a[0]=i+=1}
b=[s=0]*(1+r=l.size)
l.reverse_each{|n,|i=n;(s+=b[i];i&=i-1)while i>0;(b[n]+=1;n+=n&-n)until n>r}
p s

Measured memory_bytes: 32604
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class Main {
	static class Monster{
		int health, strength;
		
		Monster(int health, int strength){
			this.health = health;
			this.strength = strength;
		}
	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int A = Integer.parseInt(st.nextToken());
		int B = Integer.parseInt(st.nextToken());
		int C = Integer.parseInt(st.nextToken());
		int D = Integer.parseInt(st.nextToken());
		
		Monster ta = new Monster(A, B);
		Monster ao = new Monster(C, D);
		
		while(true) {
			ao.health -= ta.strength;
			if(ao.health <= 0) {
				bw.write("Yes\n");
				break;
			}
			
			ta.health -= ao.strength;
			if(ta.health <= 0) {
				bw.write("No\n");
				break;
			}
			
		}
		
		bw.flush();
	}

}


Measured memory_bytes: 32648
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,t;
  cin >> n >> t;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  vector<int> smax(n+1, 0);
  ll diffmax = -INF;
  int ans = 0;

  for (int i=n-1; i >= 0; i--) {
    smax[i] = max(smax[i+1],a[i]);
    int d = smax[i]-a[i];
    if (diffmax < d) ans = 0;
    if (diffmax <= d) { ans++; diffmax = d; }
  }
  COUT(ans);

  return 0;
}

Measured memory_bytes: 3984
#include <iostream>

using namespace std;

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

	for (int i = 0; i < s.length();i++) {

		cout << (char) s.at(i);
		if (i == 3) {
			cout << " ";
		}

	}
	cout << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    char *a = malloc(105*sizeof(char)), *b = malloc(105*sizeof(char));
    scanf("%s %s", a, b);
    int x = strlen(a), y = strlen(b);
    if (x>y)
        puts("GREATER");
    else if (x<y)
        puts("LESS");
    else {
        int z = strcmp(a, b);
        if (z>0)
            puts("GREATER");
        else if (z<0)
            puts("LESS");
        else
            puts("EQUAL");
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<math.h>

int main(void){
    long int S;
    int x_1,x_2,x_3,y_1,y_2,y_3,s;
    scanf("%ld",&S);
    x_1 = 0;
    y_1 = 0;
    if(S != 1000000000000000000){
        x_2 = (int)sqrt(S) + 1;
        y_3 = (int)sqrt(S) + 1;
        s = (x_2 * y_3) - S;
        int i = 0,p;
        p = (int)sqrt(s);
        while(s % (p - i) != 0){
            i--;
        }
        y_2 = p - i;
        x_3 = s / y_2;
    }else{
        x_2 = sqrt(S);
        y_3 = sqrt(S);
        x_3 = 0;
        y_2 = 0;
    }
    printf("%d %d %d %d %d %d",x_1,y_1,x_2,y_2,x_3,y_3);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vll = vector<long long>;

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

  vll b(n);
  vll c(n);

  for(ll i = 0; i < n; i++){
    cin >> b[i];
  } 
  for(ll i = 0; i < n; i++){
    cin >> c[i];
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  vll bc(n);
  for(ll i = n-1; i >= 0; i--){
    auto itr2 = lower_bound(c.begin(), c.end(), b[i]);
    bc[i] = n - (itr2 - c.begin());
    if(*itr2 == b[i]){
      auto itr3 = lower_bound(c.begin(), c.end(), b[i]+1);
      bc[i] = n - (itr3 - c.begin());
      }
    if(i != n-1){bc[i] += bc[i+1];}
  }

  ll sum = 0LL;
  for(ll i = 0; i < n; i++){
    auto itr1 = lower_bound(b.begin(), b.end(), a[i]);
    if(itr1 == b.end()){continue;}
    ll ab = itr1 - b.begin();
    if(*itr1 == a[i]){
      auto itr4 = lower_bound(b.begin(), b.end(), a[i]+1);
      if(itr1 == b.end()){continue;}
      ab = itr4 - b.begin();
    }
    sum += bc[ab];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <algorithm>
#define re register
#define ll long long
#define inf 1<<30
#define il inline
using namespace std;
/*===================Header Template=====================*/
#define N 200005
char s[N],t[N];
int nex[N][30];
int main(){
	scanf(" %s",s+1);
	scanf(" %s",t+1);
	int n=strlen(s+1);
	int m=strlen(t+1);
	for(int i=n;i;i--){
		for(int j=0;j<26;j++) nex[i-1][j]=nex[i][j];
		nex[i-1][s[i]-'a']=i;
	}
	int now=1;
	ll ans=0;
	for(re int i=1;i<=m;i++){
		if(!nex[now-1][t[i]-'a']){
			ans+=n-now+1;
			now=1;
			if(!nex[now-1][t[i]-'a']){
				puts("-1");
				return 0;
			}
			else{
				ans+=nex[now-1][t[i]-'a'];
				now=nex[now-1][t[i]-'a']+1;
			}
		}
		else{
			ans+=nex[now-1][t[i]-'a']-now+1;
			now=nex[now-1][t[i]-'a']+1;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 12672
#include<cstdio>
#include<queue>
using namespace std;
const int N=3010;
int n,a[N];
vector<int> e[N];
bool check(int x,int fa){
	for (auto v:e[x]){
		if (v==fa) continue;
		if (a[v]<a[x]&&!check(v,x)) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for (int i=1;i<=n;i++)
		if (check(i,0)) printf("%d ",i);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S[] = new String[N];
		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
			char c[] = S[i].toCharArray();
			if (c[0] == 'Y') {
				System.out.println("Four");
				sc.close();
				return;
			}
		}
		sc.close();
		System.out.println("Three");
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define model l,mid,num<<1
#define moder mid+1,r,num<<1|1
#define bug(k)  cout<<"text :"<<t<<endl
#define lowbit(k) k&-k
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int M=1e5+5;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if((a&1)&&(b&1))puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const ll MOD =  1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";
const ll MN = 1e5+10;
#define pos(v) ((v) << 1)
#define neg(v) (pos(v) ^ 1)
ll a[MN],dir[MN] ;
void output()
{
    ll n ;
    cin>>n ;
    a[0] = 0 ;
    FOR(i,1,n+1)
    {
        cin>>a[i] ;
    }
    n++ ;
    n++ ;
    ll tot = 0 ;
    a[n-1] = 0 ;
    FOR(i,0,n-1)
    {
        dir[i] = sign(a[i+1]-a[i]) ;
        tot += abs(a[i+1]-a[i]) ;
    }
    FOR(i,1,n-1)
    {
        cout<<tot - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1])<<endl ;
    }
}
int main()
{
	 #ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1  ;
    // cin>>t ;
    FOR(i,0,t)
    {
        output() ;
    }
    return 0 ;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll a,b,m;
    cin >> a >> b >> m;
    vector<ll> A(a);
    vector<ll> B(b);
    cins(all(A));
    cins(all(B));
  	ll ans = LLINF;
    rep(i, m){
        ll x,y,c;
        cin >> x >> y >> c;
        --x, --y;
        chmin(ans, A[x] + B[y] - c);
    }
    sort(all(A));
    sort(all(B));
    chmin(ans, A[0] + B[0]);
    print(ans);


}



Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int a, b, c, tmp;
    scanf("%d %d %d", &a, &b, &c);
    if(a>b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    
    if(a>b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    printf("%d %d %d\n", a, b, c);
}



Measured memory_bytes: 2048
sub i{$t=<STDIN>;split/ /,$t;}@c=i;for($j=0;$j<$c[2];$j++){@d=i;if($d[1]<=$d[0]){${$s[$d[1]]}[@{$s[$d[1]]}]=$d[0];}}$e=$c[0]+1;$f=1;for($j=1;$j<=$c[1];$j++){foreach(sort{$a<=>$b}@{$s[$j]}){if($f==$_){$f++;}if($f<$_&&$e>$_){$e=$_;}}$f++;}$e--;print$e;

Measured memory_bytes: 28264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans(ll a, ll b)
{
    if(a>b)
        return ans(b,a);

    ll k = a+b;
    if(k%2==0)
    {
        return k/2;
    }
    else
        return -1;
}
int main()
{
    ll a,b;
    cin>>a>>b;
    ll low = 0;
    ll high = 2000000000;
    ll mid;
    if(ans(a,b)>=0)
    cout<<ans(a,b)<<endl;
    else
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
  
  public static void main(String[] args){
	  
	  Scanner scanner = new Scanner(System.in);
	  int amount = scanner.nextInt();
	  List<Integer> takoyakiList = new ArrayList<>();
	  for (int i = 0; i < amount; i++) {
		int takoyaki = scanner.nextInt();
		takoyakiList.add(takoyaki);
	}
	  scanner.close();
	  int total = 0;
	  for (int i = 0; i < amount; i++) {
		for (int j = i + 1; j < amount ; j++) {
			total += takoyakiList.get(i) * takoyakiList.get(j);
		}
	}
	  System.out.println(total);
   }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const int INF = 1000000;

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

  int ret = INF;
  rep(i,N){
    int c, t;
    cin >> c >> t;
    if(t <= T){
      ret = min(ret, c);
    }
  }

  if(ret == INF){
    cout << "TLE" << endl;
  }else{
    cout << ret << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def tenka18beg_c():
    # https://atcoder.jp/contests/tenka1-2018-beginner/submissions/6799465
    inp = list(map(int, read().split()))
    N = inp[0]
    A = inp[1:]
    A.sort()

    if N % 2 == 0:
        lower = A[:N//2]
        upper = A[N//2:]
        ans = (2 * sum(upper) - upper[0]) - (2 * sum(lower) - lower[-1])
    else:
        lower = A[:N//2]
        upper = A[N//2 + 1:]
        mid = A[N//2]
        x = 2 * sum(upper) - 2 * sum(lower) - mid + lower[-1]  # 中央が +2* -1* -1* のパターン
        y = 2 * sum(upper) - 2 * sum(lower) + mid - upper[0]  # 中央が +1* +1* -2* のパターン
        ans = max(x, y)
    print(ans)

tenka18beg_c()

Measured memory_bytes: 13028
import java.util.Arrays;
import java.util.Scanner;

class Main {
    static int m;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        m = sc.nextInt();
        long x[] = new long[n];
        long y[] = new long[n];
        long z[] = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
            y[i] = sc.nextLong();
            z[i] = sc.nextLong();
        }
        long sum[] = new long[n];
        // ppp
        for (int i = 0; i < n; i++) {
            sum[i] = x[i] + y[i] + z[i];
        }
        long ans = maxSum(sum);
        // mpp
        for (int i = 0; i < n; i++) {
            x[i] *= -1;
            sum[i] = x[i] + y[i] + z[i];
        }
        ans = Math.max(ans, maxSum(sum));
        // mmp
        for (int i = 0; i < n; i++) {
            y[i] *= -1;
            sum[i] = x[i] + y[i] + z[i];
        }
        ans = Math.max(ans, maxSum(sum));
        // mmm
        for (int i = 0; i < n; i++) {
            z[i] *= -1;
            sum[i] = x[i] + y[i] + z[i];
        }
        ans = Math.max(ans, maxSum(sum));
        // pmm
        for (int i = 0; i < n; i++) {
            x[i] *= -1;
            sum[i] = x[i] + y[i] + z[i];
        }
        ans = Math.max(ans, maxSum(sum));
        // ppm
        for (int i = 0; i < n; i++) {
            y[i] *= -1;
            sum[i] = x[i] + y[i] + z[i];
        }

        ans = Math.max(ans, maxSum(sum));
        // mpm
        for (int i = 0; i < n; i++) {
            x[i] *= -1;
            sum[i] = x[i] + y[i] + z[i];
        }
        ans = Math.max(ans, maxSum(sum));
        // pmp
        for (int i = 0; i < n; i++) {
            x[i] *= -1;
            y[i] *= -1;
            z[i] *= -1;
            sum[i] = x[i] + y[i] + z[i];
        }
        ans = Math.max(ans, maxSum(sum));
        System.out.println(ans);
        sc.close();
    }

    public static long maxSum(long[] sum) {
        Arrays.sort(sum);
        int len = sum.length;
        long ret = 0;
        for (int i = 0; i < m; i++) {
            ret += sum[len - 1 - i];
        }
        return ret;
    }
}


Measured memory_bytes: 27912
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
class Program
{
    public static int Main()
    {
        //入力の受け取り
        int[] inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = inputs[0], m = inputs[1];
        int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        //問題を解く
        if (m <= n)
        {
            Console.WriteLine(0);
            return 0;
        }
        Array.Sort(x);
        List<int> dis = new List<int>();
        for (int i = 0; ; i++)
        {
            try { dis.Add(x[i + 1] - x[i]); }
            catch { break; }
        }
        dis.Sort();
        int ans = 0;
        for (int i = 0; i < m - n; i++)
            ans += dis[i];
        Console.WriteLine(ans);
        return 0;
    }
}

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

int main() {
    string S, T;
    cin >> S >> T;
    if(S == T.substr(0, S.size())){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

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

    int a, b, c;
    cin >> a >> b >> c;
    int result = 0;
    if (a >= b && a >= c) {
        result = ((a * 10) + b) + c;
    }
    if (b >= a && b >= c) {
        result = ((b * 10) + a) + c;
    }
    if (c >= b && c >= a) {
        result = ((c * 10) + a) + b;
    }
    cout << result;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int main() {
	int n; qr(n);
	printf("%.7lf\n",(double)2*n*acos(-1.0)); 
	return 0;
}



Measured memory_bytes: 3720
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <bitset>
using namespace std;

typedef long long ll;
ll mod=1e9+7;
int main() {
    int n;
    cin>>n;
    ll ans=1;
    for (int i=2; i<=n; ++i)
        ans=(ans*(i%mod))%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    println((n + 999) / 1000 * 1000 - n)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34356
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;

	VI A(N);
	int ans = 0;
	REP(i, N)A[i] = -1;
	REP(i, N) {
		if (T[i] == 'r') {
			if (i - K >= 0 && A[i - K] != 2) {
				ans += P;
				A[i] = 2;
			}
			else if (i - K < 0) {
				ans += P;
				A[i] = 2;
			}
		}
		if (T[i] == 's') {
			if (i - K >= 0 && A[i - K] != 0) {
				ans += R;
				A[i] = 0;
			}
			else if (i - K < 0) {
				ans += R;
				A[i] = 0;
			}
		}
		if (T[i] == 'p') {
			if (i - K >= 0 && A[i - K] != 1) {
				ans += S;
				A[i] = 1;
			}
			else if(i-K<0){
				ans += S;
				A[i] = 1;
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int a[1000010];

int main() {
    int N;
    cin >> N;
    rep(i, 100010)a[i+1] = i*i;
    rep(i, 100010) {
        if (a[i] > N) {
            cout << a[i-1] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 640
mod = 10**9+7
S = list(input())
Thankyou = 1
DP=[]
#DP[x][y] x+1文字目までを見たときの、
#y=0,1,2 : A,AB,ABCの登場回数
if S[0] == "A" or S[0]=="?":
    DP.append([1,0,0])
    if S[0]=="?":
        Thankyou = 3
else:
    DP.append([0,0,0])
for i,s in enumerate(S):

    if i==0:continue
    a,b,c = DP[i-1]
    if s=="A":
        DP.append([(a+Thankyou)%mod,b,c])
    elif s=="B":
        DP.append([a,(a+b)%mod,c])
    elif s=="C":
        DP.append([a,b,(b+c)%mod])
    else:
        DP.append([(Thankyou+3*a)%mod,(a+3*b)%mod,(b+3*c)%mod])
        Thankyou *= 3
        Thankyou %= mod
print(DP[len(S)-1][2]%mod)

Measured memory_bytes: 23468
#include <bits/stdc++.h>
#define le 100005
#define ll long long int
using namespace std;
ll n[le][4], dp[le][4];
int len;
bool vis[le][4];
ll fnc(int i, int j){
    if(i == len) return 0;
    if(vis[i][j]) return dp[i][j];
    ll ans;
    if(j == 0) ans = max(fnc(i + 1, 1), fnc(i + 1, 2));
    if(j == 1) ans = max(fnc(i + 1, 0), fnc(i + 1, 2));
    if(j == 2) ans = max(fnc(i + 1, 0), fnc(i + 1, 1));
    vis[i][j] = true;
    return dp[i][j] = n[i][j] + ans;
}
int main(){
    //freopen("input.txt", "r", stdin);
    scanf("%d", &len);
    for(int i = 0; i < len; i++) scanf("%d %d %d", &n[i][0], &n[i][1], &n[i][2]);
    printf("%lld\n", max(fnc(0, 0), max(fnc(0, 1), fnc(0, 2))));
    return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s; 
    int cnt = 0;
    for(int i=0; i<3; i++)
    {
    	if(s[i]=='1') cnt++; 
    }
    cout << cnt << endl;


	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 5;
int sol[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, q;
	cin >> n >> q;
	vector<pair<int, pair<int, int>>> obs;
	for(int i = 0; i < n; i++){
		int s, t, x;
		cin >> s >> t >> x;
		t--;
		obs.push_back({x,{s, t}});
	}
	sort(obs.begin(), obs.end());
	set<pair<int, int>> sett;
	for(int i = 0; i < q; i++){
		int d;
		cin >> d;
		sett.insert({d, i});
	}
	memset(sol, -1, sizeof sol);
	for(int i = 0; i < obs.size(); i++){
		int x = obs[i].first;
		int s = obs[i].second.first;
		int t = obs[i].second.second;
		s -= x;
		t -= x;
		while(true){
			auto it = sett.upper_bound({s-1, 1e9});
			auto val = *it;
			if(it == sett.end() || val.first > t)
				break;
			sol[val.second] = x;
			sett.erase(it);
		}
	}
	for(int i = 0; i < q; i++)
		cout << sol[i] << '\n';
	return 0;
}


Measured memory_bytes: 15824
import           Data.Char

main :: IO ()
main = do
    s <- getLine :: IO String
    putStrLn $ if judge s then "AC" else "WA"

judge :: String -> Bool
judge s = ahead s && celem s && small s

ahead :: String -> Bool
ahead s = head s == 'A'

celem :: String -> Bool
celem s =
    let n  = length s
        si = drop 2 (take (n - 1) s)
    in  'C' `elem` si

small :: String -> Bool
small s = length (filter isUpper s) == 2


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

int startx[2000000];

#define _LL long long

int modpow(int a, int b, int m)
{
    _LL prebit = a % m;
    _LL ans = 1;
    for( int bit = 0; (long unsigned int) b >= (1UL << bit); bit++ )
    {
        if( bit > 0 ) prebit = (prebit * prebit) % m;
        if( b & (1UL << bit) ) ans = (ans * prebit) % m;
    }
    return ans;
}

// x <= n
int calcf(int x)
{
    if( x == 0 ) return 0;
    int popcount = 0;
    for( int i = 0; (1 << i) <= x; i++ )
    {
        if( (1 << i) & x ) popcount++;
    }
    return calcf(x % popcount) + 1;
}

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

    _LL popcount = 0;
    for( int i = 0; i < n; i++ )
    {
        startx[i] = ( s[i] == '1' ? 1 : 0);
        if( startx[i] == 1 ) popcount++;
    }
    _LL mod0 = 0;
    if( popcount > 1 )
    {
        // popcount - 1でxをわったときのあまりを求める
        for( int i = 0; i < n; i++ )
        {
            mod0 = (mod0 * 2) % (popcount - 1);
            if( startx[i] == 1 ) mod0 = (mod0 + 1) % (popcount - 1);            
        }
    }
    _LL mod1 = 0;
    for( int i = 0; i < n; i++ )
    {
        mod1 = (mod1 * 2) % (popcount + 1);
        if( startx[i] == 1 ) mod1 = (mod1 + 1) % (popcount + 1);            
    }

    for( _LL i = 0; i < n; i++ )
    {
        _LL nmod = 0;
        if( startx[i] == 1 )
        {
            // 1 -> 0
            if( popcount - 1 > 0 )
            {
                nmod = (mod0 - modpow(2, n - 1 - i, popcount - 1)) % ( popcount - 1);
                if( nmod < 0 ) nmod += popcount - 1;
            }
            else
            {
                cout << 0 << endl;
                continue;
            }
        }
        else
        {
            nmod = (mod1 + modpow(2, n - 1 - i, popcount + 1)) % ( popcount + 1);
            if( nmod < 0 ) nmod += popcount + 1;
        }
        cout << calcf(nmod) + 1 << endl;
    }
}

Measured memory_bytes: 4528
# -*- coding utf-8 -*-
N=int(input())
S=list(str(input()))
ans=0
ansl=[]
for i in range(N):
    if S[i]=="I":
        ans+=1
    elif S[i]=="D":
        ans-=1
    ansl.append(ans)


ansl.append(0)
print(max(ansl))


Measured memory_bytes: 2940
import math

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

Xlist = [list(map(int,input().split())) for i in range(N)]

ans = 0
mathTemp = 0

for i in range(N):
    for j in range(i+1, N):
        for k in range(D):
           mathTemp = mathTemp + (( Xlist[i][k] - Xlist[j][k] ) ** 2)
        if math.sqrt(mathTemp) % 1 == 0:
            ans = ans + 1
        mathTemp = 0

print(ans)

Measured memory_bytes: 3064
from heapq import heappop, heappush

N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

List = sorted(List, key=lambda x: x[0])

hq = []
acc = 0
i = 0
j = 1
while j<M+1:
    while i<N and List[i][0]==j:
        heappush(hq, -List[i][1])
        i+=1
    if len(hq)>0:
        acc+=heappop(hq)*(-1)
    j+=1

print(acc)

Measured memory_bytes: 31976
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int> 
#define vll vector<ll> 
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;
using namespace std;

ll get(ll x){
    return (x * (x-1) / 2);
}

int main() {
    IOS;
    int n; cin >> n;
    vll mp(n+2,0),v(n);
    for(int i=0;i<n;++i){
        cin >> v[i],mp[v[i]]++; 
    }
    ll sum = 0,temp;
    for(auto x:mp){
        sum += get(x);
    }
    
    for(int i=0;i<n;++i){
        ll type = v[i];
        temp = sum;
        temp -= get(mp[type]);
        ll temp1 = mp[type] - 1;
        temp += get(temp1);
        cout << temp << "\n";
    }
}

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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  int sum = 0;
  string ans = "No";
  rep(i, n) {
    sum += a[i];
    if (h <= sum) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 100001;
int n, k, v[N], an[N];

int main(){
    scanf("%d", &n);
    for(int i = 0; i<n; ++i){
        scanf("%d", v+i);
        an[v[i]] = i+1;
    }
    for(int i = 1; i<=n; ++i)printf("%d ", an[i]);
} 


Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=500000;
int n,w[N],tmp[N];
int main()
{
    scanf("%d",&n);int cnt=0;
    for(int i=1;i<=n;i++)scanf("%d",w+i),tmp[i]=w[i];
    sort(tmp+1,tmp+n+1);
    for(int i=1;i<=n;i++)w[i]=lower_bound(tmp+1,tmp+n+1,w[i])-tmp,cnt+=(i&1)^(w[i]&1);
    cout<<(cnt>>1)<<endl;
}

Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end()
#define int long long
#define double long double
int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}
main()
{
	string s;
	int k;
	cin>>s>>k;
	int a;
	rep(i,s.length()){
		if(s[i]!='1') {
			a=i;
			break;
		}
	}
	if(k<a+1) cout<<1<<endl;
	else cout<<s[a]<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;


int main(){
    int n;
    vector<int> v;
    cin>>n;

    int hoge;
    for(int i=0;i<n;i++){
        cin>>hoge;
        v.push_back(hoge);
    }

    sort(v.begin(), v.end(), greater<int>());

    int ans=0;
    int diameter=101;

    for(int i=0;i<n;i++){
        if(v[i] < diameter){
            ans++;
            diameter = v[i];
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int H, W, K, ans, row[6], col[6];
vector<string> C;
void test() {
    int cnt = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (C[i][j] == '#' && row[i] && col[j]) {
                cnt++;
            }
        }
    }
    ans += cnt == K;
}
void rec1(int i) {
    if (i == W) {
        test();
        return;
    }
    col[i] = 0; rec1(i + 1);
    col[i] = 1; rec1(i + 1);
}
void rec0(int i) {
    if (i == H) {
        rec1(0);
        return;
    }
    row[i] = 0; rec0(i + 1);
    row[i] = 1; rec0(i + 1);
}
int main() {
    cin >> H >> W >> K;
    C.resize(H);
    for (auto &c : C) cin >> c;
    rec0(0);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n-1);
    int sum=0;
    rep(i,n) cin>>a[i];
    rep(i,n){
        cin>>b[i];
        sum+=b[i];
    }
    rep(i,n-1) cin>>c[i];
    rep(i,n-1){
        if(a[i]+1==a[i+1]) sum+=c[a[i]-1];
    }
    cout<<sum;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        System.out.println(Character.toString(a.charAt(0)) + b.charAt(1) + c.charAt(2));
    }
}

Measured memory_bytes: 20820