akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[82][82];
bool ans[82][82][25700];
int main() {
	ll h,w;
	cin>>h>>w;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>ch[i][j];
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			ll x;
			cin>>x;
			ch[i][j]=abs(ch[i][j]-x);
	//		cout <<ch[i][j];
		}
		//cout <<endl;
	}
	ans[0][0][12800+ch[0][0]]=ans[0][0][12800-ch[0][0]]=true;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			for(ll k=0;k<25700;k++){
				if(i!=0){
					if(ans[i-1][j][k]){
						ans[i][j][k+ch[i][j]]=ans[i][j][k-ch[i][j]]=true;
					}
				}
				if(j!=0){
					if(ans[i][j-1][k]){
						ans[i][j][k+ch[i][j]]=ans[i][j][k-ch[i][j]]=true;
					}
				}				
			}
		}
	}
	ll ANS=inf;
	for(ll k=0;k<25700;k++){
		if(ans[h-1][w-1][k]){
			ANS=min(ANS,abs(12800-k));
		}
	}
	cout <<ANS;
	// your code goes here
	return 0;
}

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

namespace procon
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int result = 0;

            for(int i = 0; i <= n;i++)
            {
                result += i;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner

object Main {
    case class pseudoMap(key:Int , count:Int)
    implicit def tupleToName(tup: (Int, Int)): pseudoMap = tup match {
        case (key, count) => pseudoMap(key, count)
    }

    def main(args: Array[String]): Unit = {
        val scanner = new Scanner(System.in)
        val n: Int = scanner.nextInt
        val vs: List[Int] = List.fill(n)(scanner.nextInt)
        println(calc(vs))
    }

    def calc(nums: List[Int] ): Int ={
        val (evens, odds) = nums.zipWithIndex.partition(_._2 % 2 == 0)
        val (evensFirst, evensSecond) = take2(evens)
        val (oddsFirst, oddsSecond) = take2(odds)

        if (evensSecond.key == -1 && oddsSecond.key == -1){
          if (evensFirst.key != oddsFirst.key)
              0
          else
              nums.length / 2
        }
        else {
          if (evensFirst.key != oddsFirst.key)
              nums.length - evensFirst.count - oddsFirst.count
          else
            countMinNumberOfRewrite(nums.length, evensFirst.count, evensSecond.count, oddsFirst.count, oddsSecond.count)
        }
    }

    def take2(nums: List[(Int, Int)]): ((Int,Int),(Int,Int)) = {
      val sortedNums: Seq[(Int, Int)] = nums.map(_._1).groupBy(n => n).mapValues(_.length).toSeq.sortBy(_.count).reverse
      (sortedNums(0), try{sortedNums(1)}catch{case e :Exception => (-1, Int.MinValue)})
    }

    def countMinNumberOfRewrite(allNums: Int ,e1stCnt: Int, e2ndCnt: Int, o1stCnt: Int, o2ndCnt: Int): Int={
      val count1 = allNums - e1stCnt - o2ndCnt
      val count2 = allNums - e2ndCnt - o1stCnt
      count1.min(count2)
    }
}


Measured memory_bytes: 116936
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+7;
int main(){
 	int n,k;
  	scanf("%d%d",&n,&k);
  	vector<int> h(n);
  	for(int &i:h){
     	scanf("%d",&i); 
    }
  	vector<int> dp(n,INF);
  	dp[0]=0;
  	dp[1]=abs(h[0]-h[1]);
  	for(int i=2;i<n;i++){
  	    for(int j=min(i,k);j>-1;j--)
     	dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j])); 
    }
  printf("%d",dp[n-1]);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  ll x, a, b;
  cin >> x >> a >> b;
  string ans = "dangerous";
  if(a-b >= 0) ans = "delicious";
  else if(b-a <= x) ans = "safe";
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>
#include <set>
#include <list> //list<???> a; a.push_back ,insert(追加したい要素),a.sort(),参照できない
#include <vector> //vector<???> a; a.push_back,sort(a.begin(),a.end());a[i]
//配列 int a[N];a[i]=追加したい要素;sort(a,a+N);a[i]
const int MOD = 1e9+7;
using namespace std;
typedef long  ll;
#define rep(i,n) for(int i=0;i<(n);i++)


