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

#define S size()
#define E end()
#define B begin()
#define L length()
 
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define fl float
#define ld long double
#define ll long long

#define gcd __gcd
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define all(v) v.B,v.E
#define acc(v) accumulate(all(v), 0)
#define psum partial_sum
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation
#define maxe *max_element
#define mine *min_element
 
#define forl(i,n) for(ll i = 0; i < n; i++)
#define fore(i,m,n) for (ll i = m; i <= n; i++)
#define rforl(i,n) for (ll i = n - 1; i >= 0; i--)
#define rfore(i,m,n) for (ll i = m; i >=n; i--)    
#define iter(s) for(auto it:s)
 

#define prec(n) fixed<<setprecision(n)
#define popcnt(n) __builtin_popcountll(n)
#define parity(n) __builtin_parityll(n)
#define clz(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctzll(n)

#define sll set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vll vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define msll multiset<ll>
#define msc multiset<char>
#define vvll vector<vector<ll>>
#define rev reverse

#define tc ll q;cin>>q;while(q--)
#define pat ll n;cin>>n;
#define pat1 vll a(n);forl(i,n)cin>>a[i];
#define pat2 ll n,k;cin>>n>>k;vll a;forl(i,n) cin>>a[i];
#define pats string s;cin>>s;
#define yesno if(flag)cout<<"YES\n";else cout<<"NO\n";
#define loop forl(i,n)

#define p0(a) cout << a << " ";
#define p1(a) cout << a << endl;
#define p2(a,b) cout << a << " " << b << endl;
#define p3(a,b,c) cout << a << " " << b << " " << c << endl;
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
 
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832

//**********************************
 
