akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){

       int n,x,t,l;
       cin>>n>>x>>t;
       l=n/x;
       if(n%x==0){

       cout<<l*t<<endl;
       }
       else{
        cout<<(l+1)*t<<endl;
       }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;


vector<int> v[100001];

P dfs(int x,int y){
    LL b=1,w=1;
    for (int i = 0; i < v[x].size(); i++) {
        if(v[x][i]==y) continue;
        P p=dfs(v[x][i],x);
        w*=(p.fs+p.sc)%mod;
        w%=mod;
        b*=(p.fs)%mod;
        b%=mod;
    }
    return P(w,b);
}



int main(){
    int N;cin >> N;
    for (int i = 0; i < N-1; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    P p=dfs(0,0);
    cout << (p.fs+p.sc)%mod << endl;
    return 0;
}




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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define push_back pb

typedef long long ll;

const int N = 200001;

vector <int> adj[N];

int main()
{
    FAST_IO;
    int a, b;
    cin >> a >> b;
    for (int i = (b - a + 1); i <= (b + a - 1); i++) cout << i << " ";
    return 0;
}


Measured memory_bytes: 4992
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N,W; cin >> N >> W;
  vector<ll> dp(W+1, -1);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    ll w,v; cin>>w>>v;
    for (int t = W-w; t >= 0; t--) if (dp[t] != -1)
      dp[t+w] = max(dp[t+w], dp[t] + v);
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int a[108][108],b[108][64],x[6],l,m,n,o;
void fn(int p,int q,int r){
  int i;
  if(p==l+m+1&&q==(~((~0)<<l))){
    if(b[p][q]>r)
      b[p][q]=r;
  }else if(b[p][q]>r){
    b[p][q]=r;
    for(i=0;i<l+m+2;i++){
      if(a[p][i]!=-1){
	if(i<l){
	  if((q&(1<<i))==0)
	    fn(i,q|(1<<i),r+a[p][i]-x[i]);
	}else{
	  fn(i,q,r+a[p][i]);
	}
      }
    }
  }
  return;
}
int main(){
  int i,j;
  while(cin>>l>>m>>n>>o&&(l||m||n||o)){
    for(i=0;i<l;i++)
      cin>>x[i];
    memset(a,-1,sizeof(a));
    for(i=0;i<o;i++){
      int p,q,r;
      char s;
      cin>>s;
      if(0){
      }else if(s=='C'){
	cin>>p>>s;
	p--;
	if(0){
	}else if(s=='C'){
	  cin>>q>>r;
	  q--;
	}else if(s=='L'){
	  cin>>q>>r;
	  q+=l-1;
	}else if(s=='H'){
	  cin>>r;
	  q=l+m;
	}else if(s=='D'){
	  cin>>r;
	  q=l+m+1;
	}
      }else if(s=='L'){
	cin>>p>>s;
	p+=l-1;	
	if(0){
	}else if(s=='C'){
	  cin>>q>>r;
	  q--;
	}else if(s=='L'){
	  cin>>q>>r;
	  q+=l-1;
	}else if(s=='H'){
	  cin>>r;
	  q=l+m;
	}else if(s=='D'){
	  cin>>r;
	  q=l+m+1;
	}
      }else if(s=='H'){
	p=l+m;
	cin>>s;
	if(0){
	}else if(s=='C'){
	  cin>>q>>r;
	  q--;
	}else if(s=='L'){
	  cin>>q>>r;
	  q+=l-1;
	}else if(s=='D'){
	  cin>>r;
	  q=l+m+1;
	}
      }else if(s=='D'){
	p=l+m+1;
	cin>>s;
	if(0){
	}else if(s=='C'){
	  cin>>q>>r;
	  q--;
	}else if(s=='L'){
	  cin>>q>>r;
	  q+=l-1;
	}else if(s=='H'){
	  cin>>r;
	  q=l+m;
	}
      }
      a[p][q]=a[q][p]=r*n;
    }
    for(i=0;i<l+m+2;i++)
      for(j=0;j<(1<<l);j++)
	b[i][j]=1<<30;
    fn(l+m,0,0);
    int mn=1<<30;
    for(i=0;i<(1<<l);i++)
      mn=min(mn,b[l+m+1][i]);
    cout<<mn<<endl;
  }
  return 0;
}

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

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

    int A, B; 
    cin >> A >> B;

    int n[] = {A + B, A - B, A * B};
    cout << *max_element(n, n + 3) << endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8


def main():
    N = int(input())

    fs = [0] * N
    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 100):
                i = (x**2) + (y**2) + (z**2) + (x*y) + (y*z) + (z*x)
                if i <= N:
                    fs[i-1] += 1

    for i in range(N):
        print(fs[i])


main()
# print(main())


Measured memory_bytes: 9136
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N, K;
    string S;
    cin >> N >> K >> S;

    int wrong = 0;

    for (int i = 1; i < N; i++) wrong += (S[i] != S[i - 1] ? 1 : 0);
    int ans = N - 1 - wrong;
    ans += min(wrong, K * 2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
from statistics import median
from fractions import gcd

N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))

if X < x[0]:
  ans = x[0] - X
elif X > x[len(x)-1]:
  ans = X - x[len(x)-1]
else:
  for i in range(len(x)-1):
    if x[i] < X < x[i+1]:
      if X - x[i] > x[i+1] - X:
        ans = x[i+1] - X
      else:
        ans = X - x[i] 