//using namespace std;
//


int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(c*d<=a*b){
    cout<<a*b<<endl;
  }else{
    cout<<c*d<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

lli d;
lli c[26];
lli s[370][26];
lli t[370];
lli lastDay[26];


lli score(){

	lli ans = 0;
	REP(i,0,26)lastDay[i]=0;

	REP(i,1,d+1){
		ans += s[i-1][t[i-1]];

		lastDay[t[i-1]] = i;
		REP(j,0,26){
			ans -= c[j]*(i-lastDay[j]);
			LOG2(ans,c[j]*(i-lastDay[j]))
		}
	}
	return ans;
}

void dummyDayInput(){

	REP(i,0,d){
		cin>>t[i];
		//t[i]=1;
		t[i]--;
	}

}

void input(){
	cin>>d;
	REP(i,0,26)cin>>c[i];
	REP(i,0,d){
		REP(j,0,26){
			cin>>s[i][j];
		}
	}
}

void dummyDayChangeInput(){
	lli m;
	cin>>m;

	REP(i,0,m){
		lli d,q;
		cin>>d>>q;
		d--,q--;
		t[d] = q;
		cout<<score()<<endl;
	}
}

int main(){

	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	input();

	dummyDayInput();
	dummyDayChangeInput();
 
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll from;
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll h ,w, k;
vector<vector<string>> c;
/******* define variable end *******/
int solve() {
	cin >> h >> w >> k;
	c.resize(h, vector<string>(w));
	REP(i, h){
		string tmp;
		cin >> tmp;
		REP(j, w){
			c[i][j] = tmp.substr(j, 1);
		}
	}
	ll ans = 0;
	REP(i, 1 << h){
		REP(j, 1 << w){
			vl sh(h);
			ll tmph = i;
			vl sw(w);
			ll tmpw = j;
			ll count = 0;
			while(count < h){
				sh[count] = tmph % 2;
				tmph /= 2;
				count++;
			}
			count = 0;
			while(count < w){
				sw[count] = tmpw % 2;
				tmpw /= 2;
				count++;
			}
			ll anstmp = 0;
			REP(k, h){
				REP(l, w){
					if(sh[k] != 1 && sw[l] != 1 && c[k][l] == "#"){
						anstmp++;
					}
				}
			}
			if(anstmp == k){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3616
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;
    cin >> s >> t;
    int ss=s.size(),ts=t.size();
    ll dp[ss+1][ts+1];
    rep(i,ss+1){
        rep(j,ts+1){
            dp[i][j]=0;
        }
    }
    rep(i,ss){
        rep(j,ts){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }
            else{
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
            }
            //cout << dp[i+1][j+1] << ( j==ts-1 ? '\n' : ' ' );
        }
    }
    string st="";
    int MX=dp[ss][ts];
    int nowi=ss+1,nowj=ts+1;
    per(i,ss-1){
        per(j,ts-1){
            if(nowi>=i&&nowj>=j&&dp[i+1][j+1]==MX&&dp[i+1][j+1]==dp[i][j+1]+1&&dp[i+1][j+1]==dp[i+1][j]+1){
                st+=s[i];
                MX--;
                nowi=i-1;nowj=j-1;
                break;
            }
        }
    }
    reverse(st.begin(),st.end());
    cout << st << endl;
}

Measured memory_bytes: 73928
#include <stdio.h>
#include <string.h>

int main()
{
	int A, B;
	char S[11];
	char T[11];
	char U[11];
	
	scanf("%s %s", &S, &T);
	scanf("%d %d", &A, &B);
	scanf("%s", &U);
	
	if (strcmp(S,U) == 0){
		A--;
		printf("%d %d", A,B);
	} else if (strcmp(T,U) == 0){
		B--;
		printf("%d %d", A,B);
	}
		
	return 0;
}


Measured memory_bytes: 1732
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 2005
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, k, ans;
int f = 1;
string s;
deque<char> q;
int main() {
	io(); cin >> s;
	rep(i, 0, (s.length() - 1)) q.push_back(s[i]);
	cin >> k;
	rep(i, 1, k) {
		int op; cin >> op;
		if (op == 1) f ^= 1;
		else {
			int x; char ch;
			cin >> x >> ch;
			if (x == 1) {
				if (f) q.push_front(ch);
				else q.push_back(ch);
			}
			else {
				if (f) q.push_back(ch);
				else q.push_front(ch);
			}
		}
	}
	string ans;
	while (!q.empty()) {
		ans += q.front();
		q.pop_front();
	}
	if (!f) reverse(ans.begin(), ans.end());
	cout << ans;
}


Measured memory_bytes: 1368
#include <iostream>
using namespace std;
int main() {
  int N, M; cin >> N >> M;
  int a[M], b[M];
//  int m[N][N];
  int c[N];
  for(int i = 0; i < N; i++)
    c[i] = 0;
//  for(int i = 0; i < N; i++)
//    for(int j = 0; j < N; j++)
//      m[i][j] = 0;
  for(int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    ++(c[a[i] - 1]);
    ++(c[b[i] - 1]);
  }
//  for(int i = 1; i <= N; i++)
//    for(int j = 1; j <= N; j++) {
//      c[i] += m[i][j];
//      c[j] += m[i][j];
//    }
  for(int i = 0; i < N; i++)
    cout << c[i] << endl;
}

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

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    if((r * 100 + g * 10 + b ) % 4 == 0){
        cout << "YES" << endl;
    }
    else{ 
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int N; cin>>N;
  vector<int>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  //compute
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int sum=0;  
  for(int i=1;i<N;i++){
    sum+=vec[i];
  }
  
  
  //output
  if(vec[0]<sum){
  	cout<<"Yes"<<endl;  
  }
  else{
    cout<<"No"<<endl;
  }
}
  


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int SIZE = 1000000 + 5;
int min_factor[SIZE];
int count_p[SIZE];

ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main2() {
  int N = nextLong();
  vector<ll> A(N);
  REP(i, N) A[i] = nextLong();


  bool setwise_coprime = false;
  {
    ll g = A[0];
    for (int i = 1; i < N; i++) g = gcd(g, A[i]);
    setwise_coprime = g == 1;
  }

  bool pairwise_coprime = true;
  {
    CLR(count_p, 0);
    for (ll x : A) {
      while (x > 1) {
        ll p =  min_factor[x];
        count_p[p]++;
        while (x % p == 0) {
          x /= p;
        }
      }
    }

    // REP(i, 100) {
      // cout  << i << "  " << count_p[i] << endl;
    // }
    REP(i, SIZE) if (count_p[i] >= 2) pairwise_coprime = false;
  }


  if (pairwise_coprime) {
    cout << "pairwise coprime" << endl;
  } else if (setwise_coprime) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}

int main() {

  REP(i, SIZE) min_factor[i] = i;
  for (int d = 2; d < SIZE; d++) {
    for (int i = d; i < SIZE; i += d) {
      chmin(min_factor[i], d);
    }
  }


#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 18840
#include <stdio.h>

int main(void)
{
 int S,h,m,s;

 scanf("%d", &S) ;

 h = S / 3600 ;
 m = (S%3600) / 60 ;
 s = S%60 ;

 printf("%d:%d:%d\n", h, m, s);

 return 0;
}

Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    
    int sum = 0;
    for (int i = 0;i<N;i++) {
        int l,r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
    

}

Measured memory_bytes: 3564
if __name__ == '__main__':
    N = input()


    m = [[0] * (N+1) for i in range(N+1)]

    p = [0] * N

    for i in range (N):
        p[i],dummy  = map(int, raw_input().split())
        
    p.append(dummy)

    for l in range (2, N+1):
        for i in range(1, N - l + 2):
            j = i + l - 1
            m[i][j] = float("inf")
            for k in range(i, j):
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j])

print  m[1][N]

Measured memory_bytes: 6496
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
string a;
ll b;
ll count=0;
cin >> a;
b=a.size();
for(ll i=0 ; i<b/2 ; i++){
  if((a.at(i)==a.at(b-i-1)) && (a.at(i)==a.at(b/2-i-1)) ){
    count+=0;
  }else{
    count+=1;
  }
}
if(count==0){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
}
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val answer = (105..n).count { pred(it) }
    println(answer)
}

fun divisors(n: Int) =
        (1..n).toList().filter { n % it == 0 }

fun pred(n: Int) =
        n % 2 == 1 && divisors(n).size == 8

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

struct A {
    bool operator<(const A& a) const {
        return x > a.x;
    }
    int w, b;
    int64_t x;
};

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

    int n;
    cin >> n;

    int64_t p;
    cin >> p;

    vector<A> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].w >> a[i].b;
        a[i].x = a[i].w * (100 - p) + a[i].b * p;
    }

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

    int64_t w = 0, b = 0;
    for (int i = 0; i < n; i++) {
        b += a[i].b;
    }
    for (int i = 0; i < n; i++) {
        w += a[i].w;
        b -= a[i].b;
        if (w * 100 >= p * (w + b)) {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1920
# B
def getInt(): return int(input())
s = getInt()
def f(n):
    if  n%2==0: return n//2
    else: return 3*n+1
def a(n):
    if n==1: return s
    else: return f(a(n-1))
ls = []
i = 1
while True:
    e = a(i)
    if e in ls: break
    ls.append(e) 
    i += 1
print(i)


Measured memory_bytes: 3060
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
edges = [(0,0) for _ in range(M)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    edges[i] = (a-1,b-1)

import sys
sys.setrecursionlimit(10**8)

def dfs(v, es):
    #print(h,w)
    if len(es[v])==0:
        return 0
    for u in es[v]:
        if visited[u]==False:
            visited[u]=True
            dfs(u,es)
    return 0

import copy
ans = 0
for i in range(M):
    visited = [False]*N
    a,b = edges[i]
    es = copy.deepcopy(edge)
    # print(edge,a,b)
    es[a].remove(b)
    es[b].remove(a)
    for v in range(N):
        if visited[v]==False:
            visited[v]=True
            dfs(v,es)
            if False in visited:
                # print(a,b)
                break
    else:
        continue
    ans += 1
print(ans)

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc+1)%2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (c[1 - i][0]==0&&c[1-i][1]==0) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}

Measured memory_bytes: 11632
X,K,D = map(int, input().split())

x = abs(X)

ans = 0
if x >= K*D:
  ans = x - K*D
else:
  k = K - x//D
  if k%2==0:
    ans = x % D
  else:
    ans = D - (x % D)
print(ans)  



Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

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

    int n,sum=0,now=0; cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i]; sum+=a[i]; if(i>0 and i%2==1)now+=a[i];
    }

    rep(i,n){
        cout<<sum-now*2<<endl;
        now=sum-now-a[i];
    }

}