int main(){
    pat pat1
    ll p=1;
    bool flag=true;
    sort(all(a));
    loop{
        if(p!=0 && 1000000000000000000/p>=a[i]){
        p*=a[i];
        }else if(p!=0 && 1000000000000000000/p<a[i]){
            flag=false;
            break;
        }else if(a[i]==0){
            p=0;
        }
    }
    if(flag){
        p1(p)
    }else{
        p1(-1)
    }
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int main()
{
    char s[N];
    scanf("%s",s);
    int len=strlen(s);
    int cnt0=0,cnt1=0;
    for(int i=0;i<=len;i++){
        if(s[i]=='0'){
            cnt0++;
        }
        else if(s[i]=='1'){
            cnt1++;
        }
    }
    int ans=2*min(cnt0,cnt1);
    printf("%d\n",ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;

    if (n % 10 == 7 || (n / 10) % 10 == 7 || (n / 100) == 7)
        cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
vector<int>v[20];
vector<int>c;
int ans[20];
int main()
{
    int n,m,x,temp;
    cin>>n>>m>>x;
    For(i,0,n-1)
    {
        cin>>temp;
        c.push_back(temp);
        For(j,0,m-1)
        {
            cin>>temp;
            v[i].push_back(temp);
        }
    }
    int tot=1<<n;
    int flag=1;
    int minx=1e9;
    For(i,0,tot-1)
    {
        flag=1;
        For(j,0,m-1)ans[j]=0;
        temp=0;
        For(j,0,n-1)
        {
            if(i>>j&1)
            {
                temp+=c[j];
                For(k,0,m-1)ans[k]+=v[j][k];
            }
        }
        For(j,0,m-1)if(ans[j]<x)flag=0;
        if(flag)minx=min(minx,temp);
    }
    if(minx==1e9)cout<<-1<<endl;
    else cout<<minx<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

#define STR_MAX	100

int main(void)
{
	char w[STR_MAX + 1] = {'\0'};
	int num['z' - 'a' + 1] = {0};
	char *wp = w;
	int cnt;

	scanf("%s", wp);

	while (*wp != '\0') {
		num[*wp - 'a']++;
		wp++;
	}

	for (cnt = 0; cnt < ('z' - 'a' + 1); cnt++) {
		if ((num[cnt] % 2) != 0) {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}


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

Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int n;
	cin>>n;
	int dp[n];
	int array[n];
	for(int x=0;x<n;x++){
		cin>>array[x];
	}
	dp[0]=0;
	dp[1]=abs(array[1]-array[0]);
	for(int x=2;x<n;x++){
		dp[x]=min(dp[x-1]+abs(array[x]-array[x-1]),dp[x-2]+abs(array[x]-array[x-2]));
	}
	cout<<dp[n-1];
	
	
	
	
	
	
return 0;
}


Measured memory_bytes: 1792
# http://zehnpaard.hatenablog.com/entry/2018/06/26/201512
# https://atcoder.jp/contests/nikkei2019-qual/submissions/4112080

from collections import deque, defaultdict

V, E = map(int, input().split())
g = defaultdict(set)
# グラフの隣接リスト
h = defaultdict(int)
# 頂点の入次数を管理

for _ in range(V - 1 + E):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    # 頂点は0-indexedで管理する
    g[s].add(t)
    # 頂点sから頂点tへの有向辺
    h[t] += 1

root = -1
# 根の頂点番号（出力時の0-indexedから1-indexedへの変換（+1）で0になるようにとる）

q = deque((v1, root) for v1 in range(V) if h[v1] == 0)
# 入次数0の頂点の「番号v1とその親root」

res = [-1] * V
# 親の頂点番号（0-indexedなので、出力時に1-indexedに直す）

while q:
    # qがなくなるまでループ
    v1, root = q.popleft()
    res[v1] = root
    for v2 in g[v1]:
        h[v2] -= 1
        # 隣接する頂点の入次数をマイナス1
        if h[v2] == 0:
            q.append((v2, v1))
            # これによって入次数が0になればqに追加

res = tuple(map(lambda x: x + 1, res))
print(*res, sep='\n')


Measured memory_bytes: 51584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
int solve(int h,int w,int ht){
    int ans=1000000007;
    int up,left,right;
    up=w*ht;
    int min=ans;
    for(int i=1;i<w;i++){
        left=i*(h-ht);
        right=(w-i)*(h-ht);
        vector<int> buf;
        buf.push_back(left);
        buf.push_back(right);
        buf.push_back(up);
        sort(buf.begin(),buf.end());
        int sub=buf[2]-buf[0];
        if(min>sub)min=sub;
    }
    return min;
}
signed main(){
    int h,w;cin>>h>>w;
    int ans=10000007;
    int bb=max(h,w);
    int aa=min(h,w);
    h=bb;w=aa;
    if(h%3==0||w%3==0){
        ans=0;
    }
    else if(1){
        for(int i=0;i<2;i++){
        int ht,ht2,ans1;
        ht=h/3;
        ht2=h/3+i;
        //if(ht2<1||ht2>h)continue;
        ans1=solve(h,w,ht);
        ans1=min(ans1,solve(h,w,ht2));
        int ans2;
        ht=w/3;
        ht2=w/3+i;
        //if(ht2<1||ht2>w)continue;
        ans2=solve(w,h,ht);
        ans2=min(ans2,solve(w,h,ht2));

        ht2=h/3-i;
        //if(ht2<1||ht2>h)continue;
        ans1=min(ans1,solve(h,w,ht2));
        ht2=w/3-i;
        //if(ht2<1||ht2>w)continue;
        ans2=min(ans2,solve(w,h,ht2));

        ans=min(ans,ans2);
        ans=min(ans,ans1);
        }
        ans=min(ans,w);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		//sc??¨dice??????????????????????????????
		Scanner sc = new Scanner(System.in);
        Dice7 dice7 = new Dice7();

        //dice1???????????????
        for(int i = 0 ; i < 6 ; i ++){
            dice7.dice1[i] = sc.nextInt();
        }

        //dice2???????????????
        for(int i = 0 ; i < 6 ; i ++){
            dice7.dice2[i] = sc.nextInt();
        }

        //dice7????????????check()????£??????§???
        System.out.println(dice7.check());
        sc.close();
	}
}

class Dice7{
	//?????£?????????
	int[] dice1 = new int[6];
	int[] dice2 = new int[6];
	int temp = 0;

	//???????????????????????\????????????
	void rollN(char N){
		temp = dice1[0];
		dice1[0] = dice1[1];
		dice1[1] = dice1[5];
		dice1[5] = dice1[4];
		dice1[4] = temp;
	}

	void rollS(char S){
		temp = dice1[0];
		dice1[0] = dice1[4];
		dice1[4] = dice1[5];
		dice1[5] = dice1[1];
		dice1[1] = temp;
	}

	void rollE(char E){
		temp = dice1[0];
		dice1[0] = dice1[3];
		dice1[3] = dice1[5];
		dice1[5] = dice1[2];
		dice1[2] = temp;
	}

	void rollW(char W){
		temp = dice1[0];
		dice1[0] = dice1[2];
		dice1[2] = dice1[5];
		dice1[5] = dice1[3];
		dice1[3] = temp;
	}
	void rollL(char L){
		temp = dice1[2];
		dice1[2] = dice1[1];
		dice1[1] = dice1[3];
		dice1[3] = dice1[4];
		dice1[4] = temp;

	}
	void rollR(char R){
		temp = dice1[1];
		dice1[1] = dice1[2];
		dice1[2] = dice1[4];
		dice1[4] = dice1[3];
		dice1[3] = temp;
	}

	String check(){
		String check = "No";

		//?????????4?????????(???????????????????????????)
		for(int i = 0; i < 4; i++){
			//Ans???true?????£??????for???????????????
			if(Ans()){ check = "Yes";}
			rollN('N');

			//??¨??????4?????????()
			for(int j = 0; j < 4; j++){
				if(Ans()){ check = "Yes";}
				rollR('R');
			}
		}


		//?¨?????????§????????????
		for(int i = 0; i < 3; i++){
			if(Ans()){ check = "Yes";}
			rollW('W');

			//?¨????4????????????
			for(int j = 0; j < 4; j++){
				if(Ans()){ check = "Yes";}
				rollR('R');
			}
		}

		//?????????String??§??????
		return check;

	}

	//??¨??¨????????´???????????????true?????????
	//????????£???Arrays.equals??¨???????????????????????????
	boolean Ans(){
		if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] &&
				dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5]){
			return true;

		}else{
			return false;
		}
	}
}

Measured memory_bytes: 26316
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <cassert>

using namespace std;
typedef long long ll;

static mt19937 engine(random_device{}());

int rnd(int mod) { return engine() % mod; }

ll solve(int n, int k, vector<int> &p, vector<ll> &c) {
    ll ret = -(1LL << 60);
    for (int i = 0; i < n; i++) {
        int cycle = 0, now = i;
        ll cost = 0;
        do {
            cycle++, now = p[now], cost += c[now], ret = max(ret, cost);
        } while (now != i && cycle < k);

        if (cost > 0) {
            cost *= (ll) (k - 1) / cycle;
            ret = max(ret, cost);
            for (int j = 0; j < (k - 1) % cycle + 1; j++) {
                now = p[now], cost += c[now], ret = max(ret, cost);
            }
        }
    }
    return ret;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i], p[i]--;
    vector<ll> c(n);
    for (int i = 0; i < n; i++) cin >> c[i];

    cout << solve(n, k, p, c) << endl;
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, T;
  std::cin >> N >> T;
  std::vector< ll > vt(N+1, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vt[i];
  }
  vt[N] = INF;

  ll ans = 0LL;
  for (ll i = 0; i < N; i++) {
    ans += std::min(T, vt[i+1] - vt[i]);
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

int d[100005];

int main(){
  int n,q; cin>>n>>q;
  string s; cin>>s;
  int mc=0;
  rep(i,s.size()){
    if(s[i]=='A'&&s[i+1]=='C'&&i!=s.size()-1){
      d[i]=mc;mc++;
      d[i+1]=mc;
      i++;
    }else{
      d[i]=mc;
    }
  }

  vector<int> ans(q);
  rep(i,q){
    int l,r; cin>>l>>r;
    l--;r--;
    ans[i]=d[r]-d[l];
  }
  rep(i,q)
  cout<<ans[i]<<endl;

  // rep(i,s.size()){
  //   cout<<d[i]<<(i==s.size()-1?"\n":" ");
  // }

  return 0;
}


Measured memory_bytes: 1792
gets
x = gets.split(" ").map(&:to_f)
y = gets.split(" ").map(&:to_f)
d = [x,y].transpose.map{|c| c.inject(:-).abs}
4.times do |i|
  puts ((i+1 == 4) ? d.max : d.map{|c| c**(i+1)}.inject(:+)**(1.0/(i+1))).round(6)
end

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

int main() {
    int k; cin >> k;
    for(int i = 0; i < k; i++) {
        int n, m;
        bool flag = true;
        cin >> n >> m;
        int t = n * n + m * m;
        for(int x = -144; x < 144; x++) {
            for(int y = -144; y < 144; y++) {
                if ((abs(x) || abs(y)) && t % (x * x + y * y) == 0) {
                    if (t * (x * x + y * y) == t);
                    else if (x * x + y * y == t);
                    else flag = false;
                }
            }
        }

        cout << (flag ? "P" : "C") << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B = MAP()

print(max(A+A-1,A+B, B+B-1))

Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define endl "\n"
#define INF (int)1e9
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;
using ull = unsigned long long;
using namespace std;

int dp[100000]={0};
int ans = 0;

int dfs(int src, vector<vector<int>> &arr){
	if(dp[src]) return dp[src];
	
	int curr = 0;
	for(int i : arr[src]){
		curr = max(curr, 1 + dfs(i, arr));
	}

	dp[src] = curr;
	return dp[src];	
}


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

    int n, m;    
    cin >> n >> m;
    vector<vector<int>> arr(n);
    
    for(int i = 0; i < m; i++){
		int p, q;
		cin >> p >> q;
		--p; --q;
		
		arr[p].push_back(q);
	}
	
	for(int i = 0; i < n; i++){
		ans = max(ans, dfs(i, arr));
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 8192
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  N=this.input[0];
  M=this.input[1];
  SN=String(this.input[0]);
  SM=String(this.input[1]);

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop, callback){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const main = () => {
  const o = new AtCoder()
  for(let i=0;i<3;i++){
    if(o.SN[i] == '7') {
      o.Yes()
      return
    }
  }
  o.No();
}
main();

Measured memory_bytes: 29612
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    char iTenki[4];
    scanf("%s", iTenki);
    int nAns = 0;
    int nTmp = 0;
    for(int i = 0; i < 3; i++){
        if(iTenki[i]=='R'){
            nTmp++;
        } else {
            nTmp = 0;
        }
        if(nTmp > nAns){
            nAns = nTmp;
        }
    }
    printf("%d", nAns);
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2e5+5;
vector<int> graph[M];
bool vis[M]={0};
int dfs(int i){
	vis[i]=1;
	int cnt = 1;
	for(auto node:graph[i]){
		if(!vis[node]){
			cnt+=dfs(node);
		}
	}
	return cnt;
}
int main(){
	//freopen("test.in","r",stdin);
	int n,m;
	cin>>n>>m;
	while(m--){
		int a,b;
		cin>>a>>b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	int res = 0;
	for(int i=1;i<=n;i++){
		if(!vis[i])res = max(res,dfs(i));
	}
	cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 24100
def resolve():
    N = int(input())
    ans = ''

    for i in range(1, 99):
        if N <= 26 ** i:
            N -= 1
            for j in range(i):
                ans += chr(ord('a') + N % 26)
                N //= 26
            break
        else:
            N -=26 **i
    print(ans[::-1])
    return

resolve()

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int n;
	scanf("%d", &n);
	vector<int> h(n);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);

	h[0]--;
	for (int i = 1; i < n; i++) {
		if (h[i-1] < h[i]) h[i]--;
		if (h[i-1] > h[i]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}


Measured memory_bytes: 640
#include <iostream>


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

    long long ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3772
#include<stdio.h>
#define MAX 100
#define INF 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1

void dijkstra();

int n;
int A[MAX][MAX];
int visit[MAX];
int d[MAX];

int main(){
    int i,j,u,k,v,c;
   

    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            A[i][j]=INF;
        }
    }

    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            A[u][v]=c;
        }
    }

    dijkstra();

    for(i=0;i<n;i++){
        if(d[i]==INF) printf("%d %d\n",i,-1);
        else printf("%d %d\n",i,d[i]);
    
    }

    return 0;
}

void dijkstra(){
    int i,v,mincost,u;

    for(i=0;i<n;i++){
        visit[i]=WHITE;
        d[i]=INF;
    }

    d[0]=0;
    visit[0]=GRAY;

    while(1){
        mincost=INF;
        u=-1;
        for(i=0;i<n;i++){
            if(visit[i]!=BLACK && d[i]<mincost){
                mincost=d[i];
                u=i;
            }
        }
        if(mincost==INF) break;
        visit[u]=BLACK;

        for(v=0;v<n;v++){
            if(visit[v] != BLACK && A[u][v] != INF){
                if(d[u]+A[u][v] < d[v]){
                    d[v]=d[u]+A[u][v];
                    visit[v]=GRAY;
                }
            }
        }
    }

}




Measured memory_bytes: 2060
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define pc(x) __builtin_popcount((x))
#define inf 10000000000000000
#define MOD 1000000007	
#define N 200005
#define M 100005
#define LOG 20
#define KOK 5880
#define EPS 0.00000001
using namespace std;

int n,a,b;

vector<int> solve(int bas,int son,int rm) {

	if(rm==0) {

		return {0};

	}

	vector<int> l,r;

	vector<int> res;

	for(int i=0;i<rm;i++) {

		if((bas&pw(i))!=(son&pw(i))) {

			int bn=(bas-(bas&pw(i))+(bas&1)*pw(i))>>1;
			int sn=(son-(son&pw(i))+(son&1)*pw(i))>>1;

			l=solve(bn,sn^1,rm-1);
			r=solve(sn^1,sn,rm-1);

			for(int cur:l) {

				int nw=cur<<1;

				nw+=((nw&pw(i))>0);

				if((nw&pw(i))!=(bas&pw(i))) nw^=pw(i); 

				res.pb(nw);

			}

			for(int cur:r) {

				int nw=cur<<1;

				nw+=((nw&pw(i))>0);

				if((nw&pw(i))!=(son&pw(i))) nw^=pw(i);

				res.pb(nw);

			}

			break ;

		}

	}

	return res;

}

int main(int argc,char* argv[]) {

	scanf("%d %d %d",&n,&a,&b);

	b^=a;

	if(pc(b)%2==0) {

		printf("NO");

		return 0;

	}

	vector<int> res=solve(0,b,n);

	printf("YES\n");

	for(int i:res) printf("%d ",a^i);

}


Measured memory_bytes: 1628
#include"bits/stdc++.h"
using namespace std;
int main()
{
	int n,t,br=0,seq=1,count=0;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		
          {
		    if(t!=seq)
			  br++;
		    else 
			  seq++;
		}


	}if(br==n)
			cout<<"-1"<<endl;
    else
	        cout<<br<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	
	int N;
	int rate[100];
	int i=0;
	int color=0;
	int f0=0, f1=0, f2=0, f3=0, f4=0, f5=0, f6=0, f7=0, f8=0; 
	
	cin >> N;
	
	while(i < N){
		cin >> rate[i];
		i++;
	}
	
	i = 0;
	
	while (i < N){
		if(rate[i] >= 1 and rate[i] <= 399){
			if (f0 == 0){
				color = color + 1;
			}
			f0++;
		}else if(rate[i] >= 400 and rate[i] <= 799){
			if (f1 == 0){
				color = color + 1;
			}
			f1++;
		}else if(rate[i] >= 800 and rate[i] <= 1199){
			if (f2 == 0){
				color = color + 1;
			}
			f2++;
		}else if(rate[i] >= 1200 and rate[i] <= 1599){
			if (f3 == 0){
				color = color + 1;
			}
			f3++;
		}else if(rate[i] >= 1600 and rate[i] <= 1999){
			if (f4 == 0){
				color = color + 1;
			}
			f4++;
		}else if(rate[i] >= 2000 and rate[i] <= 2399){
			if (f5 == 0){
				color = color + 1;
			}
			f5++;
		}else if(rate[i] >= 2400 and rate[i] <= 2799){
			if (f6 == 0){
				color = color + 1;
			}
			f6++;
		}else if(rate[i] >= 2800 and rate[i] <= 3199){
			if (f7 == 0){
				color = color + 1;
			}
			f7++;
		}else{
			f8++;
		}
		i++;
	}
	
	if(f0 == 0 and f1 == 0 and f2 == 0 and f3 == 0 and f4 == 0 and f5 == 0 and f6 == 0 and f7 == 0){
		cout << "1 ";
	}else{
		cout << color << " ";
	}
	
	cout << color + f8;
	
	return 0;
}

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

if __name__ == '__main__':
    S = input()

    W_count = S.count('W')
    idx, count, result = 0, 0, 0

    while count < W_count:
        if S[idx] == 'W':
            result += idx - count
            count += 1
        idx += 1

    print(result)


Measured memory_bytes: 3500
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <queue>
using namespace std;
const int N = 5000+5;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
#define mp make_pair
#define pb push_back
#define inf 1e18
int wrong[N];
int main()
{
  ios_base:: sync_with_stdio(false); cin.tie(0);
  // freopen ("inp","r",stdin);
  // freopen ("out","w",stdout);

  int n,k;
  string s;
  cin>>n>>k>>s;
  int j=0,seg=0,ans=0;
  for(int i=0;i<n;i++)
  {
    if(s[i]=='0' && (i==0 || (i>0 and s[i-1]=='1')) )
    {
      seg++;
    }
    while (seg>k and j<i)
    {
      j++;
      if(s[j]=='1' and s[j-1]=='0')
      {
        seg--;
      }
    }
    ans=max(ans,i-j+1);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int a,b,c,d,e=0,f,g,h,i,j,k;
    for(d=1;d<=100;d++)
    {
     
    scanf("%d %d %d",&a,&b,&c);
     
    if(a==-1&&b==-1&&c==-1)
    {
        break;
    }
    if(a==-1||b==-1)
    {
        printf("F\n");
        continue;
    }
     
    e=a+b;
    if(e>=80)
    {
        printf("A\n");
        continue;
    }
    else if(e>=65)
    {
        printf("B\n");
        continue;
    }
    else if(e>=50||c>=50)
    {
        printf("C\n");
        continue;
    }
    else if(e>=30)
    {
        printf("D\n");
        continue;
    }
    else if(e<30)
    {
        printf("F\n");
        continue;
    }   
    }
}


Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = Integer.parseInt(sc.next());
        long B = Integer.parseInt(sc.next());
        double K = (A + B) / 2d;

        if (K == (long) K) {
            System.out.println((long) K);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  string s;
  cin>>s;
  if(s[0]-'0' == 7 || s[1]-'0' == 7 || s[2]-'0' == 7){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  if ((a>=2800) && (a<=5000)) {
    if (a>=3200) {
      string s;
    cin >> s;
    cout << s << "\n";
    } else {
      cout << "red" << "\n";
    }
  } else {
    cout << "error" << "\n";
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

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

	let diff = b - a;
	let mut west = 0;
	for i in 1..=diff {
		west += i;
	}

	println!("{}", west - b);
}


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

using namespace std; 

int main(){ 
  int n;
  cin>>n;
  int a=0;
  while(n){
    if(n>1){
      n/=2;
      a+=1;
    }
    else{
      break;
    }
  }
  int b=1;
  for(int i=0;i<a;++i){
    b*=2;
  }
  cout<<b;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
I = [list(map(int, input().split())) for _ in range(M)]
s = [0] * M
c = [0] * M
for i in range(M):
    s[i] = I[i][0]
    c[i] = I[i][1]
ans = -1
if N == 1:
    for i in range(0, 10):
        flg = 0
        for j in range(M):
            if c[j] != i:
                flg = 1
                break
        if flg == 1:
            continue
        if ans == -1:
            ans = i
        else:
            ans = min(ans, i)
else:
    for i in range(10**(N-1), 10**N):
        i = str(i)
        flg = 0
        for j in range(M):
            if i[s[j]-1] == str(c[j]):
                continue
            flg = 1
            break
        if flg == 1:
            continue
        if ans == -1:
            ans = int(i)
        else:
            ans = min(ans, int(i))

print(ans)

Measured memory_bytes: 9184
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.trim.split(" ").map(_.toInt))
    val n = in.next.head
    val t = (0 to n-1).toArray
    val d = in.toSeq
    val es = (for (i <- (0 to n-2); j <- (i+1 to n-1) if d(i)(j) != -1) yield (i, j, d(i)(j))).sortBy(_._3)
    var cost = 0
    val find: Int => Int = m => if(t(m) == m) m else {t(m) = find(t(m)); t(m)}
    val unite: (Int, Int) => Unit = (x, y) => {
        val _x = find(x)
        val _y = find(y)
        if(_x != _y) t(_x) = _y
    }
 
    es.foreach(e => if (find(e._1) != find(e._2)) {unite(e._1, e._2); cost += e._3})
    println(cost)
}

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

int main() {
    int n, cnt=0;
    string s;
    cin>>n>>s;

    for(int i=0; i<n-1; i++){
        if(s.at(i)==s.at(i+1)) cnt++;
    }

    cout<<n-cnt<<endl;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
from bisect import bisect
vs = list(Counter(A).values())
vs.sort()
cums = [0]
for v in vs:
    cums.append(cums[-1] + v)

def is_ok(k,m):
    j = bisect(vs,m)
    z = cums[j] + m*(len(vs)-j)
    return z >= m*k

ans = []
for k in range(1,N+1):
    if k > len(vs):
        ans.append(0)
    else:
        ok = 0
        ng = N//k + 1
        while ng-ok > 1:
            m = (ok+ng)//2
            if is_ok(k,m):
                ok = m
            else:
                ng = m
        ans.append(ok)

print(*ans, sep='\n')

Measured memory_bytes: 124180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lolololololol ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main(){ lolololololol
	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	ll ans=min(a, k); k-=min(a, k);
	if(k==0){cout<<ans<<endl; return 0;}
	k-=min(k, b);
	if(k==0){cout<<ans<<endl; return 0;}
	ans-=min(c, k);
	cout<<ans<<endl;
}

Measured memory_bytes: 3652
import collections

N = int(input())
S = [str(input())[0] for _ in range(N)]
ref_lst = [["M",0],["A",0],["R",0],["C",0],["H",0]]

for i in range(5):
    ref_lst[i][1] = S.count(ref_lst[i][0])

ans = 0
for j in range(5):
    for k in range(j+1,5):
        for l in range(k+1,5):
            ans += ref_lst[j][1]*ref_lst[k][1]*ref_lst[l][1]

print(ans)

Measured memory_bytes: 10140
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

int get(int x)
{
	int cnt = 0;
	while(x % 2 == 0)
		x /= 2, cnt++;
	return cnt;
}
            	
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	int a, b, c;
	cin >> a >> b >> c;
	if ((a + b + c) & 1)
	{
		cout << 0 << endl;
		return 0;
	}
	if (a == b && b == c)
		cout << -1 << endl;
	else	
		cout << min(min(get(a + b), get(a + c)), get(b + c)) << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>

int a[200007];
int ball[200007];
using namespace std;

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

    for(int i=1; i<=M; i++) scanf("%d ", &a[i]);

    for(int i=M; i>0; i--)
    {
        int p=0, k=i*2;
        while(k<=M){ p+=ball[k]; k+=i; }

        if(a[i]==p%2) ball[i]=0;
        else ball[i]=1;
    }

    int res=0;
    for(int i=1; i<=M; i++){ res+=ball[i]; }

    printf("%d\n", res);
    
    for(int i=1; i<=M; i++)
    {
        if(ball[i]) printf("%d ",i);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>

int main(){
	int kelipatan,batas1,batas2;
	scanf("%d %d %d", &kelipatan,&batas1,&batas2);
	int temp=batas2/kelipatan;
	if(temp*kelipatan>=batas1){
		printf("OK\n");
	}
	else printf("NG\n");
	return 0;
}

Measured memory_bytes: 1620
s=list(input())

def hoge(s):
    if s == "A" or s == "C" or s == "G" or s == "T":
        return True
    else:
        return False


ans_list=[]
for i in range(len(s)):
    ans = 0
    if hoge(s[i]):
        ans+=1
        for j in range(i+1,len(s)):
            if hoge(s[j]):
                ans+=1
            else:
                ans_list.append(ans)
                break
    ans_list.append(ans)
print(max(ans_list))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int max = 0;
    for(int i = 0;i < s.size();i++) {
        int j = 0;
        int count = 0;
        while(i + j < s.size() && (s.at(i + j) == 'A' || s.at(i + j) == 'C' || s.at(i + j) == 'G' || s.at(i + j) == 'T')) {
            count++;
            j++;
        }
        if(max < count) {
            max = count;
        }
    }
    cout << max << endl;
}


Measured memory_bytes: 256
import numpy as np


def solve(string):
    n, *a = map(int, string.split())
    a = np.asarray(a)
    m = 10**9 + 7
    ans = 0
    for i in range(60):
        s = int((a & 1).sum())
        a >>= 1
        ans += s * (n - s) * pow(2, i, m) % m
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

long long const MOD = 1e9 + 7;

long long modadd(long long a, long long b, long long mod = MOD) {
  return ((a % mod) + (b % mod)) % mod;
}

long long modmul(long long a, long long b, long long mod = MOD) {
  return ((a % mod) * (b % mod)) % mod;
}

void Main() {
  int n, m;
  cin >> n >> m;

  int x[n], y[m];

  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }

  for (int i = 0; i < m; i++) {
    cin >> y[i];
  }

  long long X = 0;
  for (int i = 0; i < n; i++) {
    X = (X + (modmul(i, x[i]) - modmul((n - i - 1), x[i])) % MOD) % MOD;
    if (X < 0) X += MOD;
  }

  long long Y = 0;
  for (int i = 0; i < m; i++) {
    Y = (Y + (modmul(i, y[i]) - modmul((m - i - 1), y[i])) % MOD) % MOD;
    if (Y < 0) Y += MOD;
  }

  cout << modmul(X, Y) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

int main(){
  int N;
  cin>>N;
  vector<pair<int,ll>>A[N];
  int f,t;
  long long c;
  for(int i=0;i<N-1;i++){
    cin>>f>>t>>c;
    f--;
    t--;
    A[f].push_back({t,c});
    A[t].push_back({f,c});
  }
  
  int Q,K;
  cin>>Q>>K;
  K--;
  long long D[N]={};
  queue<int>que;
  que.push(K);
  D[K]=0;
  while(que.size() != 0){
    int temp=que.front();
    que.pop();
    for(auto itr=A[temp].begin();itr !=A[temp].end();itr++){
      if(D[(itr->first)]==0){
        D[(itr->first)]=D[temp]+(itr->second);
        //cout<<temp<<" "<<itr->first<<" "<<itr->second<<endl;
        que.push(itr->first);
      }
    }
  }
  int x,y;
  for(int i=0;i<Q;i++){
    cin>>x>>y;
    x--;
    y--;
    cout<<D[x]+D[y]<<endl;
  }
  return 0;
}

           

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

int main() {
    int N; cin>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    int ans=0;
    rep(i,N){
        int mn=i;
        for(int j=i;j<N;j++){
            if(A[j]<A[mn]) mn=j;
        }
        swap(A[i],A[mn]);
        if (mn!=i)ans++;
    }
    rep(i,N){
        cout<<A[i];
        if(i!=N-1)cout<<' ';
        else cout<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3116
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int length = s.length();
        int cnt = 0; //ATGC文字列の長さ
        int max = 0; //ATGC文字列の長さの最大
        String[] sArray = s.split("");//配列に1文字ずつ入れる
        for(int i = 0; i < length; i++)
        {
           if(sArray[i].equals("A") || sArray[i].equals("T") || sArray[i].equals("G") || sArray[i].equals("C"))
           {
                cnt++;
                max = Math.max(cnt,max);
           }else{
               cnt = 0;
           } 
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
main() {
	int n,m;
	cin>>n>>m;
	if(m==1) puts("0"),exit(0);
	for(int i=1; i<=100; i++)
		if(n*i-i+1>=m)
			cout<<i,exit(0);
}

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

int main(void){
    int A,B,Q; cin >> A >> B >> Q;
    vector<ll> s(A), t(B), X(Q);
    for(int i=0; i<A; i++) cin >> s[i];
    for(int i=0; i<B; i++) cin >> t[i];
    for(int i=0; i<Q; i++) cin >> X[i];
    
    for(int i=0; i<Q; i++){
        ll x=X[i];
        
        if(x<s[0] && x<t[0]){
            cout << max(s[0],t[0])-x << endl;
        }
        else if(x>s[A-1] && x>t[B-1]){
            cout << x-min(s[A-1],t[B-1]) << endl;
        }
        else if(x<s[0] && x>t[0] && x<t[B-1]){
            auto it1=upper_bound(t.begin(), t.end(), x);
            ll tRight=*it1;
            it1--;
            ll tLeft=*it1;
            cout << min(max(s[0], tRight)-x , min(2*s[0]-x-tLeft, s[0]+x-2*tLeft)) << endl;
        }
        else if(x>s[0] && x<t[0] && x<s[A-1]){
            auto it1=upper_bound(s.begin(), s.end(), x);
            ll sRight=*it1;
            it1--;
            ll sLeft=*it1;
            cout << min(max(t[0],sRight)-x, min(2*t[0]-x-sLeft, t[0]+x-2*sLeft)) << endl;
        }
        else if(x>s[A-1] && x<t[B-1] && x>t[0]){
            auto it1=upper_bound(t.begin(), t.end(), x);
            ll tRight=*it1;
            it1--;
            ll tLeft=*it1;
            cout << min(x-min(s[A-1],tLeft), min(2*tRight-x-s[A-1], tRight+x-2*s[A-1])) << endl;
        }
        else if(x<s[A-1] && x>t[B-1] && x>s[0]){
            auto it1=upper_bound(s.begin(), s.end(), x);
            ll sRight=*it1;
            it1--;
            ll sLeft=*it1;
            cout << min(min(2*sRight-x-t[B-1], sRight+x-2*t[B-1]), x-min(t[B-1], sLeft)) << endl;
        }
        else if(x<s[0] && x>t[B-1]){
            cout << min(2*s[0]-x-t[B-1], s[0]+x-2*t[B-1]) << endl;
        }
        else if(x>s[A-1] && x<t[0]){
            cout << min(2*t[0]-x-s[A-1], t[0]+x-2*s[A-1]) << endl;
        }
        else{
            auto it1=upper_bound(s.begin(), s.end(), x);
            ll sRight=*it1;
            it1--;
            ll sLeft=*it1;
            auto it2=upper_bound(t.begin(), t.end(), x);
            ll tRight=*it2;
            it2--;
            ll tLeft=*it2;

            ll a=x-min(sLeft, tLeft);
            ll b=max(sRight, tRight)-x;
            ll c=min(2*sRight-x-tLeft, sRight+x-2*tLeft);
            ll d=min(2*tRight-x-sLeft, tRight+x-2*sLeft);
            ll e=min(c,d);
            //ll c=min(sRight-tLeft, tRight-sLeft);
            cout << min(a,min(b,e)) << endl;
            
        }

    }


}

Measured memory_bytes: 3712
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char a = s.charAt(0);
        char aa = 'a';
        char zz = 'z';
        int nu = aa;
        int zu = zz;
        int che = a;
        if(nu <= che && che <= zu){
            System.out.println("a");
        }else{
            System.out.println("A");
        }
        sc.close();
    }
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
  int x,y;
  cin >> x >> y;
  if(y-x>=2019){
    cout << 0 << endl;
    return 0;
  }
  int ans=2018;
  rrep(i,x,y)rrep(j,i+1,y+1){
    int a=i%2019,b=j%2019;
    chmin(ans,(a*b)%2019);
  }
  cout << ans << endl;
}


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

typedef struct{
	string name;
	vector<int> vec;
}acount;

acount a[1001];

void print(int dot,int num){
	for(int i = 0;i < dot;i++){
		cout << '.';
	}
	cout << a[num].name << endl;
	for(int i = 0;i < a[num].vec.size();i++){
		print(dot+1,a[num].vec[i]);
	}
}

int main(){
	int n,x;
	cin >> n;
	cin >> x >> a[1].name;
	for(int i = 2;i <= n;i++){
		cin >> x >> a[i].name;
		a[x].vec.push_back(i);
	}
	print(0,1);

	return 0;
}

Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int64_t a, b, x;
    cin >> a >> b >> x;
    b = b / x + 1;
    if (a != 0) {
        a = (a - 1) / x + 1;
    }
    cout << b - a << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, k,x,l=0,ans;
    cin >> a >> b >> k;
    x = min(a, b);
    for (int i = 0; i < x;i++){
        if (a % (x-i) == 0 && b % (x-i)== 0){
            l++;
        }if(l==k){
            ans = x-i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=100010,M=200010;
struct edge {
    int to,next,val;
} e[M];
int head[N],tot=0;
void add_edge(int u,int v,int val) {
    e[tot].to=v;
    e[tot].val=val;
    e[tot].next=head[u];
    head[u]=tot++;
}
int in[N],dis[N];

int n,m,l,r,d;
int main()
{
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    memset(dis,INF,sizeof(dis));
    for (int i=1;i<=m;i++) {
        scanf("%d%d%d",&l,&r,&d);
        add_edge(l,r,d);
        in[r]++;
    }
    queue<PII> q;
    for (int i=1;i<=n;i++) {
        if (!in[i]) q.push(mp(i,0));
    }
    if (m>0&&q.empty()) {
        printf("No\n");
        return 0;
    }
    int cnt=0;
    while (!q.empty()) {
        PII cur=q.front();//printf("cur:%d dis:%d\n",cur.first,cur.second);
        q.pop();
        if (dis[cur.first]==INF) {
            cnt++;
            dis[cur.first]=cur.second;
            for (int i=head[cur.first];i!=-1;i=e[i].next) {
                int to=e[i].to;
                q.push({to,cur.second+e[i].val});
            }
        } else {
            if (dis[cur.first]!=cur.second) {
                printf("No\n");
                return 0;
            }
        }
    }
    if (cnt==n) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
 
using namespace std;
 
const int INF = 1e9;
 
bool flag[105];
 
int main() {
	int x, n;
	scanf("%d%d", &x, &n);
	
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		flag[x] = 1;
	}
	
	int v = INF;
	int res = -1;
	
	for (int i = 0; i <= 101; i++) {
		if (flag[i]) continue;
		if (abs(x - i) < v) {
			v = abs(x - i);
			res = i;
		}
	}
	
	printf("%d\n", res);
}

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

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

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1, i >= 0, i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    vector<ll> ans_v;
    while (true) {
        ll n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) {
            break;
        }
        ll ans = 0;
        repd(l0, 1, n + 1) {
            repd(l1, l0 + 1, n + 1) {
                repd(l2, l1 + 1, n + 1) {
                    if (l0 + l1 + l2 == x) {
                        ans++;
                    }
                }
            }
        }
        ans_v.push_back(ans);
    }
    rep(i, ans_v.size()) { cout << ans_v[i] << endl; }
    return 0;
}




Measured memory_bytes: 3120
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a0 = sc.nextInt();
			int l = sc.nextInt();
			if (a0 == 0 && l == 0)
				break;
			Vector<Integer> a = new Vector<Integer>(0);
			a.add(a0);
			while (true) {
				String s = Integer.toString(a0);
				while (s.length() < l)
					s = "0" + s;
				char[] minc = s.toCharArray();
				char[] maxc = s.toCharArray();
				Arrays.sort(minc);
				for (int i = 0; i < l; i++)
					maxc[i] = minc[l - 1 - i];
				int max = Integer.parseInt(String.valueOf(maxc));
				int min = Integer.parseInt(String.valueOf(minc));
				a0 = max - min;
				if (a.contains(a0)) {
					System.out.println(a.indexOf(a0) + " " + a0 + " "
							+ (a.size()-a.indexOf(a0)));
					break;
				}
				a.add(a0);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 20848
#include<stdio.h>
#define MAX 20000
#define INFTY 100000000

int n, box[MAX][MAX];

int prim() {
	int i, j,minv, u, v, sum;
	int d[MAX], p[MAX], t[MAX];
	
	for ( i = 0; i < n;i++ ) {
		d[i] = INFTY;
		p[i] = -1;
		t[i] = 0;
	}

	d[0] = 0;

	while(1){
		minv = INFTY;
		u = -1;
		for ( i = 0; i < n; i++ ){
			if ( minv > d[i] && !t[i] ){
				u = i;
				minv = d[i];
			}
		}
		
		if ( u == -1 ) break;
		t[u] = 1;
		for ( v = 0; v < n; v++ ){
			if ( ! t[v] && box[u][v] != INFTY ){
				if ( d[v] > box[u][v] ){
					d[v] =  box[u][v];
					p[v] = u;
				}
			}
		}
	}

	sum = 0;

	for ( i = 0; i < n; i++ ){
		if ( p[i] != -1 ) sum += box[i][p[i]];
	}

	return sum;
}

int main() {
	int i, j, fact;

	scanf("%d", &n);
	for ( i = 0; i< n; i++ ){
	  for ( j = 0; j < n; j++ ){
	    scanf("%d", &fact);
	    box[i][j] = (fact == -1) ? INFTY : fact;
	  }
	}
	printf("%d\n", prim());
	
	return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == ',') {
            cout << ' ';
        } else {
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256