akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,a[100],b[100],c[100],sum=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		sum=sum+b[i];
	}
	for(int i=2;i<=n;i++)
	{
		cin>>c[i];
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]-1==a[i-1])
		sum=sum+c[a[i]];
	}
	cout<<sum;
}

Measured memory_bytes: 256
package main
import (
  "fmt"
  "container/list"
)
const INF = 1<<30
func main() {
  var n int
  var s string
  fmt.Scan(&n)
  g := make([][]int,n)
  for i:=0;i<n;i++ {
    fmt.Scan(&s)
    for j,r := range s {
      if r == '1' {
        g[i] = append(g[i],j)
        g[j] = append(g[j],i)
      }
    }
  }
  topologicalSort(g)
  color := make([]int,n)
  queue := list.New()
  ok := true
  color[0] = 1
  queue.PushBack(0)
  Bfs:
  for queue.Len() > 0 {
    i,_ := queue.Remove(queue.Front()).(int)
    for _,j := range g[i] {
      if color[j] == color[i] {
        ok = false
        break Bfs
      }
      if color[j] == 0 {
        color[j] = -color[i]
        queue.PushBack(j)
      }
    }
  }
  if !ok { fmt.Println(-1);return }
  d := make([][]int,n)
  for i:=0;i<n;i++ {
    d[i] = make([]int,n)
    for j:=0;j<n;j++ { d[i][j] = INF }
    for _,j := range g[i] { d[i][j] = 1 }
    d[i][i] = 0
  }
  for k:=0;k<n;k++ {
    for i:=0;i<n;i++ {
      for j:=0;j<n;j++ { d[i][j] = min(d[i][j],d[i][k]+d[k][j]) }
    }
  }
  m := 0
  for i:=0;i<n;i++ {
    for j:=0;j<n;j++ { m = max(m,d[i][j]+1) }
  }
  fmt.Println(m)
}
func min(x,y int) int {
  if x < y { return x }
  return y
}
func max(x,y int) int {
  if x > y { return x }
  return y
}
func topologicalSort(g [][]int) []int {
  n := len(g)
  s := []int{}
  u := make([]bool,n)
  var dfs func(int)
  dfs = func(i int) {
    if u[i] { return }
    u[i] = true
    for _,e := range g[i] { dfs(e) }
    s = append(s,i)
  }
  for i:=0;i<n;i++ { dfs(i) }
  m := len(s)
  for i:=0;i<m-1-i;i++ { s[i],s[m-1-i] = s[m-1-i],s[i] }
  return s
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
int main()
{
	lli x,y;
	cin>>x>>y;
	lli a[3] = {300000, 200000, 100000};
	lli aa = 0;
	x--, y--;
	if(x<3)
	aa += a[x];
	if(y<3)
	aa += a[y];
	if(x == 0 and y == 0)
	aa += 400000;
	cout<<aa<<endl;
}



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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, x;
    cin >> a >> b >> x;
    cout << ((a <= x && a + b >= x) ? "YES" : "NO") << endl;
}


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

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

	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e1 + 10;
LL getsum(LL a, LL b)
{
	LL sum = 0;
	while (a)
	{
		sum += a % b;
		a /= b;
	}
	return sum;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL n, s;
	cin >> n >> s;
	for (LL i = 2; i*i <= n; i++)
	{
		if (getsum(n, i) == s)
		{
			cout << i << endl;
			return 0;
		}
	}
	LL ans = INF * INF;
	if (n == s) ans = n + 1;
	for (LL i = 1; i*i <= n; i++)
	{
		if (s < i) break;
		LL a = i, b = s - i;
		if (n <= b) continue;
		if ((n - b) % a) continue;
		LL o = (n - b) / a;
		if (o <= 1) continue;
		if (getsum(n, o) == s)
		{
			ans = min(ans, o);
		}
	}
	if (ans == INF * INF) ans = -1;
	cout << ans << endl;
	return 0;
}

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

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

int l[500005], r[500005];
string s;
int n;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> s;
	n = s.size();
	for (int i=0; i<n; i++) {
		l[i+1] = l[i] + 1;
		if (s[i] == '>')
			l[i+1] = 0;
	}
	for (int i=n-1; i>=0; i--) {
		r[i] = r[i+1] + 1;
		if (s[i] == '<')
			r[i] = 0;
	}

	ll sol = 0;
	for (int i=0; i<=n; i++) {
		sol += max(l[i], r[i]);
	}
	cout << sol << '\n';
}

Measured memory_bytes: 4764
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int r; cin >> r;
	if (r < 1200)
		cout << "ABC" << endl;
	else if (r < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;
}

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

using namespace std;