Measured memory_bytes: 2176
fun main(args: Array<String>) {
    val (sankaCount, hyojiRating) = readLine()!!.trim().split(' ').map {it.toInt()}

    val naibuRating = if (sankaCount >= 10) {
        hyojiRating
    } else {
        hyojiRating + 100 * (10 - sankaCount)
    }

    println(naibuRating)
}

Measured memory_bytes: 36440
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

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

# 最小値が返ってくるので-1倍する
A = [-i for i in map(int,input().split())]
heapify(A)

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print(-sum(A))

Measured memory_bytes: 20476
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i=1;i<=n;i++)
{
    if(i%3==0 || String.valueOf(i).indexOf('3')>=0)
        System.out.print(" " + i);
}
System.out.println();
}
}

Measured memory_bytes: 23720
N, M = map(int, input().split())

if N >= 3 and M >= 3:
    ans = (N - 2) * (M - 2)
elif N == 2:
    ans = 0
elif M == 2:
    ans = 0
elif N == 1 and M == 1:
    ans = 1
else:
    ans = max(N, M) - 2

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;


int N, M, Q;
vector<int>a, b, c, d;
vector<int> buf;
int sum;

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

	if (S == "ABC") {


		cout << "ARC";
	}
	else {
		cout << "ABC";
	}

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 4
#define MAXH 4
#define MAXM 4
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	ll x,y;
	cin >> x >> y;
	cout << (abs(y-x) <= 1?"Brown":"Alice") << '\n';
}


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