for i in range(1, len(x)):
  ans = gcd(ans, x[i] - x[i-1])

print(ans)

Measured memory_bytes: 16340
import numpy as np
h,w=map(int,input().split())
maze = []
for i in range(h):
  maze.append([0 if x=="#" else float('INF') for x in list(input())])
maze = np.array(maze)

for i in range(1,h):
  maze[i,:] = np.minimum(maze[i,:],maze[i-1,:]+1)
for j in range(h-2,-1,-1):
  maze[j,:] = np.minimum(maze[j,:],maze[j+1,:]+1)
for k in range(1,w):
  maze[:,k] = np.minimum(maze[:,k],maze[:,k-1]+1)
for l in range(w-2,-1,-1):
  maze[:,l] = np.minimum(maze[:,l],maze[:,l+1]+1)


print(int(np.max(maze)))

Measured memory_bytes: 52420
import itertools

n = int(input())
a_l = list(map(int, input().split()))
index_l = [i for i in range(len(a_l))]

# print(a_l)
# print(index_l)

max_ans = 0
for v in itertools.combinations(index_l, 2):
#   print(v[0])
#   print(v[1])
    ans = abs(a_l[v[0]] - a_l[v[1]])
    # print(ans)
    max_ans = max(max_ans, ans)
    
print(max_ans)

Measured memory_bytes: 9188
package main

import (
	"fmt"
)

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scanln(&n)
	pt, px, py := 0, 0, 0
	for i := 0; i < n; i++ {
		var t, x, y int
		fmt.Scanln(&t, &x, &y)
		rt := (t - pt) - (Abs(x-px) + Abs(y-py))
		if rt < 0 || rt%2 != 0 {
			fmt.Println("No")
			return
		}
		pt, px, py = t, x, y
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    if A + B >= C:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()


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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  for (int i=0; i<n; i++)
    cin >> l.at(i);
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int sum = 0;
  for (int i=0; i<k; i++)
    sum += l.at(i);
  
  cout << sum << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  ll n,k;
  cin >> n >> k;
  
  map <ll,ll>num;
  
  REP(i,n){
    int x,y;
    cin >> x >> y;
    num[x] += y;
  }
  
  ITR(itr,num){
    k -= itr->second;
    if(k <= 0){
      cout << itr->first << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

int modpow(int x, int y, int p = mod) 
{ 
	int res = 1;       
	x %= p;   
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res * x) % p; 
		y >>= 1;
		x = (x * x) % p;   
	} 
	return res; 
} 
int add(int x, int y) 
{
	x %= mod;
	y %= mod;
	x += y;
	if (x >= mod) return x - mod;
	return x;
}
int sub(int x, int y) 
{
	x %= mod;
	y %= mod;
	x -= y;
	if (x < 0) return x + mod;
	return x;
}
int inv(int a, int m = mod)
{
	a %= mod;
	return modpow(a, m - 2, m);
}
int mul(int a, int b) 
{
	a %= mod;
	b %= mod;
	return (long long) a * b % mod;
}

const int maxn = 1e5 + 10;
int fac[maxn], invfac[maxn];
int ncr(int n, int r)
{
	int ans = mul(fac[n], mul(invfac[r], invfac[n - r]));
	return ans;
}
int a[maxn];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	fac[0] = invfac[0] = 1;
	for(int i = 1; i < maxn; ++ i)
	{
		fac[i] = mul(i, fac[i - 1]);
		invfac[i] = inv(fac[i]);
	}
	
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	int ans = 0;
	
	for(int i = 1; i <= n; ++ i)
	{
		int bef = i - 1;
		int aft = n - i;
		int to = k - 1;
		if(aft >= to)
		{
			int mini = mul(ncr(aft, to), a[i]);
			
			ans = sub(ans, mini);
		}
		if(bef >= to)
		{
			int maxi = mul(ncr(bef, to), a[i]);
			ans = add(ans, maxi);
		}
	}
	cout << ans << '\n';
	
	return 0;
}






Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
  int a[1000], n, i, j, k, v;
  scanf("%d", &n);
  for(k = 0; k < n; k++)
    {
      scanf("%d",&a[k]);
    }
  for(k = 0; k < n-1; k++)
    {
      printf("%d ",a[k]);
    }
  printf("%d\n", a[n-1]);
  for(i = 1; i < n; i++)
    {
      v = a[i];
      j = i - 1;
      while (j >= 0 && a[j] > v)
	{
	  a[j+1] = a[j];
	  j--;
	  a[j+1] = v;
	}
      for(k = 0; k < n-1; k++)
	{
	  printf("%d ",a[k]);
	}
      printf("%d\n", a[n-1]);
    }
  return 0;
}