int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)
			break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i==0 || i==H-1 || j==0 || j==W-1)
					cout<<"#";
				else
					cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, k - n % k);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int mod = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0L;
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            long x = sc.nextLong();
            a[i] = x;
            sum += x;
            sum %= mod;
        }
        long ans = 0L;
        for (int i = 0; i < n; i++) {
            sum = (sum - a[i] + mod)%mod;
            ans = (ans + sum * a[i]) %mod;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 62352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<vector<pp>> path(n);
    vector<int> color(n-1,-1);
    rep(i,n-1){
        int a,b; cin>>a>>b;
        a--; b--;
        path[a].push_back(mk(b,i));
        path[b].push_back(mk(a,i));
    }
    int k=-1,idx;
    rep(i,n){
        if(k<(int)path[i].size()){
            k=path[i].size();
            idx=i;
        }
    }
    cout<<k<<endl;
    queue<pp> que;
    que.push(mk(idx,-1));
    while(!(que.empty())){
        int s,e;
        tie(s,e)=que.front();
        que.pop();
        int cnt=1;
        for(auto to:path[s]){
            if(color[to.second]>=0) continue;
            if(e==cnt) cnt++;
            color[to.second]=cnt;
            que.push(mk(to.first,cnt));
            cnt++;
        }
    }
    rep(i,n-1) cout<<color[i]<<endl;
}