int main() {
  ll r, g, b, n, ans = 0;
  cin >> r >> g >> b >> n;

  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; i * r + j * g <= n; j++) {
      if ((n - i * r - j * g) % b == 0) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
H = list(map(int,input().split()))
inf = float('INF')
dp = [inf]*n
dp[0] = 0
for i in range(0,n-1):
    for j in range(1,min(n-i-1,k)+1):
        # print(j)
        dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))
    # print(dp)

    # dp[i]=min(dp[i],dp[i-1]+abs(H[i]-H[i-1]))
# print(dp)
print(dp[-1])

Measured memory_bytes: 55008
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<int> gr[100100];
int pa[100100];
int n,de,ng,num=0;
bool dfs(int d,int v,int u){
	pa[d]=v;
	if(v==n){
		de=d;return true;
	}
	rep(i,gr[v].size()){
		int w=gr[v][i];
		if(w==u) continue;
		if(dfs(d+1,w,v)) return true;
	}
	return false;
}
void dfs2(int v,int u){
	if(v==ng) return;num++;
	rep(i,gr[v].size()){
		int w=gr[v][i];
		if(w==u) continue;
		dfs2(w,v);
	}
}
int main()
{
	cin>>n;
	int a,b;
	rep(i,n-1){
		cin>>a>>b;gr[a].pb(b);gr[b].pb(a);
	}
	dfs(0,1,0);
	ng=pa[de/2+1];
	dfs2(1,0);
	if(num>n-num) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	string s;
	LL k;
	cin>>s>>k;
	reverse(s.begin(),s.end());
	while(!s.empty() && s.back()=='1' && --k)s.pop_back();
	putchar(s.back());
	return 0;
}



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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\