Measured memory_bytes: 2124
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n == 1) {
		    System.out.println(3);
		    return;
		}
		char[] arr1 = sc.next().toCharArray();
		char[] arr2 = sc.next().toCharArray();
		int[] types = new int[n];
		int idx = 0;
		int charIdx = 0;
		while (idx < n) {
		    if (arr1[charIdx] == arr2[charIdx]) {
		        types[idx] = 1;
		        charIdx++;
		        idx++;
		    } else {
		        types[idx] = 2;
		        types[idx + 1] = 3;
		        charIdx += 2;
		        idx += 2;
		    }
		}
		int[][][] dp = new int[3][3][n];
		dp[0][1][1] = 1;
		dp[0][2][1] = 1;
		dp[1][0][1] = 1;
		dp[1][2][1] = 1;
		dp[2][0][1] = 1;
		dp[2][1][1] = 1;
        for (int i = 2; i < n; i++) {
            for (int a = 0; a < 3; a++) {
                for (int b = 0; b < 3; b++) {
                    for (int c = 0; c < 3; c++) {
                        if (types[i] == 1) {
                            if (b == c || (types[i - 1] != 1 && a == c)) {
                                continue;
                            }
                        } else if (types[i] == 2) {
                            if ((types[i - 1] != 1 && a == c) || (types[i - 1] == 1 && b == c)) {
                                continue;
                            }
                        } else {
                            if (b == c || a == c) {
                                continue;
                            }
                        }
                        dp[b][c][i] += dp[a][b][i - 1];
                        dp[b][c][i] %= MOD;
                    }
                }
            }
        }
        int total = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                total += dp[i][j][n - 1];
                total %= MOD;
            }
        }
        System.out.println(total);
   }
}




Measured memory_bytes: 21844
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


n = int(input())

ans = 0
totalNum = -1
for i in range(1,n+1):
    temp = i
    num = 0
    while True:
        if (temp % 2 != 0):
            break
        else:
            temp = temp // 2
            num+=1
    if (totalNum < num):
        totalNum = num
        ans = i
print(ans)




Measured memory_bytes: 9144
N = int(input())
A = list(map(int, input().split())) 
ans = 1
ikiti = pow(10,18)
if 0 in A:
    print(0)
else:
    ikiti = pow(10,18)
    for i in range(0,N):
        ans = ans * A[i]
        if ans > ikiti:
            print(-1)
            break
    if ans <= ikiti:
        print(ans)

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


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


    int dp[100000][3] = {};  // dp[i][j]: maximum happiness when choose j in i-th day
    for( int i = 0; i < 3; ++i ) dp[0][i] = a[0][i];

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

    sort( dp[N-1], dp[N-1]+3 );
    cout << dp[N-1][2] << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long x = scan.nextLong();
        long y = 100;
        int year = 0;
        outloop:for(int i = 1; ;i++){
            y = y + (y/100);
            if (y>=x){
                year = i;
                break outloop;
            }
        }
        System.out.println(year);
        }
        }

Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int h,w;cin>>h>>w;
  vs a(h);
  rep(i,h)cin>>a[i];
  rep(i,w+2)cout<<"#";
  cout<<endl;
  rep(i,h)cout<<"#"<<a[i]<<"#"<<endl;
  rep(i,w+2)cout<<"#";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
k       = int(input())

def predicate_green():
    return b > a

def predicate_blue():
    return c > b

while k != 0:
    if not predicate_green():
        b *= 2
        k -= 1

    elif not predicate_blue():
        c *= 2
        k -= 1

    else:
        break

if c > b > a:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 9180
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> maize(h);
    REP(i,h) {
        string s;
        cin >> s;
        REP(j, s.size()) {
            if(s[j]=='#') {
                maize[i].push_back(false);
            }else{
                maize[i].push_back(true);
            }
        }
    }

    int ans = 0;
    REP(i,h)
    REP(j,w) {
        vector<vector<int>> dist(h);
        REP(nn,h) dist[nn].resize(w,-1);
        queue<P> que;
        
        auto push = [&] (int nx, int ny, int nd) {
            if(nx < 0 || ny < 0 || nx >= w || ny >= h) return;
            if(dist[ny][nx] != -1 || !(maize[ny][nx])) return;
            que.push(make_pair(nx,ny));
            dist[ny][nx] = nd;
        };

        push(j,i,0);
        while(!que.empty()) {
            P tmp = que.front(); que.pop();
            int newx = tmp.first;
            int newy = tmp.second;
            int tmpd = dist[newy][newx];

            push(newx+1, newy, tmpd+1);
            push(newx-1, newy, tmpd+1);
            push(newx, newy+1, tmpd+1);
            push(newx, newy-1, tmpd+1);
        }
        REP(i,h)
        REP(j,w) {
            ans = max(ans,dist[i][j]);
        }
    }
    cout  << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<cstdlib>
#include<ctime>
#include<cctype>

using namespace std;

int n;
int h[100010];
int dp[100010];
int k;
int main()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	memset(dp, 0x3f3f, sizeof(dp));
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for(int i = 3; i <= n; i++)
	{
		for(int l = 1; l <= k && (i - l)>= 1; l++)
		{
			dp[i] = min(dp[i], dp[i-l] + abs(h[i] - h[i-l]));
		}
	}
	cout << dp[n] << endl; 
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
rate = list(map(int, input().split()))
color = [0 for _ in range(9)]
for i in range(N):
    if rate[i] <= 399:
        color[0] += 1
    if rate[i] >= 400 and rate[i] <= 799:
        color[1] += 1
    if rate[i] >= 800 and rate[i] <= 1199:
        color[2] += 1
    if rate[i] >= 1200 and rate[i] <= 1599:
        color[3] += 1
    if rate[i] >= 1600 and rate[i] <= 1999:
        color[4] += 1
    if rate[i] >= 2000 and rate[i] <= 2399:
        color[5] += 1
    if rate[i] >= 2400 and rate[i] <= 2799:
        color[6] += 1
    if rate[i] >= 2800 and rate[i] <= 3199:
        color[7] += 1
    if rate[i] >= 3200:
        color[8] += 1