Measured memory_bytes: 7040
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int count = 0;
  for (int i = 0; i <= A; ++i) {
    for (int j = 0; j <= B; ++j) {
      for (int k = 0; k <= C; ++k) {
        if (i * 500 + j * 100 + k * 50 == X)
          ++count;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

using namespace std;


// 1. dp?????????
int dp[8][1001];
// 2. n????????????
int n;
char chr;
// ???. calc????????????
int calc(int k,int m){
	// 8. dp???????????°??????
	if(dp[k][m]>=0)return dp[k][m];
	if(k==1)dp[k][m]=calc(1,m-1)+calc(3,m-1)+calc(5,m-1)+calc(7,m-1);
	if(k==2)dp[k][m]=calc(2,m-1)+calc(3,m-1)+calc(6,m-1)+calc(7,m-1);
	if(k==3)dp[k][m]=calc(1,m-1)+calc(2,m-1)+calc(3,m-1)+calc(5,m-1)+calc(6,m-1)+calc(7,m-1);
	if(k==4)dp[k][m]=calc(4,m-1)+calc(5,m-1)+calc(6,m-1)+calc(7,m-1);
	if(k==5)dp[k][m]=calc(1,m-1)+calc(3,m-1)+calc(4,m-1)+calc(5,m-1)+calc(6,m-1)+calc(7,m-1);
	if(k==6)dp[k][m]=calc(2,m-1)+calc(3,m-1)+calc(4,m-1)+calc(5,m-1)+calc(6,m-1)+calc(7,m-1);
	if(k==7)dp[k][m]=calc(1,m-1)+calc(2,m-1)+calc(3,m-1)+calc(4,m-1)+calc(5,m-1)+calc(6,m-1)+calc(7,m-1);
	dp[k][m]=dp[k][m]%10007;
	return dp[k][m];

}

int main() {

	cin>>n;

	// 3. ?????????
	for(int i=0;i<8;++i){
		for(int j=0;j<1001;++j){
			dp[i][j]=-1;

		}
	}
	// 4.??\???

	dp[1][1]=0;
	dp[2][1]=0;
	dp[3][1]=0;
	dp[4][1]=1;
	dp[5][1]=1;
	dp[6][1]=1;
	dp[7][1]=1;
	for(int i=1; i<n+1; ++i){
		cin>>chr;
		if(chr=='J'){
			dp[1][i]=0;
			dp[2][i]=0;
			dp[3][i]=0;
		}
		if(chr=='O'){
			dp[1][i]=0;
			dp[4][i]=0;
			dp[5][i]=0;
		}
		if(chr=='I'){
			dp[2][i]=0;
			dp[4][i]=0;
			dp[6][i]=0;
		}
	}

	// 5. ???????????¨??????


	// 6. ??????

	int total=0;
	for(int i=1;i<8;++i){
		total+=calc(i,n);
	}

	total=total%10007;

	cout<<total<<endl;
	return 0;
}

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

using namespace std;

#define MOD 1000000007
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626

typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    if(n>=400 && n<600)cout<<"8\n";
    else if(n>=600 && n<800)cout<<"7\n";
    else if(n>=800 && n<1000)cout<<"6\n";
    else if(n>=1000 && n<1200)cout<<"5\n";
    else if(n>=1200 && n<1400)cout<<"4\n";
    else if(n>=1400 && n<1600)cout<<"3\n";
    else if(n>=1600 && n<1800)cout<<"2\n";
    else cout<<"1\n";
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}

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


int main(){

	int N;
	cin >> N;
	int b[N+10];
	for(int i = 0; i < N-1; i++) cin >> b[i];


	int ans = b[0] + b[N-2];

	for(int i = 1; i < N-1; i++){
		ans += min(b[i-1], b[i]);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(void) {
    int K, N;
    string S;
    cin >> N >> S >> K;
    for (int i=0;i<N;i++) {
        if (S[i] != S[K-1]) S[i] = '*';
    }
    cout << S << endl;

    return 0;
}

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

int main(){
    int n, m, t, a;
    cin >> n >> m >> t;

    bool occupied[10001] = {};
    for(int i = 0; i < n; i++){
        cin >> a;
        for(int j = max(0, a-m); j < min(t, a+m); j++) occupied[j] = true;
    }

    int ans = 0;
    for(int i = 0; i < t; i++) if(!occupied[i])  ans++;
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3112
package main
import "fmt"

func main(){
	n:=0
	fmt.Scanf("%d", &n)
	mod:=n%27
	if mod==13||mod==26{
		fmt.Println(":(")
	}else if mod >=14{
		fmt.Println((n/27)*25+mod-1)
	}else{
		fmt.Println((n/27)*25+mod)
	}
}


Measured memory_bytes: 1832
#include<iostream>
#include<stdio.h>

using namespace std;

int main() {
	int H, W;

	while (1) {

		cin >> H >> W;

		if (H == 0 && W == 0) {
			return 0;
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {

				if (i >= 1 && i < (H - 1) && j >= 1 && j < (W - 1)) {
					cout << '.';
				}
				else {
					cout << '#';
				}
			}
			cout << endl;
		}
		cout << endl;

	}
	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>

struct Dice
{
	int n[6];
};

Dice InputDice()
{
	Dice d;
	for(int i = 0; i < 6; ++i)
	{
		scanf("%d", &d.n[i]);
	}
	
	return d;
}

Dice SetDice(int a, int b, int c, int d, int e, int f)
{
	Dice dice;
	dice.n[0] = a;
	dice.n[1] = b;
	dice.n[2] = c;
	dice.n[3] = d;
	dice.n[4] = e;
	dice.n[5] = f;
	
	return dice;
}

Dice Roll(Dice dice, char dir)
{
	switch(dir)
	{
		case 'N':
			return SetDice(dice.n[1], dice.n[5], dice.n[2], dice.n[3], dice.n[0], dice.n[4]);
		case 'S':
			return SetDice(dice.n[4], dice.n[0], dice.n[2], dice.n[3], dice.n[5], dice.n[1]);
		case 'W':
			return SetDice(dice.n[2], dice.n[1], dice.n[5], dice.n[0], dice.n[4], dice.n[3]);
		case 'E':
			return SetDice(dice.n[3], dice.n[1], dice.n[0], dice.n[5], dice.n[4], dice.n[2]);
	}
}

bool IsSame(Dice a, Dice b)
{
	for(int i = 0; i < 6; ++i)
	{
		if(a.n[i] != b.n[i])
		{
			return false;
		}
	}
	
	return true;
}

bool IsEqual(Dice a, Dice b)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		b = Roll(b, cmd[i]);
		if(IsSame(a, b))
		{
			return true;
		}
	}
	
	return false;
}

int FindTop(Dice a, int top, int front)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		a = Roll(a, cmd[i]);
		if(a.n[0] == top && a.n[1] == front)
		{
			return a.n[2];
		}
	}
	
	return -1;
}

int main()
{
	Dice D = InputDice();
	char cmd[128];
	scanf("%s", cmd);
	
	for(int i = 0; cmd[i] != 0; ++i)
	{
		D = Roll(D, cmd[i]);
	}
	
	printf("%d\n", D.n[0]);

    return 0;
}



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

S = [A[0]]
for i in range(1,N):
	S.append(S[-1] + A[i])

#正から始まるver
cnt_p = 0
app_p = 0

for i in range(N):
	if i == 0:
		if S[i] <= 0:
			cnt_p += 1 - S[i]
			app_p += 1 - S[i]
		continue

	if i % 2 == 1: #負でないとだめ
		if S[i]+app_p >= 0:
			cnt_p += (S[i]+app_p)  - (-1)
			app_p += -1 - (S[i]+app_p)
	elif i % 2 == 0: #正でないとだめ
		if S[i] + app_p <= 0:
			cnt_p += 1 - (S[i]+app_p)
			app_p += 1 - (S[i]+app_p)

#負から始まるver
cnt_n = 0
app_n = 0

for i in range(N):
	if i == 0:
		if S[i] >= 0:
			cnt_n += S[i] - (-1)
			app_n += -1 - S[i]
		continue

	if i % 2 == 1: #正でないとだめ
		if S[i]+app_n <= 0:
			cnt_n += 1 - (S[i]+app_n)
			app_n += 1 - (S[i]+app_n)
	elif i % 2 == 0: #負でないとだめ
		if S[i] + app_n >= 0:
			cnt_n += (S[i]+app_n) - (-1)
			app_n += -1 - (S[i]+app_n)

print(min(cnt_n, cnt_p))

Measured memory_bytes: 14332
package main

import (
	"fmt"
)

func main() {
	var n, c int
	fmt.Scan(&n)

	b := 1
	for i := 0; i < n; i++ {
		var t int
		fmt.Scan(&t)

		if b == t {
			b++
		} else {
			c++
		}
	}

	if c < n {
		fmt.Println(c)
	} else {
		fmt.Println(-1)
	}

}

Measured memory_bytes: 6912
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int H = scan.nextInt();
      	int W = scan.nextInt();
      	int h = scan.nextInt();
      	int w = scan.nextInt();
      	int all = H * W;
      	int nokori = all - h * W;
      	nokori = nokori - (H -h) * w;
      	System.out.print(nokori);
    }

}

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

int main() {
  int N;
  cin >> N;
  map<string,int> S;
  for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    S[s] = 0;
  }
  cout << S.size() << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
string S;

template<class V,int NV> class SegTree_Pair {
public:
	vector<pair<V,int> > val;
	static V const def=1<<30;
	pair<V,int> comp(pair<V,int> l,pair<V,int> r){ return min(l,r);}
	SegTree_Pair(){
		val.resize(NV*2);
		int i;
		FOR(i,NV) val[i+NV]=make_pair(def,i);
		for(i=NV-1;i>=1;i--) val[i]=comp(val[2*i],val[2*i+1]);
	};
	pair<V,int> getval(int x,int y,int l=0,int r=NV,int k=1) {
		if(r<=x || y<=l) return make_pair(def,NV);
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry]=make_pair(v,entry-NV);
		while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
	}
};
SegTree_Pair<int,1<<20> st;