int main()
{
    IOS;
    //fileRead
    int tc = 1;
    //cin>>tc;
    while(tc--)
    {
        string s; cin>>s;
        int ans=0;
        for0(i,3) if(s[i]=='R') ans=1;
        for0(i,3-1){
            if(s[i]=='R' and s[i+1]=='R') ans++;
        }
        
        cout<<ans;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,y;
    cin>>n>>y;
    rep(i,n+1)rep(j,n+1){
        if(i+j>n)continue;
        if(i*10000 + j*5000 + (n-i-j)*1000 == y){
            puta(i, j, n-i-j);
            return 0;
        }
    }
    puta(-1, -1, -1);
    return 0;
}

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

long long N;

int main(){
	cin>>N;
	string s="";
	while(N>0){
		long long plus=97;
		long long tmp=(N-1)%26;
		char temp=plus+tmp;
		s=temp+s;
		N=(N-1)/26;
	}
	cout<<s<<'\n';
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  ll n,sum=0,ans=0,sumx=0;cin>>n;
  vi v(n);
  vector<bool>used(n,true);
  rep(i,n)cin>>v[i];
  ll j=0;
  rep(i,n){
    bool b=false;
    while(j<n){
      if(used[j]){
        sum+=v[j];
        sumx^=v[j];
        used[j]=false;
      }
      if(sum!=sumx){
        b=true;
        break;
      }
      j++;
    }
    if(b)ans+=j-i;
    else ans+=n-i;
    sum-=v[i];
    sumx^=v[i];
  }
  cout<<ans<<endl;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N, K;
    string s;
    cin >> N >> K;
    cin >> s;
    vector<int> d(1, 1);
    FOR(i, 1, N) {
        if(s[i - 1] == s[i]) {
            auto itr = d.end();
            itr--;
            (*itr)++;
        }else{
            d.push_back(1);
        }
    }
    int sum = N - d.size();
    int res = sum + 2*min<int>(K, d.size()/2);
    if(d.size()%2 == 0 && d.size() <= 2*K) {
        res--;
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> H(30);
  for(int i=0;i<N;i++)cin >> H[i];
  int cnt=1; int M=H[0];
  for(int i=1;i<N;i++){
    if(H[i]>=M){cnt++; M=H[i];}
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x; cin >> x;
    if(x<1200) cout << "ABC";
    else cout << "ARC";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
M = 2019

S = list(input())
s_size = len(S)

S.reverse()
x = 1
tot = 0
ans = 0

cnt_list = [0 for i in range(M)]

for i in range(s_size):
	cnt_list[tot] += 1
	tot += (ord(S[i])-ord('0'))*x
	tot %= M
	ans += cnt_list[tot]
	x = x*10%M

print(ans)


Measured memory_bytes: 10384
#include <bits/stdc++.h>
using namespace std;
#define sz(v)   ((int)((v).size()))
#define all(v)  ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
long long sum(long long n) {
	return (n * (n + 1)) / 2;
}
long long n, m, f, b, ans, x;
int main() {
	cin >> n;
	n *= 2;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n);

	for (int i = n - 1; i >= 0; i -= 2) {
		ans += min(a[i], a[i - 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include"iostream"
using namespace std;
void countingsort(int a[],int b[],int k,int n)
{
	int i,j;
	int*c=new int[k + 1];
	for (i = 0; i <= k; ++i)
		c[i] = 0;
	for (j = 1; j <= n; ++j)
		++c[a[j]];
	for (i = 1; i <= k; ++i)
		c[i] = c[i] + c[i - 1];
	for(j=n;j>=1;--j)
	{
		b[c[a[j]]] = a[j];
		--c[a[j]];
	}
	cout << b[1];
	for (i = 2; i <= n; ++i)
		cout << ' ' << b[i];
	cout << endl;
}
int main()
{
	int n;
	cin >> n;
	int* a = new int[n + 1];
	int* b = new int[n + 1];
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	int max = a[1];
	for (int i = 1; i <= n; ++i)
		if (a[i] > max)max = a[i];
	countingsort(a, b,max,n );
	return 0;
}


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

int bubbleSort(int A[], int N){
	int sw = 0;
	bool flag = 1;
	for(int i = 0; flag; i++){
		flag = 0;
		for(int j = N-1; j >= i + 1; j--){
			if( A[j] < A[j-1] ){
				swap(A[j], A[j-1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(){
	int A[100], N, sw;
	cin >> N;
	for( int i = 0; i < N; i++) cin >> A[i];

	sw = bubbleSort(A, N);

	for( int i = 0; i < N; i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	
	return 0;
}

Measured memory_bytes: 1160
//
// Created on 2018-12-08.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<(n);++i)
#define RFOR(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define PB push_back
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vs> vvs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int D;
    cin >> D;

    if (D == 25) cout << "Christmas" << endl;
    if (D == 24) cout << "Christmas Eve" << endl;
    if (D == 23) cout << "Christmas Eve Eve" << endl;
    if (D == 22) cout << "Christmas Eve Eve Eve" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n;
    cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;++i){
      cin >> a[i];
    }
	vector<long long> s(n+1);
	s[0]=0;
	for(int i=0;i<n;++i){
		s[i+1]=s[i]+a[i];
	}
	sort(s.begin(),s.end());
	long long ans=0,sum=1,b=s[0];
	for(int i=1;i<=n;++i){
		if(s[i]==b) sum++;
		else{
			ans+=sum*(sum-1)/2;
			b=s[i];
			sum=1;
		}
	}
	ans+=sum*(sum-1)/2;
  
	cout << ans << endl;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;

  string s; cin >> s;

  for(char c : s){
    if(c=='7'){
      cout << "Yes\n";
      return 0;
    }
  }


  cout << "No\n";
  

  return 0;
}

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

int main() {
	int N;
	cin >> N;
	ull x, A1, A2;
	cin >> A1;
	cin >> A2;
	x = 0;
	for (int i = 3; i <= N; i++) {
		ull a;
		cin >> a;
		x ^= a;
	}
	set<pair<ull, ull> > S; // (z+b,b)
	S.insert(pair<ull, ull>(1, 1));
	while (S.size() > 0) {
		pair<ull, ull> p = *S.begin();
		S.erase(S.begin());
		ull z = p.first - p.second;
		ull b = p.second;
//		cout << "check (" << z << "," << b << ")" << endl;
		if (((A1 - z) ^ (A2 + z)) == x) {
			cout << z << endl;
			return(0);
		}
		if ((((A1 - z) & (b * 2 - 1)) ^ ((A2 + z) & (b * 2 - 1))) == (x & (b * 2 - 1))) {
			if (p.first + p.second < A1) {
				S.insert(pair<ull, ull>(z + b * 2, b * 2));
//				cout << "insert (" << z + b * 2 << "," << b * 2 << ")" << endl;
				if (((A1 - z) & b) == 0 || ((A2 + z) & b) == b) {
					S.insert(pair<ull, ull>(z + b + b * 2, b * 2));
					//				cout << "insert (" << z + b + b * 2 << "," << b * 2 << ")" << endl;

				}
			}
		}
	}
	cout << -1 << endl;
	return(0);
}


Measured memory_bytes: 4356
#include <iostream>
#include <vector>

using namespace std;

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

  long long a[1009][3];
  for (long long i = 1; i <= N; ++i) { // i番目のケーキ
    for (int j = 0; j < 3; ++j) { // j=0 は x, j=1 は y, j=2 は z
      cin >> a[i][j];
    }
  }

  long long maxn = -1;

  // x, y, z それぞれについて、正の方向に最大化するか、負の方向に最大化するかの場合分け
  // i = 0 なら ビット表現は 000 zは負, yは負, xは負
  // i = 1 なら ビット表現は 001 zは負, yは負, xは正
  for (int i = 0; i < 8; ++i) {
    // iの場合での、全てのケーキの x, y, z の合計
    vector<long long> vec;

    // 全てのケーキについて
    for (int j = 1; j <= N; ++j) {
      // S は iの場合で, j番目のケーキの x, y, z の合計
      long long S = 0;
      for (int k = 0; k < 3; k++) {
        if (i & (1<<k)) {    // i の k ビット目が 1 なら true, 0 なら false
          S += a[j][k];
        } else {
          S -= a[j][k];
        }
      }

      // S を vec に追加
      vec.push_back(S);
    }

    // vec を昇順でソート
    sort(vec.begin(), vec.end());
    // 大きい値が先にくるように vec を反転
    reverse(vec.begin(), vec.end());

    // ans に vec の値が大きい方から M 個足し合わせる
    long long ans = 0;
    for (int j = 0; j < M; ++j) {
      ans += vec[j];
    }

    // もし ans が maxn より大きければ maxn に ans を代入
    maxn = max(maxn, ans);
  }

  cout << maxn << endl;
  return 0;
}


Measured memory_bytes: 888
S = input()

import itertools
gr = itertools.groupby(S)

R, L = [], []
for k, g in gr:
    if k == 'R':
        R.append(len(list(g)))
    else:
        L.append(len(list(g)))

ans = []
for r, l in zip(R, L):
    ans += [0]*(r-1)
    ans.append(r//2+l//2+r%2)
    ans.append(l//2+r//2+l%2)
    ans += [0]*(l-1)
print(*ans)

Measured memory_bytes: 7208
#include <iostream>
#include <vector>

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> cache(n+1);
    cache[0]=0;
    for(int i=1; i<=n; ++i){
        int min_n=i;
        for(int j=1; j<=i; j*=6){
            min_n=min(min_n, cache[i-j]+1);
        }
        for(int j=1; j<=i; j*=9){
            min_n=min(min_n, cache[i-j]+1);
        }
        cache[i]=min_n;
    }
    cout << cache[n] << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
long long a[100010];
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%lld",&a[i]);
int zero=0;
for(int i=0;i<n;i++)if(a[i]==0)zero++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod=1;
for(int i=0;i<n;i++){
if(a[i] <=1000000000000000000/prod){
// This condition is equivalent to prod*a[i]<=10ˆ18
prod*=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N+1);
  for(int i=1;i<N+1;i++){
    cin >> a[i];
  } 
  int b=1;
  
  for(int i=1;i<N+1;i++){
    b=a[b];
   
    if(b==2){
      cout << i << endl;
    
      return 0;
      break;
      
    }  
  }
  cout << -1 << endl;
}  
 


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 1e5+5;



int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	vector<vector<int>> g(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			g[i][j] = s[i][j] - '0';
		}
	}

	/*
	for (int i = 0; i < n; i++) {
		vector<int> v;
		for (int j = 0; j < n; j++) {
			if (g[i][j] != 1) {
				continue;
			}

			v.emplace_back(j);
		}

		for (int vi1 : v) {
			for (int vi2 : v) {
				if (g[vi1][vi2] == 1) {
					cout << -1 << endl;
					return 0;
				}
			}
		}


	}
	
	*/
	vector<vector<int>>d(n, vector<int>(n, BIG_NUM));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (g[i][j] == 1) {
				d[i][j] = 1;
			}
			
		}
		
		d[i][i] = 0;
		
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	int m = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			m = max(m, d[i][j]);
			//cout << d[i][j] << " ";
		}

		//cout << endl;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (d[i][j] % 2 != (d[i][k] + d[k][j]) % 2) {
					cout << -1 << endl;
					return 0;
				}
			}
		}

		//cout << endl;
	}

	cout << m + 1 << endl;
}

Measured memory_bytes: 3976
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const int mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y;
  cin >>n>>x>>y;
  vector<int> ans(n+3,0);
  for(int i=1;i<n;i++){
    for(int j=i+1;j<=n;j++){
      int tmp=min(abs(i-x)+abs(y-j),abs(i-y)+abs(x-j));
      ans[min(j-i,tmp+1)]++;
    }
  }
  for(int i=1;i<n;i++) cout <<ans[i]<<'\n';
  return (0);
}

Measured memory_bytes: 3656
import sys

N = int(input())
p = list(map(int, input().split()))


for i in range(N):
    if p[i] == 0:
        print(0)
        sys.exit()

product = 1
for i in range(N):
    product = product * p[i]
    if product > 10 ** 18:
        print(-1)
        sys.exit()
        break

print(product)

Measured memory_bytes: 21600
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
using namespace std;


int main(void) {
	
	int a, b;
	cin >> a >> b;

	int res = a * b % 2;

	string ans = "Odd";
	if (res == 0)
	{
		ans = "Even";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256