CV = 8- color[0:8].count(0)
if CV == 0:
    mi = 1
else:
    mi = CV
ma = CV + color[8]
print(mi, ma)

Measured memory_bytes: 3064
a,b,c=map(int,input().split())
if a<b:
    if a<c:
        if b<c:
            print(a,b,c)
        else:
            print(a,c,b)
    else:
        print(c,a,b)
else:
    if a<c:
        print(b,a,c)
    else:
        if b<c:
            print(b,c,a)
        else:
            print(c,b,a)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 



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

int N, Q; string S;
cin >> N >> S >> Q;

vector<set<int>> pos(26, set<int>({1<<30}));
rep(i, 0, N) {
    pos[S[i] - 'a'].insert(i);
}

while(Q--){
    int q; cin >> q;
    if (q == 1){
        int i; char c; cin >> i >> c;
        pos[S[i-1] - 'a'].erase(i-1);
        pos[c - 'a'].insert(i-1);
        S[i-1] = c;
    }
    else {
        int l, r; cin >> l >> r;
        int c = 0;
        for(set<int> &p: pos) if (!p.empty())
            if (*p.lower_bound(l-1) < *p.lower_bound(r)) ++c;

        cout << c << "\n";
    }
}

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 24220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

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



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

int main() {
  int S;
  cin >> S;
  int s12,s34;
  s12 = S/100;
  s34 = S%100;
  if((1<=s12)&&(s12<=12)){
    if((1<=s34)&&(s34<=12)) cout << "AMBIGUOUS";
    else cout << "MMYY";
  }
  else{
    if((1<=s34)&&(s34<=12)) cout << "YYMM";
    else cout << "NA";
  }
}

Measured memory_bytes: 256
s = gets.chomp.reverse!
t = gets.chomp.reverse!
pattern = "";
0.upto(t.length - 1) {|i| pattern += "[#{t[i]}?]" }
s = s.sub!(/#{pattern}/, t)
if s 
  s.gsub!(/[?]/, 'a')
  puts s.reverse
else
  puts 'UNRESTORABLE'
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
 
int main() {
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		if (i%3==0){
			cout<<" "<<i;
		}
		else if (i%10==3||i%100/10==3||i%1000/100==3||i/1000==3){
			cout<<" "<<i;
		}
	}
	cout<<endl;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> d(n);
  rep(i,n){
  cin>>d[i];
  }
  
  int sum=0;
  rep(i,n-1){
   for(int j=i+1;j<n;j++){
      sum+=d[i]*d[j];
    }
  }
  
  cout<<sum<<endl;
  
  
  }
  

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

int main()
{
  int N ;
  cin>>N ;
  vector<int>a ;
  for(int i=0;i<N;i++){
    int temp ;
    cin>>temp ;
    a.push_back(temp) ;
    a.push_back(temp-1) ;
    a.push_back(temp+1) ;
  }
  sort(a.begin(),a.end()) ;

  int pre_value=a.at(0) ;
  int start=0 ;
  int max=0 ;
  for(int i=0;i<3*N;i++){
    if(pre_value!=a.at(i)){
      if(i-1-start>max) max=i-1-start ;
      start=i-1 ;
      pre_value=a.at(i) ;
    }
  }
  cout<<max<<endl ;
 
  return 0 ;
}


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