int dp[202020];
int from[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>S;
	
	dp[N]=0;
	st.update(N,0);
	for(i=N-1;i>=0;i--) if(S[i]=='0') {
		auto p=st.getval(i+1,min(i+M+1,N+1));
		from[i]=p.second;
		dp[i]=p.first+1;
		st.update(i,dp[i]);
	}
	
	if(dp[0]>=1<<30) {
		cout<<-1<<endl;
	}
	else {
		int cur=0;
		while(cur<N) {
			cout<<from[cur]-cur<<" ";
			cur=from[cur];
		}
		cout<<endl;
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 17872
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

struct Info{
	Info(){ left = height = 0;}
	Info(int arg_left,int arg_height){
		left = arg_left;
		height = arg_height;
	}
	int left,height;
};

int main(){

	int n,max_s,tmp,tmp_h,table[6][6];

	stack<Info> S;
	Info work;

	scanf("%d",&n);

	for(int loop = 0; loop < n; loop++){

		for(int i = 0; i < 6; i++)table[0][i] = 0;
		for(int i = 0; i < 6; i++)table[i][5] = 0;

		max_s = 0;

		for(int i = 1; i <= 5; i++){

			for(int k = 0; k < 5; k++){
				scanf("%d",&table[i][k]);
				if(table[i][k] == 1){
					table[i][k] = table[i-1][k]+1;
				}
			}

			getchar();

			tmp_h = table[i][0];
			S.push(Info(0,tmp_h));

			for(int k = 1; k < 6; k++){
				if(table[i][k] > tmp_h){
					S.push(Info(k,table[i][k]));
					tmp_h = table[i][k];
				}else if(table[i][k] == tmp_h){
					//Do nothing
				}else{
					while(S.empty() == false && S.top().height >= table[i][k]){
						work = S.top();
						S.pop();
						tmp = (k - work.left)*work.height;
						max_s = (max_s >= tmp)?max_s:tmp;
					}
					tmp_h = table[i][k];
					S.push(Info(work.left,table[i][k]));
				}
			}
		}
		while(!S.empty())S.pop();
		printf("%d\n",max_s);
	}

	return 0;
}

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

using namespace std;

int main(){
char letter[30], dump[30];
int b;
priority_queue<int>PQ;
do{
fgets(letter, 25, stdin);
if(letter[0]=='i'){
sscanf(letter, "%*s %d", &b, sizeof(b));
PQ.push(b);
}else{
if(letter[0]=='e' && letter[1]=='n' && letter[2]=='d'){
break;
}else{
cout << PQ.top() << endl;
PQ.pop();
}
}
}while(1);
return 0;
}


Measured memory_bytes: 6960
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int H, W, D; cin >> H >> W >> D;
    vvi A(H, vi(W));
    REP(i, H)
        REP(j, W) cin >> A[i][j];

    int Q; cin >> Q;
    vi L(Q), R(Q); REP(i, Q) cin >> L[i] >> R[i];

    map<int, pii> mp;
    REP(i, H)
        REP(j, W) mp[A[i][j]] = pii(i+1, j+1);

    map<pii,int> cost;
    for(int i=1; i+D <= H*W; i++) {
        pii p = mp[i];
        pii np = mp[i + D];
        cost[pii(i, i + D)] = abs(np.first - p.first) + abs(np.second - p.second);
    }
    
    vi sum(H*W + 1, 0);
    for (int i = 1; i <= H * W; i++) {
        if (i < D) sum[i] = 0;
        else sum[i] = sum[i - D] + cost[pii(i - D, i)];
    }

    REP(i,Q) {
        int ans = sum[R[i]] - sum[L[i]];
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define INF 105

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);  
    int n;
    cin >> n;
    string a;
    cin >> a;
    if(a.size()<=n)
    {
    	cout << a << endl;
    }else
    {
    	cout << a.substr(0,n) << "..." << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    int a,b;
    cin >> a >> b;
    vector<int> h(999);
    h[0] = 1;
    rep2(i,1,1000) h[i] = h[i-1] + i + 1;
    
    int d = b - a;
    cout << h[d-1] - b << endl;     
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, y;cin>>n>>y;
  int res10000=-1, res5000=-1, res1000=-1;
  for(int a=0;a<=n;a++){
    for(int b=0; a+b<=n;b++){
      int c=n-a-b; int total= 10000*a+5000*b+1000*c;
      if(total==y){
        res10000=a;
        res5000=b;
        res1000=c;
      }
    }
  }
  cout<<res10000<<" "<<res5000<<" "<<res1000<<endl;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    REP(i,SZ(s)){
        if(s[i]=='?'){
            s[i] = 'D';
        }
    }
    cout << s <<endl;
    return 0;
}

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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	ll total = 0;
	for(int i = 1; i < n; i++) {
		if(arr[i] < arr[i - 1]) {
			total += - arr[i] + arr[i - 1];
			arr[i] = arr[i - 1];
		}
	}
	cout << total;

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
		solve();

	return 0;
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  vector<string> vec;
  vec.pb("AKIHABARA");
  vec.pb("AKIHABAR");
  vec.pb("AKIHABRA");
  vec.pb("AKIHABR");
  vec.pb("AKIHBARA");
  vec.pb("AKIHBAR");
  vec.pb("AKIHBRA");
  vec.pb("AKIHBR");
  vec.pb("KIHABARA");
  vec.pb("KIHABAR");
  vec.pb("KIHABRA");
  vec.pb("KIHABR");
  vec.pb("KIHBARA");
  vec.pb("KIHBAR");
  vec.pb("KIHBRA");
  vec.pb("KIHBR");
  rep(i,16)
  {
    if(S==vec[i]) 
    {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

int main() {
  int n;cin>>n;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  string t="MARCH";
  vector<int> cnt(5);
  rep(i,n){
    rep(j,5){
      if(t[j]==s[i][0])cnt[j]++;
    }
  }
  ll ans=0;
  rep(i,5)for(int j=i+1;j<5;j++)for(int k=j+1;k<5;k++){
    ans+=(ll)cnt[i]*cnt[j]*cnt[k];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6424
def cut_at (x, y, len)
  mod = len % ((x + y) * 2)
  return [mod, 0] if mod < x
  mod -= x
  return [0, mod] if mod < y
  mod -= y
  return [x - mod, 0] if mod < x
  mod -= x
  return [0, y - mod]
end

def cut(piece, i, len)
  target = piece.delete_at(i - 1)
  sx, sy = target[0]
  tx, ty = target[1]
  x, y = tx - sx, ty - sy
  dx, dy = cut_at(x, y, len)
  nsx = sx + dx; nsy = sy + dy
  old = dx == 0 ? [[sx, sy], [tx, nsy]] : [[sx, sy], [nsx, ty]]
  now = [[nsx, nsy], [tx, ty]]
  if dx == 0 ? y > dy * 2 : x > dx * 2
    piece << old
    piece << now
  else
    piece << now
    piece << old
  end
end

loop do
  n, w, d = gets.split.map(&:to_i)
  break if n == 0 && w == 0 && d == 0
  piece = []
  piece << [[0, 0], [w, d]]
  n.times.each do
    i, len = gets.split.map(&:to_i)
    cut(piece, i, len)
  end
  puts piece.map{ |(sx, sy), (tx, ty)|
    (ty - sy) * (tx - sx)
  }.sort.join(' ')
end

Measured memory_bytes: 8736
from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

q = deque([0])
d = [-1]*n
d[0] = 0
ans = [0]*n
print('Yes')
while q:
    p = q.popleft()
    for node in g[p]:
        if d[node] == -1:
            d[node] = d[p] + 1
            q.append(node)
        else:
            if d[node] + 1 == d[p]:
                ans[p] = node + 1
for i in range(1, n):
    print(ans[i])

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

public class Main{
  public static void main(String[] args) {
    try {
      BufferedReader stdReader =
        new BufferedReader(new InputStreamReader(System.in));
      String line0;
      line0 = stdReader.readLine();

      String Array[]=line0.split(" ");
      if( Integer.parseInt(Array[0])>Integer.parseInt(Array[1])     ){
          System.out.println("a > b");
	  }
	  
	  if( Integer.parseInt(Array[0])< Integer.parseInt(Array[1])){
          System.out.println("a < b");
	  }
	  
	  if( Integer.parseInt(Array[0])== Integer.parseInt(Array[1])){
          System.out.println("a == b");
	  }
	  
	  
      stdReader.close();
    } catch (Exception e) {
      e.getStackTrace();
      /*?????´??????0??????*/
      System.exit(0); 
    }
  }
}

Measured memory_bytes: 24152
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val inputs = readLine()!!.split(" ").map { it.toInt() }

    // 柱問題と一緒，その柱に至る最小の移動コストを左から順に記録しておく

    val costs = IntArray(n)

    for (i in 0 until n) {
        if (i == 0 ) {
            costs[i] = 0
            continue
        }

        if ( i == 1 ) {
            costs[i] = Math.abs(inputs[1] - inputs[0])
            continue
        }

        val costsM1 = costs[i-1] +  Math.abs(inputs[i] - inputs[i-1])
        val costSM2 = costs[i-2] +  Math.abs(inputs[i] - inputs[i-2])

        costs[i] = Math.min(costsM1, costSM2)
    }

    println(costs[n-1])
}

Measured memory_bytes: 48728
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
ll GCD(ll a, ll b){
  if(b == 0){
    return a;
  }
  return GCD(b, a%b);
}
#define SIEVE_SIZE 1010101
bool sieve[SIEVE_SIZE];
int cnt[1010101];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;
  vector<ll> A(N);

  ll d = 0;
  bool check = true;
  REP(i,N) {
    cin >> A[i];
    d = GCD(d, A[i]);
    cnt[A[i]]++;
  }

  if(d != 1){
    cout << "not coprime" << endl;
  }else{
    memset(sieve, true, sizeof(sieve));
    sieve[0] = sieve[1] = false;
    for(int i=2; i<=1000000; i++){
      if(sieve[i]){
        
        int a = cnt[i];

        for(int j=2; i*j<=1000000; j++){
          sieve[i*j] = false;
          a += cnt[i*j];
        }
        if(a >= 2)check = false;
      }
    }
    if(check){
      cout << "pairwise coprime" << endl;
    }else{
      cout << "setwise coprime" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 15824
package main

import (
	"fmt"
)

func main() {
	var N string
	fmt.Scan(&N)

	res := "No"
	if N[0:1] == "7" || N[1:2] == "7" || N[2:3] == "7" {
		res = "Yes"
	}

	fmt.Println(res)
}


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const int N = 1e6 + 7;

int first[N];
int last[N];

int main() {
  _upgrade;
  int n, k, c;
  cin >> n >> k >> c;
  string calendar;
  cin >> calendar;

  int day = 0;
  for (int i = 1; i <= k; i++) {
    while (calendar[day] == 'x') {
      day++;
    }
    first[i] = day;
    day += (c + 1);
  }

  day = sz(calendar) - 1;
  for (int i = k; i >= 1; i--) {
    while (calendar[day] == 'x') {
      day--;
    }
    last[i] = day;
    day -= (c + 1);
  }

  for (int i = 1; i <= k; i++) {
    if (first[i] == last[i]) {
      cout << first[i] + 1 << " ";
    }
  }
  cout << '\n';

  return 0;
}

Measured memory_bytes: 6676
#include<ctype.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
inline ll gcd(ll a,ll b){while(a)a^=b^=a^=b%=a;return b;}
inline ll read ( )
{
	ll o=0,fl=1;
	char ch=getchar();
	while(!isdigit(ch))o^=ch=='-',ch=getchar();
	while(isdigit(ch))o=10*o+ch-48,ch=getchar();
	return fl?o:-o;
}
ll n,m,p,q,k;
char s1[200010],s2[200010];
int main ( )
{
	n=read();m=read();
	cin>>s1>>s2;
	p=n/gcd(n,m)*m;
	q=p/m;p=p/n;
	k=p/gcd(p,q)*q;
	int f=p;
	p=k/q,q=k/f;
	f=p;p=q;q=f;
	//printf("%lld %lld %lld %lld\n",n,m,p,q);
	for(int i=0;i<n/p;i++)
		if(s1[i*p]!=s2[i*q])
			return puts("-1")&0;
	printf("%lld",n/gcd(n,m)*m);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007
int main(){
    int n;
    cin >>n;
    string S,T;
    cin >> S >> T;
    for(int i=0;i<n;i++){
        cout << S[i] << T[i];
    }
    cout <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>

using namespace std;

map<char, int> mp;

int main(void)

{
    int a, f = 0;
    string s;
    char ch;
    cin>>s;
    a = s.size();
    for(int i = 0; i < a; i++){
        ch = s[i];
        mp[ch]++;
    }
    map<char, int> :: iterator it;
    for(it = mp.begin(); it != mp.end(); it++){
        if(it->second%2 == 1){
            f = 1;
            break;
        }
    }
    if(f)cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
# Binary Indexed Tree (Fenwick Tree)
class BIT():

    def __init__(self, n):
        '''
        n = 要素数
        添字は i = 0 ~ n-1 となる
        '''
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, x):
        '''i番目の要素にxを加算する'''
        i = i + 1
        while i <= self.n:
            self.bit[i] += x
            i += i & -i

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def get(self, i, j):
        '''[i, j)の和を求める'''
        return self._sum(j) - self._sum(i)

      
def solve():
    ok = len_memo
    ng = 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if 2 * bit1.get(mid, len_memo) <= cnt :
            ok = mid
        else:
            ng = mid
    return memo_inv[ng]
    

def compress(list1):
    list2 = sorted(set(list1))
    memo = {value : index for index, value in enumerate(list2)}
    #for i in range(len(list1)):
    #    list1[i] = memo[list1[i]]
    return memo, len(list2)

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

#座圧する
li1 = []
for i in range(q):
    if info[i][0] == 1:
        li1.append(info[i][1])

memo, len_memo = compress(li1)
memo_inv = dict([(v,k) for k,v in memo.items()])
#print(memo)
#print(memo_inv)

#値を管理するBIT
bit = BIT(len_memo)
#要素数を管理するBITに
bit1 = BIT(len_memo)

x = []
b = 0
cnt = 0
for i in range(q):
    if info[i][0] == 1:
        bit.add(memo[info[i][1]], info[i][1])
        bit1.add(memo[info[i][1]], 1)
        b += info[i][2]
        cnt += 1
    if info[i][0] == 2:
        median_x = solve()
        sum1 = bit.get(0, memo[median_x])
        num1 = bit1.get(0, memo[median_x])
        sum2 = bit.get(memo[median_x], len_memo)
        num2 = bit1.get(memo[median_x], len_memo)
        #print(median_x, sum1,num1, sum2, num2)
        print(median_x, abs(num1*median_x - sum1) + abs(num2*median_x - sum2) + b)


Measured memory_bytes: 124752
def solve(A, B, K):
    yakusu = list()
    for i in range(1, 101):
        if A % i == 0 and B % i == 0:
            yakusu.append(i)
    return yakusu[-K]


A, B, K = map(int, input().split())
print(solve(A, B, K))


Measured memory_bytes: 2940
x, y = map(int,input().split())

def judge_abc(z):
    A = [1, 3, 5, 7, 8, 10, 12]
    B = [4, 6, 9, 11]
    C = [2]
    if z in A: return 1
    elif z in B: return 2
    else: return 3

if judge_abc(x)==judge_abc(y):print('Yes')
else:print('No')


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

const int INF=1001001001001001001ll;

int N,M;

int dp[1<<12];
signed main(){
	fill_n(dp,1<<12,INF);
	cin>>N>>M;

	dp[0]=0;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		int m=0;
		rep(j,b){
			int c;cin>>c;c--;
			m|=1<<c;
		}

		rep(j,1<<N)chmin(dp[j|m],dp[j]+a);
	}

	int ans=dp[(1<<N)-1];
	if(ans==INF)cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  int ans = 0;
  for(int i=0; i<n+1; i++){
    int sum = 0;//各桁の総和
    sum = i%10+i/10%10+i/100%10+i/1000%10+i/10000%10;
    
    if(sum>=a && sum <=b){
      ans += i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

n, k = map(int, input().split())
n = max(0, n-2)
ans = 0
f = lambda i, j : sum(7*(i+x//3+1)+(j+x%3+1)-7 for x in range(9)) % 11 == k
h = [0] * 11
for i in range(min(n, 11)):
    h[i] = sum(1 for x in range(5) if f(i, x))
ans = sum(h) * (n // 11) + sum(h[i] for i in range(n % 11))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<functional>
#include<queue>
#include<vector>
using namespace std;
long long dist[12000][210][2];
long long T[12000], n, m, p;
vector<pair<long long, long long>>X[12000];
vector<tuple<long long, long long, long long, long long>>Y[12000][210][2];//[to, cost, minute, heya]
priority_queue<pair<long long, tuple<long long, long long, long long>>, vector<pair<long long, tuple<long long, long long, long long>>>, greater<pair<long long, tuple<long long, long long, long long>>>> Q;
int main() {
	cin >> n >> m >> p;
	for (int i = 1; i <= n; i++)cin >> T[i];
	for (int i = 0; i < m; i++) {
		int a, b, c; cin >> a >> b >> c;
		X[a].push_back(make_pair(b, c));
		X[b].push_back(make_pair(a, c));
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= p; j++) {
			for (int k = 0; k < X[i].size(); k++) {
				long long to = X[i][k].first, cost = X[i][k].second;
				long long H2 = T[to];
				if (H2 == 0) {
					Y[i][j][0].push_back(make_tuple(to, cost, 0, 0));
					if (j + cost >= p)Y[i][j][1].push_back(make_tuple(to, cost, 0, 0));
				}
				if (H2 == 1) {
					Y[i][j][0].push_back(make_tuple(to, cost, min(p, j + cost), 0));
					Y[i][j][1].push_back(make_tuple(to, cost, min(p, j + cost), 1));
				}
				if (H2 == 2) {
					if (j + cost >= p)Y[i][j][0].push_back(make_tuple(to, cost, 0, 1));
					Y[i][j][1].push_back(make_tuple(to, cost, 0, 1));
				}
			}
		}
	}
	Q.push(make_pair(0, make_tuple(1, 0, 0)));
	for (int i = 0; i < 12000; i++) {
		for (int j = 0; j < 210; j++) {
			dist[i][j][0] = 1LL << 60; dist[i][j][1] = 1LL << 60;
		}
	}
	dist[1][0][0] = 0; Q.push(make_pair(0, make_tuple(1, 0, 0)));
	while (!Q.empty()) {
		long long a1 = get<0>(Q.top().second), a2 = get<1>(Q.top().second), a3 = get<2>(Q.top().second); Q.pop();
		for (int i = 0; i < Y[a1][a2][a3].size(); i++) {
			int to1 = get<0>(Y[a1][a2][a3][i]), to2 = get<2>(Y[a1][a2][a3][i]), to3 = get<3>(Y[a1][a2][a3][i]);
			int cost4 = get<1>(Y[a1][a2][a3][i]);
			if (dist[to1][to2][to3] > dist[a1][a2][a3] + cost4) {
				dist[to1][to2][to3] = dist[a1][a2][a3] + cost4;
				Q.push(make_pair(dist[to1][to2][to3], make_tuple(to1, to2, to3)));
			}
		}
	}
	long long minx = 1LL << 60;
	for (int i = 0; i <= p; i++) { minx = min(minx, min(dist[n][i][0], dist[n][i][1])); }
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 778276
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c ;
  int ans = 0;
  
  if(a==b) ans++;
  if(b==c) ans++;
  if(c==a) ans++;
  
  if(ans==1) cout << "Yes" << endl;
  else cout << "No"<< endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<ll> A(N,0);
  ll ans = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  ll P = 1;
  for(ll bit=0;bit<60;bit++){
    ll s=0,t=0;
    for(int i=0;i<N;i++){
      if(A[i]%2>0){
        s ++;
      }else{
        t ++;
      }
      A[i] /= 2;
    }
    ans += (((s*t)%MOD*P)%MOD);
    ans %= MOD;
    P = P * 2 % MOD;
  }
  cout << ans << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(), count=0;
		int[] length = new int[n];
		for(int i=0;i<n;i++) length[i]=sc.nextInt();
		Arrays.sort(length);
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n-1;j++) {
				int left=0,right=n, tar=length[i]+length[j];
				while(right-left>1) {
					int mid = (left+right)/2;
					//if(left>=right || length[mid]==tar) break;
					if(length[mid]<tar) left = mid;
					else right=mid;
				}
				//if(length[mid]>=tar) mid--;
				count+=(left-j);
			}
		}
		System.out.println(count);
	}
}

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

int main(){
    int n;
    cin >>n;
    float arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    sort(arr,arr+n);
    float k = 0;
    for(int i=0;i<n-1;i++){
        k = (arr[i]+arr[i+1])/2;
        arr[i+1] = k;
    }
    cout << k << endl;
}

Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
L, R = np.array(list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)])))

print((R - L + 1).sum())


Measured memory_bytes: 13664
#include <stdio.h>

void judge(int x){
	
	if(x == 1){
		printf("Yes\n");
	}else if(x == 0){
		printf("No\n");
	} 
}

int main(void) {
	char word[100];
	scanf("%s",&word);
	
	int i=0;
	int flagC=0;
	int flagF=0;
	int SuccessCntC=0, SuccessCntF=0;
	int SuccessFlag=0;
	
	while(word[i]!='\0'){
		if(word[i]=='C'){
			flagC = i;
			SuccessCntC++;
		}else if(word[i]=='F'){
			flagF = i;
			SuccessCntF++;
		}
		i++;
	}
	
	if(SuccessCntC > 0 && SuccessCntF >0){
		SuccessFlag=1;
	}
	
	if(SuccessFlag == 1 && flagC < flagF){
		judge(1);
	}else{
		judge(0);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll const mod=1e9+7;
double const pi=acos(-1); 
int main()
{
	int n,m;
	cin>>n>>m;
	if(n%2==1)
	{
		for(int i=1;i<=n&&m!=0;i++)
		{
			cout<<i<<" "<<n-i<<endl;
			m--;
		}
	}
	else
	{
		int s=(n+1)/2;
		for(int i=1;i<=s/2&&m!=0;i++)
		{
			cout<<i<<" "<<s-i+1<<endl;
			m--;
		}
		for(int i=1;m!=0;i++)
		{
			cout<<i+s<<" "<<n-i<<endl;
			m--;
		}
	}
	
 	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 1000000007;

int dw(int x) {
  return x < mod ? x : x - mod;
}

const int N = 4100;
int bin[N][N];
int bins[N][N + 1];
int bin2[N][N + 1];

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a == 1 || b == 1) {
    cout << a + b << endl;
    return 0;
  }
  if (a == 2 || b == 2) {
    cout << (a + b) * (a + b - 1) / 2 % mod << endl;
    return 0;
  }
  for (int i = 0; i < N; ++i) {
    bin[i][0] = 1;
    for (int j = 1; j <= i; ++j) bin[i][j] = dw(bin[i-1][j] + bin[i-1][j-1]);
    bins[i][0] = 0;
    for (int j = 0; j < N; ++j) bins[i][j+1] = dw(bins[i][j] + bin[i][j]);
    bin2[i][0] = 0;
    for (int j = 0; j < N; ++j) bin2[i][j+1] = dw(bin2[i][j] + bins[i][j]);
  }
  ll res = 0;
  for (int i = 1; i <= a + 1; ++i) {
    res += 1;
//    if (i == a + 1) continue;
    for (int cb = max(0, b - 2 - a + i); cb <= b - 2; ++cb) {
      int l = a + 1 - i;
      int remb = b - 1 - cb;
      int rema = l - remb;
      assert(l >= remb && remb >= 1);
      int c0 = max(0, rema - remb + 1);
      res = (res + bin[b-1][cb] * (ll)bins[remb - 1][remb] % mod * c0) % mod;
      res = (res + bin[b-1][cb] * (ll)(bin2[remb - 1][rema - c0 + 2] - bin2[remb-1][1])) % mod;
//      for (int ca = 1; ca <= rema - c0 + 1; ++ca) {
//        res = (res + bin[b-1][cb] * (ll)bins[remb - 1][ca]) % mod;
//      }
//      cerr << i << ' ' << cb << ' ' << l << ' ' << remb << endl;
    }
  }
  cout << (res % mod + mod) % mod << endl;
  return 0;
}

Measured memory_bytes: 197248
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int num[100010]={};

int cmp (const void *a,const void *b)
{
    return *(int *)a - *(int *)b;
}

int main()
{
    int n;
    int i;
    int sum;
    while (scanf("%d",&n)!=EOF)
    {
        memset(num,0,sizeof (num));
        sum=n;
        for (i=0;i<n;i++)
        {
            scanf("%d",&num[i]);
        }
        qsort(num,n,sizeof (num[0]),cmp);
        for (i=1;i<n;i++)
        {
            if (num[i]==num[i-1])
            {
                sum-=2;
                i++;
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1020
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  int n;
  cin >> n;
  vector<int>a(n),b(n);
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  int ans = 0;
  rep(i,n){
    int tmp = 0;
    bool up = true;
    rep(j,n){
      if(j == i){
        tmp += a[i] + b[i];
        up = false;
      }
      else{
        if(up)tmp += a[j];
        else tmp += b[j];
      }
    }
    ans = max(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  solve();
  return 0;
}

Measured memory_bytes: 256