void printVec(std::vector<int> &vec)
{
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it)
  {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
int main() {
  // string S, T;
  // cin >> S >> T;
  // int A, B;
  // cin >> A >> B;
  // string U;
  // cin >> U;
  // if (U == S) {
  //   A -= 1;
  // } else {
  //   B -= 1;
  // }
  // cout << A << " " << B;

  // string S;
  // cin >> S;
  // int len;
  // len = S.length();
  // string ans;
  // for (int i = 0; i < len; i++) {
  //   ans += "x";
  // }
  // cout << ans << endl;

  // int N;
  // cin >> N;
  // vector<int> A(N, 0);
  // for (int i = 0; i < N; i++)
  // {
  //   int val;
  //   cin >> val;
  //   A.at(i) = val;
  // }
  // int org_len = A.size();
  // sort(A.begin(), A.end());
  // A.erase(unique(A.begin(), A.end()), A.end());
  // if (org_len == A.size())
  // {
  //   cout << "YES" << endl;
  // } else {
  //   cout << "NO" << endl;
  // }

  int N, K;
  cin >> N >> K;
  vector<int> p(N, 0);
  for (int i = 0; i < N; i++) {
    int val;
    cin >> val;
    p.at(i) = val;
  }
  vector<double> s(N+1, 0);
  for (int i = 0; i < N; ++i) {
    s[i + 1] = s[i] + (1.0/2.0) * (1 + p[i]);
  }
  double res = 0;
  for (int i = K; i <= N; i++) {
    double val;
    val = s[i] - s[i-K];
    res = max(res, val);
  }
  std::cout << std::fixed << setprecision(12) << res << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>

bool contains(int w, int h, int x, int y, int r){
  return !(x - r < 0 || x + r > w || y - r < 0 || y + r > h);
}

int main(){
  int w, h, x, y, r;
  std::cin >> w;
  std::cin >> h;
  std::cin >> x;
  std::cin >> y;
  std::cin >> r;

  if(contains(w, h, x, y, r)){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    multiset<int> ms;
    for(int i = 0; i < pow(2,n); i++)
    {
        int a;
        cin >> a;
        ms.insert(a);
    }
    int ma = *ms.rbegin();
    if(ms.count(ma) != 1)
    {
        cout << "No" << endl;
        return 0;
    }
    multiset<int> make;
    make.insert(ma);
    ms.erase(ms.find(ma));
    for(int i = 0; i < n; i++)
    {
        int size = make.size();
        auto itr = make.begin();
        multiset<int> tmp;
        for(int j = 0; j < size; j++)
        {
            auto msitr = ms.lower_bound(*itr);
            if(msitr == ms.begin())
            {
                cout << "No" << endl;
                return 0;
            }
            msitr--;
            tmp.insert(*msitr);
            ms.erase(msitr);
            itr++;
        }
        make.insert(tmp.begin(), tmp.end());
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 18688
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while (true) {
            // H height,W weight
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) {break;}

            for (int i = 1; i <= H;i++) {
                // 奇数行
                if (i%2 == 1) {
                for (int j = 1; j <= W; j++) {
                    if (j%2 == 1){
                        System.out.print("#");
                    } else if (j%2 == 0) {
                        System.out.print(".");
                    }
                }
                System.out.println();
                // 偶数行
                } else if (i%2 == 0) {
                for (int j = 1; j <= W; j++) {
                    if (j%2 == 1){
                        System.out.print(".");
                    } else if (j%2 == 0) {
                        System.out.print("#");
                    }
                }
                System.out.println();
                }
            }
            System.out.println();

        }
    }
}


Measured memory_bytes: 36988
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
int main(){
    int D, N;
    cin >> D >> N;
    int ans = 1;
    if(N == 100){
        if(D == 0) ans = 101;
        else if(D == 1) ans = 10100;
        else if(D == 2) ans = 1010000;
    }else{
        for(int i=0; i<D; i++){
            ans = ans * 100;
        }
        ans = N * ans;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int X,Y,temp=0;
  string ans;
  cin >> X >> Y;

  for(int i=0;i<=X;i++){
    temp=2*i+4*(X-i);
    if(temp==Y){
      ans="Yes";
      break;
    }else{
      ans="No";
      continue;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
n = int(input())
value = tuple(map(int, input().split()))
cost = tuple(map(int, input().split()))
# iこめまでのxーyの最大値
inf = -100
dp = [inf] * (n+1)
dp[1] = max(0, value[0]-cost[0])
for i in range(2, n+1):
    dp[i] = max(dp[i-1], dp[i-1]+value[i-1]-cost[i-1])

print(dp[n])


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

int main() {
  
  ll n , k;
  cin >> n >> k;
  
  vector<int>a(n+1);
  for(int i=0; i<n+1; i++){ 
    a[i]=i;
  }
  
  ll ans = 0;
  ll front =0; 
  ll back =0;
  
  for(int i=0; i<k-1; i++){
   front+=a[i];
   back+=a[n-i];
  }
  
  for(int i=k-1; i<n+1; i++){
    front +=a[i];
    back +=a[n-i];
    
    ans += back-front+1;
    ans%=1000000007;
    
  }
  
  cout << ans << endl;

}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (a != b && a != c) cout << a << endl;
  if (b != a && b != c) cout << b << endl;
  if (c != a && c != b) cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int M=2e6+5;
int n;
typedef pair<int,int> edge;
edge e[N*2];
int tot;

struct Tree{
	int hed[N],to[N],nxt[N],fa[N],cnt,root;
	int col[N];
	inline void adde(int u,int v){
		++cnt;to[cnt]=v,nxt[cnt]=hed[u];hed[u]=cnt;
	}
	inline void dfs(int x,int pre){
		col[x]=1;
		for(int i=hed[x];i;i=nxt[i]){
			int v=to[i];if(v==pre)continue;
			col[x]^=1;
			dfs(v,x);
		}
	}
	inline int dfs2(int x,int pre){
		int tmp=0;
		for(int i=hed[x];i;i=nxt[i]){
			int v=to[i];if(v==pre)continue;
			if(tmp)
				e[++tot]=edge(dfs2(v,x),tmp),tmp=0;
			else tmp=dfs2(v,x);
		}
		return tmp?tmp:x;
	}

}T1,T2;

namespace graph{
	int hed[N],to[M*2],nxt[M*2],cnt;
	int col[N];
	inline void adde(int u,int v){
		++cnt;to[cnt]=v,nxt[cnt]=hed[u];hed[u]=cnt;
	}
	inline void dfs(int x,int co){
		col[x]=co;
		for(int i=hed[x];i;i=nxt[i]){
			int v=to[i];
			if(col[v]==0)dfs(v,-co);
		}
	}
	inline void colo(){
		for(int i=1;i<=n;i++)if(T1.col[i]&&col[i]==0){
			dfs(i,1);
		}
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int f;scanf("%d",&f);
		if(f==-1)T1.root=i;
		else T1.adde(T1.fa[i]=f,i);
	}
	for(int i=1;i<=n;i++){
		int f;scanf("%d",&f);
		if(f==-1)T2.root=i;
		else T2.adde(T2.fa[i]=f,i);
	}
	T1.dfs(T1.root,0);T2.dfs(T2.root,0);
	T1.dfs2(T1.root,0);T2.dfs2(T2.root,0);
	for(int i=1;i<=n;i++) if(T1.col[i]!=T2.col[i]){
		puts("IMPOSSIBLE");
		return 0;
	}
	for(int i=1;i<=tot;i++){
		graph::adde(e[i].first,e[i].second);
		graph::adde(e[i].second,e[i].first);
	}
	graph::colo();
	puts("POSSIBLE");
	for(int i=1;i<=n;i++){
		printf("%d ",graph::col[i]);
	}
}

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

using namespace std;

typedef long long ll;

const int maxn = 200000 + 20;
const int inf = 1e18;

int ans[maxn];

int main()
{
    ll n;
    cin >> n;
    ll sum = 0;
    for(ll i=0;i<n;i++)
    {
        cin >> ans[i];
        sum += ans[i];
    }
    ll res = inf;
    ll t = 0;
    for(ll i=0;i<n;i++)
    {
        t += ans[i];
        sum -= ans[i];
        if(abs(sum - t) < res)
            res = abs(sum - t);
    }
    cout << res << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cctype>
#include <cstdio>
using namespace std;

int main () {
    string x;
    while (true) {
        cin >> x;
        if(x == "0") break;
        int sum = 0;
        for (int i = 0; i < x.length(); i++) {
            sum += x[i] - '0';
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3204
# -*- coding:utf-8 -*-

def check(x,i,y,j):
    flagx=True if (x+i>=0 and x+i<=9) else False
    flagy=True if (y+j>=0 and y+j<=9) else False

    return (flagx and flagy)

def main():
    LIST=[]
    for i in range(10):
        LIST.append([0,0,0,0,0,0,0,0,0,0])
        count=0
        M=0
    while True:
        try:
            x,y,size=map(int,input().split(","))
            if size==1:
                for i in range(-1,2):
                    for j in range(-1,2):
                        if check(x,i,y,j) and abs(i)+abs(j)<=1:
                            LIST[y+j][x+i]+=1

            elif size==2:
                for i in range(-1,2):
                    for j in range(-1,2):
                        if check(x,i,y,j) and abs(i)+abs(j)<=2:
                            LIST[y+j][x+i]+=1

            elif size==3:
                for i in range(-2,3):
                    for j in range(-2,3):
                        if check(x,i,y,j) and abs(i)+abs(j)<=2:
                            LIST[y+j][x+i]+=1
            
        except:
            break

    for item in LIST:
        tmp=max(x for x in item)
        M=max(tmp,M)

    for item in LIST:
        count+=item.count(0)

    print(count)
    print(M)
    
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 7764
#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n,x[N],y[N],ans=INT_MAX;
char d[N];

void case1()
{
	map <int,vector <int>> dn,lt;
	for(int i=0;i<n;i++)
		if(d[i]=='D') dn[x[i]+y[i]].push_back(x[i]);
	for(int i=0;i<n;i++)
		if(d[i]=='L') lt[x[i]+y[i]].push_back(x[i]);
	for(auto &p:lt) sort(p.second.begin(),p.second.end());

	for(auto p:dn)
	{
		if(lt.find(p.first)==lt.end()) continue;
		for(auto cx:p.second)
		{
			auto it=lower_bound(lt[p.first].begin(),lt[p.first].end(),cx);
			if(it!=lt[p.first].end()) ans=min(ans,10*(*it-cx));
		}
	}
}

void case2()
{
	map <int,vector <int>> dn,up;
	for(int i=0;i<n;i++)
		if(d[i]=='D') dn[x[i]].push_back(y[i]);
	for(int i=0;i<n;i++)
		if(d[i]=='U') up[x[i]].push_back(y[i]);
	for(auto &p:dn) sort(p.second.begin(),p.second.end());

	for(auto p:up)
	{
		if(dn.find(p.first)==dn.end()) continue;
		for(auto cx:p.second)
		{
			auto it=lower_bound(dn[p.first].begin(),dn[p.first].end(),cx);
			if(it!=dn[p.first].end()) ans=min(ans,5*(*it-cx));
		}
	}
}

void case3()
{
	map <int,vector <int>> rt,dn;
	for(int i=0;i<n;i++)
		if(d[i]=='R') rt[x[i]-y[i]].push_back(x[i]);
	for(int i=0;i<n;i++)
		if(d[i]=='D') dn[x[i]-y[i]].push_back(x[i]);
	for(auto &p:dn) sort(p.second.begin(),p.second.end());

	for(auto p:rt)
	{
		if(dn.find(p.first)==dn.end()) continue;
		for(auto cx:p.second)
		{
			auto it=lower_bound(dn[p.first].begin(),dn[p.first].end(),cx);
			if(it!=dn[p.first].end()) ans=min(ans,10*(*it-cx));
		}
	}
}

void case4()
{
	map <int,vector <int>> lt,rt;
	for(int i=0;i<n;i++)
		if(d[i]=='L') lt[y[i]].push_back(x[i]);
	for(int i=0;i<n;i++)
		if(d[i]=='R') rt[y[i]].push_back(x[i]);
	for(auto &p:lt) sort(p.second.begin(),p.second.end());

	for(auto p:rt)
	{
		if(lt.find(p.first)==lt.end()) continue;
		for(auto cx:p.second)
		{
			auto it=lower_bound(lt[p.first].begin(),lt[p.first].end(),cx);
			if(it!=lt[p.first].end()) ans=min(ans,5*(*it-cx));
		}
	}
}

void case5()
{
	map <int,vector <int>> rt,up;
	for(int i=0;i<n;i++)
		if(d[i]=='R') rt[x[i]+y[i]].push_back(x[i]);
	for(int i=0;i<n;i++)
		if(d[i]=='U') up[x[i]+y[i]].push_back(x[i]);
	for(auto &p:up) sort(p.second.begin(),p.second.end());

	for(auto p:rt)
	{
		if(up.find(p.first)==up.end()) continue;
		for(auto cx:p.second)
		{
			auto it=lower_bound(up[p.first].begin(),up[p.first].end(),cx);
			if(it!=up[p.first].end()) ans=min(ans,10*(*it-cx));
		}
	}
}

void case6()
{
	map <int,vector <int>> lt,up;
	for(int i=0;i<n;i++)
		if(d[i]=='L') lt[x[i]-y[i]].push_back(x[i]);
	for(int i=0;i<n;i++)
		if(d[i]=='U') up[x[i]-y[i]].push_back(x[i]);
	for(auto &p:lt) sort(p.second.begin(),p.second.end());

	for(auto p:up)
	{
		if(lt.find(p.first)==lt.end()) continue;
		for(auto cx:p.second)
		{
			auto it=lower_bound(lt[p.first].begin(),lt[p.first].end(),cx);
			if(it!=lt[p.first].end()) ans=min(ans,10*(*it-cx));
		}
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d%d %c",&x[i],&y[i],&d[i]);

	case1();
	case2();
	case3();
	case4();
	case5();
	case6();

	if(ans==INT_MAX) printf("SAFE");
	else printf("%d",ans);
}

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);

            Console.ReadKey();
         }
    }
}


Measured memory_bytes: 13140
#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 n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> ints(n);
	rep(i,n) ints[i] = s[i] - '0';
	
	
	// 累積和
	vector<vector<int>> sum(n,vector<int>(10));
	sum[0][ints[0]]++;
	rep(i,n-1){
      sum[i+1] = sum[i];
      sum[i+1][ints[i+1]] = sum[i][ints[i+1]] + 1;
	}
	
	
	// make first
	vector<int> first(10,n); // 一つもなければn
	rep(i,10){
		rep(j,n){
			if(ints[j] == i){
				first[i] = j;
				break;
			}
		}
	}
	
	// make last
	vector<int> last(10,-1); // 一つもなければ-1
	rep(i,10){
		rep(j,n){
			if(ints[n-1-j] == i){
				last[i] = n-1-j;
				break;
			}
		}
	}
	
	
	ll res = 0;
	rep(i,10){
      if(first[i] == n) continue;
		rep(j,10){
          if(last[j] == -1) continue;
			rep(mid,10){
				int left = first[i]+1;
				int right = last[j]-1;
              if(left == right && ints[left] == mid){
                res++;
               // cout << res << "-----" << i << mid << j << left << endl;
              }
			else if(left < right && sum[right][mid] - sum[left-1][mid] > 0){
                  res++;
                // cout << res << "---" << i << mid << j << endl;
                }
			}
		}
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A.at(i);//入力終了

  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(i)%2==1) count++;
  }
  
  if(count%2==1) cout << "NO" << endl;
  
  else cout << "YES" << endl;
}

Measured memory_bytes: 640
n = gets.to_s.to_i
s = gets.to_s.chomp

ans = 0
c = ('0'..'9')
c.each do |i|
  c.each do |j|
    c.each do |k|
      pos = s.index(i)
      pos ? (pos = s.index(j, pos+1)) : next
      pos ? (pos = s.index(k, pos+1)) : next
      ans += 1 if pos
    end
  end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int f;
int s;

queue<int> q;
int df[100010];
int ds[100010];
vector<vector<int>> edge(100010);

void dfs(){
    while(!q.empty()){
        int now=q.front();
        q.pop();
        for(auto x:edge[now]){
            if(df[x]==0){
                df[x]=df[now]+1;
                q.push(x);
            }
        }
    }
}
void dss(){
    while(!q.empty()){
        int now=q.front();
        q.pop();
        for(auto x:edge[now]){
            if(ds[x]==0){
                ds[x]=ds[now]+1;
                q.push(x);
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    f=0;
    s=0;
    rep(i,n-1){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        edge[x].pb(y);
        edge[y].pb(x);
    }
    fill(df,df+100010,0);
    fill(ds,ds+100010,0);
    q.push(0);
  	df[0]=1;
    dfs();
    q.push(n-1);
  	ds[n-1]=1;
    dss();
    int fen=0;
    rep(i,n){
        if(df[i]<=ds[i])fen++;
      	cerr << df[i] << ' ' << ds[i] << endl;
    }
    if(fen>=n/2+1)cout << "Fennec";
    else cout << "Snuke";


    
}

Measured memory_bytes: 6656
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join(chr(i+97) for i in ls)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=inf

n,m=LI()
s=input()
t=input()
import fractions
g=fractions.gcd(n,m)

a,b=n//g,m//g

if s[::a]==t[::b]:
    print(n*m//g)
else:
    print(-1)

Measured memory_bytes: 65260
#include <iostream>
#include <string>
#include <vector>

template<long long int MODVALUE>
class modllint{
  long long int val;
  void mod(){
    while( this->val < 0 ) this->val += MODVALUE;
    this->val %= MODVALUE;
  }
  void assign(long long int val){
    this->val = val;
    mod();
  }
public:
  modllint(): val(0){};
  modllint(long long int val){assign(val);};
  
  modllint operator+(modllint obj){
    return modllint<MODVALUE>(this->val + obj.val);
  }
  modllint operator+(long long int val){
    return modllint<MODVALUE>(this->val + val);
  }
  modllint& operator+=(const long long int val){
    this->assign(this->val + val);
    return *this;
  }
  
  modllint operator*(modllint obj){
    return modllint<MODVALUE>(this->val * obj.val);
  }
  modllint operator*(long long int val){
    return modllint<MODVALUE>(this->val * val);
  }
  modllint& operator*=(const long long int val){
    this->assign(this->val * val);
    return *this;
  }

  modllint& operator=(long long int intvalue){
    assign(intvalue);
    return *this;
  }
  friend std::ostream& operator<<(std::ostream& os, const modllint<MODVALUE>& val){
    os << val.val;
    return os;
  }
  friend std::istream& operator>>(std::istream& is, modllint<MODVALUE>& val){
    is >> val.val;
    return is;
  }
};

const int MOD = 1000000007;

int main(void){
  int n;
  std::string s;
  std::cin >> n >> s;

  std::vector<bool> v(2*n);
  for(int i=0; i<2*n; i++){
    v[i] = (s[i]=='B');
  }
  for(int i=0; i<2*n; i++){
    if(i%2 == 0) v[i] = !v[i];
  }

  modllint<MOD> result = 1;
  int l_count = 0;
  for(int i=0; i<2*n; i++){
    if(v[i]){ //R
      if(l_count == 0){
	std::cout << 0 << std::endl;
	return 0;
      }
      result *= l_count--;
    }else{
      l_count++;
    }
  }
  if(l_count != 0){
    std::cout << 0 << std::endl;
  }else{
    modllint<MOD> fac = 1;
    for(int i=1; i<=n; i++){
      fac *= i;
    }
    std::cout << (result * fac) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 640
/*
g£_CNXg
*/
#include<iostream>
#include<queue>
#include<map>
#define INF 10000000
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> p;
typedef pair<int,p> P;
//P(cost,p(node,ticket))
struct edge{
	int cost,to;
};
int nticket,nnode,nedge,start,goal,d[11][101];
vector<edge> v[101];
void dijkstra(){
	int nowticket,nowplace,nowsum;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,p(start,nticket)));
	while(!que.empty()){
		P now=que.top();
		que.pop();
		
		nowsum=now.first;
		nowplace=now.second.first;
		nowticket=now.second.second;
		
		if(d[nowticket][nowplace]<nowsum)
			continue;
		rep(i,(int)v[nowplace].size()){
			edge e=v[nowplace][i];
			if(nowticket>0){
				if(d[nowticket-1][e.to]>e.cost/2+nowsum){
				d[nowticket-1][e.to]=e.cost/2+nowsum;
				que.push(P(d[nowticket-1][e.to],p(e.to,nowticket-1)));
				}
			}
			if(d[nowticket][e.to]>e.cost+nowsum){
				d[nowticket][e.to]=e.cost+nowsum;
				que.push(P(d[nowticket][e.to],p(e.to,nowticket)));
			}
		}
	}
}
void input(){
	int a,b,f;
	rep(i,nedge){
			cin>>a>>b>>f;
			a--;b--;
			edge c;
			c.cost=f;
			c.to=b;v[a].push_back(c);
			c.to=a;v[b].push_back(c);
		}
}
void init(){
	rep(i,nticket+1)
		rep(j,nnode){
			if(j==start)
			d[i][j]=0;
			else
			d[i][j]=INF;
	}
}
int main(){
	//d[ticket][node]=Å­ïp
	while(cin>>nticket>>nnode>>nedge>>start>>goal,nticket||nnode||nedge||start||goal){
		start--;goal--;
		//ticket:`Pbg
		//nnode:nodeÌ
		//nedge:edgeÌ
		//start¨goal
		input();
		init();
		dijkstra();
		int ans=INF;
		for(int i=0;i<nticket+1;i++)
		ans=min(d[i][goal],ans);
		cout<<ans<<endl;
		for(int i=0;i<nnode;i++)
		v[i].clear();
	}
	return 0;
}

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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> h(n);
    for(auto &i: h) {
        std::cin >> i;
    }
    std::vector<int> c(n, 0);
    c[0] = 0;
    c[1] = std::abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        c[i] = std::min(c[i - 1] + std::abs(h[i] - h[i - 1]), c[i - 2] + std::abs(h[i] - h[i - 2]));
    }
    std::cout << c[n - 1];
    return 0;
}

Measured memory_bytes: 1024
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize
    };

    if a >= b + 1 {
        println!("{}", a * 2 - 1);
    } else if b >= a + 1 {
        println!("{}", b * 2 - 1);
    } else {
        println!("{}", a + b);
    }
}


Measured memory_bytes: 2132