akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



class RangeSubstituteTree {//範囲代入
	int n, t;
	std::vector<int> ts, val;
	void Substitute(int a, int b, int x, int k, int l, int r) {
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			ts[k] = t;
			val[k] = x;
			return;
		}
		int m = (l + r) / 2;
		Substitute(a, b, x, 2 * k + 1, l, m);
		Substitute(a, b, x, 2 * k + 2, m, r);
	}
public:
	RangeSubstituteTree(int n = 1 << 20) :n(n) {
		ts.assign(2 * n - 1, t = 0);
		val.assign(2 * n - 1, 0);
	}
	void Substitute(int a, int b, int x) {//[a,b)にxを代入
		t++;
		Substitute(a, b, x, 0, 0, n);
	}
	int get(int k)const {//k番目の値
		int res, s;
		k += n - 1;
		res = val[k];
		s = ts[k];
		while (k > 0) {
			k = (k - 1) / 2;
			if (s < ts[k]) {
				s = ts[k];
				res = val[k];
			}
		}
		return res;
	}
};



struct S {
	int s, t, x;
	bool operator<(const S& a) {
		return x > a.x;
	}
} st[200000];
int n, q;

int d[200000];



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

	cin >> n >> q;
	rep(i,n) {
		cin >> st[i].s >> st[i].t >> st[i].x;
	}
	sort(st, st + n);
	rep(i,q) {
		cin >> d[i];
	}
	rep(i, q) {
		d[i] = -d[i];
	}
	reverse(d, d + q);

	RangeSubstituteTree seg;
	seg.Substitute(0, q, -1);

	rep(i, n) {
		int a = upper_bound(d, d + q, st[i].x - st[i].t) - d;
		int b = upper_bound(d, d + q, st[i].x - st[i].s) - d;
		seg.Substitute(a, b, st[i].x);
	}

	for (int i = q - 1; i >= 0;i--)cout << seg.get(i) << endl;


	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B, C, D;

bool f(){
    while(true){
        C -= B;
        if(C <= 0){
            return true;
        }

        A -= D;
        if(A <= 0){
            return false;
        }
    }
}

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

  std::cin >> A >> B >> C >> D;

  if(f()){
      std::cout << "Yes" << std::endl;
  }else{
      std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
import copy
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    Am = max(A)
    if A.count(Am)>1:
        for j in range(N):
            print(Am)
        return
    Ap = copy.copy(A)
    set(Ap)
    Ap.sort(reverse=True)
    for i in range(N):
        if  A[i] != Am:
            print(Am)
        else:
            print(Ap[1])
if __name__ == '__main__':
    main()

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

typedef long long ll;

int main(){
	ll q;
	scanf("%lld",&q);
	
	priority_queue<ll> L;
	priority_queue<ll,vector<ll>,greater<ll>> R;
	ll ret = 0;
	
	ll t,a,b;
	scanf("%lld%lld%lld",&t,&a,&b);
	L.push(a);
	ret = b;
	q --;
	
	for(;q>0;q--){
		scanf("%lld",&t);
		if(t == 1){
			scanf("%lld%lld",&a,&b);
			if(a <= L.top()){
				ret += abs(a-L.top());
				L.push(a);
				if(L.size() >= R.size()+2){
					R.push(L.top());
					L.pop();
				}
			}
			else {
				ret += abs(a-L.top());
				R.push(a);
				if(L.size() < R.size()){
					ret -= R.top()-L.top();
					L.push(R.top());
					R.pop();
				}
			}
			ret += b;
		}
		else {
			printf("%lld %lld\n",L.top(),ret);
		}
	}
}

Measured memory_bytes: 3828
#ABC151D
h,w=map(int,input().split())
s=[input() for i in range(h)]
ans=0
from collections import deque
for i in range(h):
    for j in range(w):
        q=deque()
        q.append([i,j,0])
        seen=[[False for j in range(w)] for i in range(h)]
        while q:
            node=q.popleft() 
            y=node[0]
            x=node[1]
            dist=node[2]
            if s[y][x]=='#':
                continue
            if seen[y][x]:
                continue
            seen[y][x]=True
            if dist>ans:
                ans=dist
            dif=((0,1),(0,-1),(1,0),(-1,0))
            for d in dif:
                if 0<=y+d[0]<h and 0<=x+d[1]<w:
                    q.append([y+d[0],x+d[1],dist+1])
print(ans)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

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

	ll ans=0;

	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		ans+=i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;


int main() 
{
    int N,W; cin >> N >> W;
    int v[N],w[N];
    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }
    int dp[N+1][W+1];
    for(int i = 0; i < W+1; i++){
        dp[0][i] = 0;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < W+1; j++){
            if(j-w[i] >= 0){
                dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
    int n;cin>>n;
		vector<int> v(2*n);
		rep(i,2*n)cin>>v[i];
		sort(rall(v));
		ll ans = 0;
		rep(i,n){
			ans += v[i*2 + 1];
		}
		cout << ans << endl;
}



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

int main(){
    bool flag=true;
    string s,st,str,stri,s1,s2;
    int n,n1,n2;
    cin>>s;
    n=s.length();
    n1=(n-1)/2;
    n2=(n+3)/2-1;
    st=s;
    str=s.substr(0,n1);
    stri=s.substr(n2,n);
    s1=str;
    s2=stri;
    reverse(s.begin(),s.end());
    reverse(str.begin(),str.end());
    reverse(stri.begin(),stri.end());
    if(st==s){
        if(s1==str){
            if(s2==stri){
                printf("Yes\n");
            }else{
                flag=false;
            }
        }else{
            flag=false;
        }
    }else{
        flag=false;
    }
    if(flag==false){
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
import itertools
s = list(input())
for ops in itertools.product(['+','-'],repeat=3):
  s_i = []
  for i in range(3):
    s_i.append(s[i])
    s_i.append(ops[i])
  s_i.append(s[-1])
  s_i = "".join(s_i)
  if eval(s_i)==7:
    print(s_i+"=7")
    exit()

Measured memory_bytes: 3060
#coding: utf-8


w = input()
w = w.upper()
s = []
c = 0
while True:
    i = input()
    if i == "END_OF_TEXT":
        break
    s.append(i.upper())

for i in s:
    for j in i.split(" "):
        if j == w:
            c += 1

print(c)


Measured memory_bytes: 5564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    priority_queue<int> pq;
    rep(i,n){
        int a;
        cin>>a;
        pq.push(a);
    }

    rep(i,m){
        int x=pq.top();
        pq.pop();
        x/=2;
        pq.push(x);
    }

    ll ans=0;
    rep(i,n){
        int x=pq.top();
        pq.pop();
        ans+=x;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3932
// <------------- Template -----------------------> //


#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(0);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[200];ll visit[300]={};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x,y,q;
string s;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll a(n+2);
	for(ll i=1;i<=n;i++) cin >> a[i];
	ll ans = 0;
	for(ll i=1;i<=n+1;i++) ans+=abs(a[i]-a[i-1]);
	for(ll i=1;i<=n;i++) {
		ll prev = abs(a[i]-a[i-1]) + abs(a[i]-a[i+1]);
		ll now = abs(a[i-1]-a[i+1]);
		cout<<ans-prev+now;newl;
	}
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 4028
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        stin(s);
        ll a=0;
        ll k=0;
        if(s.sz==1){
                sal(0);
                return 0;
        }
        FOR(i,0,s.sz-2){
                if(s[i]=='A'){
                        a++;
                }else{
                        if(s[i]=='B'&&s[i+1]=='C'){
                                k+=a;
                                i++;
                        }else{
                                a=0;
                        }
                }
        }
        sal(k);
}

Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);

        Integer a = Integer.parseInt(scanner.next());
        Integer b = Integer.parseInt(scanner.next());

        Long ar = 0L;
        Long br = 0L;
        boolean a_result = true;

        Long count = 10L;
        Long end = 0L;
        while(true) {
            Integer tmp_b = (int) Math.floor(count * 0.1);
            if(tmp_b == b) {
                br = count;
                end = count + 10;
                break;
            }
            count += 10;
        }

        if((int) Math.floor(count * 0.08) > a ) {
            System.out.println(-1);
            System.exit(0);
        }

        for(Long i = count; i < end; i++) {
            Integer tmp_a = (int) Math.floor(i* 0.08);
            if(tmp_a == a){
                ar = i;
                break;
            }

            if (i == end -1) {
                System.out.println(-1);
                System.exit(0);
            }
        }

        System.out.println(ar);
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
	
    long long int a, b, k, l;
    cin >> a >> b;

    l = b - a;
    k = l*(l + 1)/2;
    cout << k - b << endl;

	return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
  int i,j;
  string s;
  while(cin>>s,s[0]!='#'){
    int ln=s.length();
    for(i=0;i<ln;i=j+2){
      for(j=i;s[j]!=')';++j);
      int a[256]={};
      for(;i<j;++i){
	if(('a'<=s[i]&&s[i]<='z')||('A'<=s[i]&&s[i]<='Z')){
	  if(a[(int)s[i]]){
	    if(s[i-1]=='~'){
	      if(a[(int)s[i]]*-1<0)
		break;
	    }else{
	      if(a[(int)s[i]]*1<0)
		break;
	    }
	  }else{
	    if(s[i-1]=='~')
	      a[(int)s[i]]=-1;
	    else
	      a[(int)s[i]]=1;
	  }
	}
      }
      if(i==j)
	break;
    }
    if(i<ln)
      cout<<"yes"<<endl;
    else
      cout<<"no"<<endl;
  }
  return 0;
}

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

using namespace std;


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

	int maxCount = 0;
	unordered_map<string, int> strmap;

	for (int i = 0; i < n; ++i)
	{
		string str;
		cin >> str;

		auto itr = strmap.find(str);

		if (itr == strmap.end())
		{
			itr = strmap.emplace(make_pair(str, 1)).first;	
		}
		else
		{
			++itr->second;
		}

		maxCount = max(maxCount, itr->second);
	}

	std::vector<string> maxStr;
	maxStr.reserve(n);

	for (const auto& strpair : strmap)
	{
		if (strpair.second == maxCount)
		{
			maxStr.emplace_back(strpair.first);
		}
	}

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

	for (const string& str : maxStr)
	{
		cout << str << endl;
	}
}

Measured memory_bytes: 25672
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int H,W;
  string a;
  cin>>H>>W;
  for(int i=0;i<W+2;i++)
  {
    cout<<'#';
  }
  cout<<endl;
  for(int j=0;j<H;j++)
  {
    cin>>a;
    cout<<'#'<<a<<'#'<<endl;
  }
  for(int k=0;k<W+2;k++)
  {
    cout<<'#';
  }
  cout<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import functools
import itertools
import math
INF = float('inf')
MOD = 10**9+7

M = 60
N = int(input())
A = [int(x) for x in input().split()]
f = [[0] * M for i in range(N+1)]
for i in range(N):
    a = A[i]
    for j in range(M):
        f[i+1][j] = f[i][j] + (a & 1)
        a >>= 1
ans = 0
for i in range(N):
    k = 1
    for j in range(M):
        if (A[i]>>j) & 1:
            ans += k * (N - i - 1 - f[N][j] + f[i+1][j])
        else:
            ans += k * (f[N][j] - f[i+1][j])
        ans %= MOD
        k <<= 1
        k %= MOD
print(ans)



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


int main() {
  long long x, y;
  int count = 0;
  cin >> x >> y;

  while (y >= x) {
    y /= 2;
    count ++;
  }

  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
const int maxn = int(4e4) + 7, mod = int(1e9) + 7;
typedef long long ll;
ll fac[maxn], inv[maxn];

ll power_mod(ll p, ll q) {
    ll ret = 1;
    while (q) {
        if (q & 1) ret = ret * p % mod;
        p = p * p % mod;
        q >>= 1;
    }
    return ret;
}

void init() {
    fac[0] = 1;
    for (int i = 1; i <= maxn - 10; ++i) fac[i] = fac[i - 1] * i % mod;
    inv[maxn - 10] = power_mod(fac[maxn - 10], mod - 2);
    for (int i = maxn - 11; i >= 0; --i) inv[i] = inv[i + 1] * (i + 1) % mod;
}

ll C(int x, int y) {
    return fac[x] * inv[y] % mod * inv[x - y] % mod;
}

int n, a[2000007], b[2000007], dp[4007][4007];

int main() {
//    freopen("in.txt", "r", stdin);
    init();
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", a + i, b + i);
        dp[2001 - a[i]][2001 - b[i]]++;
    }
    for (int i = 1; i <= 4001; i++)
        for (int j = 1; j <= 4001; j++) {
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
        }
    ll ans = 0;
    for (int i = 1; i <= n; i++) ans = (ans + dp[2001 + a[i]][2001 + b[i]]) % mod;
    for (int i = 1; i <= n; i++) ans = (ans - C(a[i] + a[i] + b[i] + b[i], a[i] + a[i]) + mod) % mod;
    printf("%lld\n", ans * power_mod(2, mod - 2) % mod);
    return 0;
}

Measured memory_bytes: 67984
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main() {
string s,k="RRR";
cin>>s;
ll c=0;
for(int i=0; i<3; i++){
    if(s[i]==k[i]){c++;}
    if(c!=0 && s[i]!=k[i]){break;}
}

cout<<c;
return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cmath>

using namespace std;

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

	int ans = ceil((double)(N - 1) / (K - 1));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;

void show(vector<pair<int, int> > ponds){

	int sum=0;
	for( unsigned int i=0; i<ponds.size(); i++ ){
		sum+= ponds[i].first;
	}

	cout<<sum<<endl
		<<ponds.size()<<flush;

	for( unsigned int i=1; i<=ponds.size(); i++ ){
		cout<<' '<<ponds[ponds.size() -i].first<<flush;
	}
	cout<<endl;
}




int main()
{
	stack<int> bsli;
	vector<pair<int, int> > ponds;
	char t;
	int btop;
	int area=0;
//	int linearea=0;
	
	for( int i=0; cin>>t; i++ ){

		if( t=='\\' ){
			bsli.push(i);
		}else if( t=='/' && bsli.size() >0 ){

			btop=bsli.top(); bsli.pop();
			
			area =i -btop;



			while( ponds.size() && ponds[0].second >btop ){
				area += ponds[0].first; ponds.erase(ponds.begin());
			}

			ponds.insert(ponds.begin(), make_pair(area, btop));
		}
	}




	show(ponds);

}
				


			

Measured memory_bytes: 1284
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    string s, t;
    cin>>s>>t;
    vector<char> v;
    rep(i, n){
        v.push_back(s[i]);
        v.push_back(t[i]);
    }
    rep(i, 2*n){
        cout<<v[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int p = -1;
  int c = 0;

  for ( ; ; )
  {
    const int ch = getchar ( );

    if ( ch != p )
    {
      switch ( p )
      {
        case '1': putchar ( "',.!?"[ c % 5 ] );    break ;
        case '2': putchar ( "abcABC"[ c % 6 ] );   break ;
        case '3': putchar ( "defDEF"[ c % 6 ] );   break ;
        case '4': putchar ( "ghiGHI"[ c % 6 ] );   break ;
        case '5': putchar ( "jklJKL"[ c % 6 ] );   break ;
        case '6': putchar ( "mnoMNO"[ c % 6 ] );   break ;
        case '7': putchar ( "pqrsPQRS"[ c % 8 ] ); break ;
        case '8': putchar ( "tuvTUV"[ c % 6 ] );   break ;
        case '9': putchar ( "wxyzWXYZ"[ c % 8 ] ); break ;
        case '0':
          while ( c-- )
          {
            putchar ( ' ' );
          }
          break ;
      }
      c = 0; p = ch;
    }
    else ++c;
    if ( ch == EOF )  break ;
    if ( ch == '\n' )
    {
      putchar ( '\n' );
      p = -1; c = 0;
    }
  }
  return ( 0 );
}

Measured memory_bytes: 0
N=int(input())
ps=list(map(lambda x: int(x),input().split()))
count=0
for i in range(N-2):
    if max(ps[i],ps[i+2],ps[i+1])!=ps[i+1] and min(ps[i],ps[i+1],ps[i+2])!=ps[i+1]:
        count+=1

print(count)

Measured memory_bytes: 3060
#include <stdio.h>
 
int main(void){
	int a;
	int b;
  scanf("%d",&a);
  scanf("%d",&b);
  
  if(a>b){
    printf("%d",2*a-1);
  }
  
  else if(a==b){
  printf("%d",a+b);
  }
  
  else if(a<b){
    printf("%d",2*b-1);
  }
 return 0;
}

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

using namespace std;
const int _max = 2e6 + 10;
const int mod = 1e9 + 7;
typedef unsigned long long ll;


int main(){
    int n;
    cin>>n;
    if(n%1000==0){
        cout<<0;
    }else{
        cout<<1000-n%1000;
    }
    return 0;
}

Measured memory_bytes: 3632
def LI(): return [int(x) for x in input().split()]
def II(): return int(input())

N=II()
LIS=[LI() for i in range(N)]
DP = [[0,0,0] for i in range(N+1)]
for i, li in enumerate(LIS):
    for j in range(3):
        for k in range(3):
            if j != k:
                DP[i+1][k] = max(DP[i+1][k], DP[i][j]+li[k])


print(max(DP[N]))


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


int main(){
 
  long int H,W;
  cin>>H>>W;
  long int minn=1000000000;
  long int s1,s2,s3;
  if(H%3==0||W%3==0) {cout<<0<<endl; return 0;}
  
 for(int i = 1; i < W; ++i)
	{
		 s1 = i * H;
		 s2 = max(((W - i) / 2) * H, (W - i) * (H/ 2));
		 s3 = (W - i) * H - s2;
                long int maxs=max(max(s1,s2),s3);
                long int mins=min(min(s1,s2),s3);
                minn=min(maxs-mins,minn);
	}
 
	swap(H, W);
 
	 for(int i = 1; i < W; ++i)
	{
		 s1 = i * H;
		 s2 = max(((W - i) / 2) * H, (W - i) * (H/ 2));
		 s3 = (W - i) * H - s2;
                long int maxs=max(max(s1,s2),s3);
                long int mins=min(min(s1,s2),s3);
                minn=min(maxs-mins,minn);
	}
 
  cout<<minn<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
from itertools import islice
read = map(int, sys.stdin.read().split())

N = next(read)
candidates = [format(i, 'b').zfill(N) for i in range(2 ** N)]
A = [0] * N
xy = [[] for _ in range(N)]
for i in range(N):
    A[i] = next(read)
    xy[i].extend(list(islice(read, A[i] * 2)))

answer = 0

for candidate in candidates:
    tmp = 0
    truth = set()
    false = set()
    for k in range(N):
        if candidate[k] == '1':
            if k in false:
                break
            truth.add(k)
            for i, j in zip(*[iter(xy[k])] * 2):
                i -= 1
                if j == 1:
                    if i in false:
                        break
                    truth.add(i)
                else:
                    if i in truth:
                        break
                    false.add(i)
            else:
                continue
            break
        else:
            if k in truth:
                break
            false.add(k)
    else:
        if len(truth) > answer:
            answer = len(truth)

print(answer)

Measured memory_bytes: 5428
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a;
	string s;
	cin>>a>>s;
	int b=(s[0]-'0')*100+(s[2]-'0')*10+s[3]-'0';
	cout<<a*b/100<<endl;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int N;
    cin >> N;
    vector<int> d(101);
    REP(i,N) cin >> d.at(i);
    int sum = 0;
    REP(i, N){
        REP(j, N){
            if(i != j)sum += d.at(i) * d.at(j);
        }
    }
    cout << sum / 2 << endl;
    return 0;
}

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

using namespace std;

int main(){
  int N;
  bool b = false;
  cin >> N;
  
  for(int i = 0; i < 3; i++){
    int x;
    x = N % 10;
    if(x == 7){
      b = true;
      break;
    }
    N = N/10;
  }
  
  if(b == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
      
  return 0;
}

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

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

int N,K;
void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>N>>K;
	
	ll R=K;
	FOR(i,N-1) R*=K-1;
	cout<<R<<endl;
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    REP(i, N) cin >> A[i];
    REP(i, M) cin >> B[i];
    REP(i, N-M+1) {
        REP(j, N-M+1) {
            if (A[i][j] != B[0][0]) continue;
            bool ok = true;
            REP(k, M) {
                REP(l, M) {
                    if (A[i+k][j+l] != B[k][l]) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) break;
            }
            if (ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

const int mod = 1e9 + 7;

lli power(lli a, lli b){
	lli ans = 1;
	while(b){
		if(b & 1) ans = ans * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return ans;
}

auto phiSieve(int n){
	vector<int> phi(n+1);
	iota(phi.begin(), phi.end(), 0);
	for(int i = 2; i <= n; ++i){
		if(phi[i] == i){
			for(int j = i; j <= n; j += i){
				phi[j] -= phi[j] / i;
			}
		}
	}
	return phi;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	auto phi = phiSieve(k);
	int ans = 0;
	for(int i = 1; i <= k; ++i){
		ans += phi[i] * power(k/i, n) % mod;
		if(ans >= mod) ans -= mod;
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll v[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    ll ans = v[0];
    for(int i=1;i<n;i++){
        ans = ans/__gcd(ans,v[i]) * v[i];
    }
    cout<<ans<<"\n";
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 102;
int a[N];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = i - 1; j >= 0; j--)
        {
            if (a[j+1] < a[j])
            {
                swap(a[j+1], a[j]);
            }
            else
            {
                break;
            }
        }
        for (int j = 0; j < n - 1; j++)
        {
            printf("%d ", a[j]);
        }
        printf("%d\n", a[n-1]);
    }
    return 0;
}



Measured memory_bytes: 3204
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# scipy version

import sys
from collections import deque
from array import array

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

def input():
    return sys.stdin.readline().rstrip('\n')

##### main

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

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

for i in range(M):
    a,b,c = list(map(int, input().split()))
    if c>L:
        continue
    C[a-1][b-1] = c

Q = int(input())

ST = [None]*Q

for i in range(Q):
    s, t = list(map(int, input().split()))
    ST[i] = (s-1,t-1)

dist_matrix, predecessors = floyd_warshall(csgraph=C, directed=False, return_predecessors=True)

# D[i][j] <= L となる i,j に辺を張る
for i in range(N):
    for j in range(i+1,N):
        if dist_matrix[i][j] <= L:
            C[i][j] = 1

dist_matrix, predecessors = floyd_warshall(csgraph=C, directed=False, return_predecessors=True)

# answer
for q in range(Q):
    i,j = ST[q]
    step = dist_matrix[i][j]
    if step > 10**9:
        print(-1)
    else:
        print(int(step-1))


Measured memory_bytes: 27044
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int M,N;
char c[555][555];
int y[33][2],x[33][2],num[33];
int del[33];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>M>>N;
	rep(i,M)cin>>c[i];
	vi ys,xs;
	memset(y,-1,sizeof(y));
	rep(i,M)rep(j,N){
		if(isupper(c[i][j])){
			int col = c[i][j] - 'A';
			y[col][num[col]] = i;
			x[col][num[col]] = j;
			num[col]++;
			rep2(d,-1,2){
				ys.pb(i+d);
				xs.pb(j+d);
			}
		}
	}
	int ans = 0;
	while(1){
		int flag = 0;
		rep(yi,sz(ys))rep(xi,sz(xs)){
			int Y = ys[yi], X = xs[xi];
			if(Y<0 || M<=Y || X<0 || N<=X)continue;
			int ok = 1;
			rep(i,26)if(!del[i] && (Y == y[i][0] && X == x[i][0]
				|| Y == y[i][1] && X == x[i][1]))ok=0;
			if(!ok)continue;

			int left = -INF, right = INF, up = -INF, down = INF;
			int l=-1,r=-2,u=-3,d=-4;
			rep(i,26)if(y[i][0] != -1 && !del[i])rep(j,2){
				if(y[i][j] == Y){
					if(x[i][j] < X && x[i][j] > left){
						left = x[i][j];
						l = i;
					}
					if(x[i][j] > X && x[i][j] < right){
						right = x[i][j];
						r = i;
					}
				}
				if(x[i][j] == X){
					if(y[i][j] < Y && y[i][j] > up){
						up = y[i][j];
						u = i;
					}
					if(y[i][j] > Y && y[i][j] < down){
						down = y[i][j];
						d = i;
					}
				}
			}
			int focus[4] = {l,r,u,d};
			rep(i,4)rep2(j,i+1,4)if(focus[i] == focus[j]){
				ans += 2;
				del[focus[i]] = 1;
				flag = 1;
				//cout<<(char)(focus[i]+'A')<<endl;
			}
		}
		if(!flag)break;
	}
	cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define  endl '\n'
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a; ld b;
    cin>>a>>b;
    a*=b;
    cout<<a;


}

Measured memory_bytes: 3748
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    from itertools import product

    h, w, n = map(int, input().split())
    dic = {}
    for _ in range(n):
        a, b = map(int, input().split())
        a -= 2
        b -= 2
        for i in product([-1, 0, 1], repeat=2):
            aa = a + i[0]
            bb = b + i[1]
            if 0 <= aa <= h-3 and 0 <= bb <= w-3:
                try:
                    dic[(aa, bb)] += 1
                except:
                    dic[(aa, bb)] = 1

    ans = [0] * 10
    for i in dic.values():
        ans[i] += 1
    ans[0] = (h-2) * (w-2) - len(dic)

    for i in ans:
        print(i)

main()

Measured memory_bytes: 242796
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    Integer c = 0;
    for (Integer i=0;i < a.length();i++){
      char d = a.charAt(i);
      char e = b.charAt(i);
      if (d == e){
        c += 1;
      }
    }
    System.out.println(c);
  }
}

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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> ans;
    ans.clear();
    for(int i = 1; i <= min(a,b); i++){
        if(a % i == 0 && b % i == 0) ans.push_back(i);
    }
    cout << ans[ans.size() - k] << endl;
    return 0;
}


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

//public class Problem0016_TreasureHunt {
public class Main {
	private double x;
	private double y;
	private int angle;
	
	public static void main(String[] args) {
		try {
		//	Problem0016_TreasureHunt test = new Problem0016_TreasureHunt();
			Main test = new Main();
			
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String line;
			while((line = reader.readLine()) != null) {
				String[] textArray = line.split(",");
				int[] numbers = new int[2];
				for(int i = 0; i < 2; i++) {
					numbers[i] = Integer.parseInt(textArray[i]);
				}
				if(numbers[0] == 0 && numbers[1] == 0) {
					System.out.println((int)test.getX());
					System.out.println((int)test.getY());
				} else {
					test.move(numbers[0]);
					test.turn(numbers[1]);
				}
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	
	}
/*	Problem0016_TreasureHunt() {
		x = 0.0;
		y = 0.0;
		angle = 90;
	}
*/
	Main() {
		x = 0.0;
		y = 0.0;
		angle = 90;
	}

	void move(int length) {
		x += length * Math.cos(Math.toRadians(angle));
		y += length * Math.sin(Math.toRadians(angle));
		
	//	System.out.println("x:" + x + "\ty:" + y + "\tangle:" + angle);
	}
	void turn(int angle) {
		this.angle = (this.angle - angle) % 360;
	}
	double getX() {
		return x;
	}
	double getY() {
		return y;
	}

}

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

void mergeSets(vector<int>& a, int i, int j, int n) {
  if (abs(a[i]) < abs(a[j])) {
    a[j] += a[i];
    a[i] = j;
  }
  else {
    a[i] += a[j];
    a[j] = i;
  }
}

int findSet(vector<int>& a, int i, int n) {
  int j = i;
  while (a[i] > 0) {
    i = a[i];
  }
  while (a[j] > 0) {
    int t = a[j];
    a[j] = i;
    j = t;
  }
  return i;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1);
  for (int i = 0; i <= n; i++) {
    v[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    int f1 = findSet(v, a, n);
    int f2 = findSet(v, b, n);
    if (f1 != f2) {
      mergeSets(v, f1, f2, n);
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    // cout << v[i] << " " << i << endl;
    ans = min(ans, v[i]);
  }
  ans = abs(ans);
  cout << ans << endl;
}


Measured memory_bytes: 3992
n = int(input())
a = [int(i) for i in input().split()]
for i in range(1,n):
    print(' '.join(map(str,a)))
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
print(' '.join(map(str,a)))


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int t = 1;
  string s;
  cin >> s;
  v1i v = {0}, u = {0};
  rep(i, s.size()){
    if(i == s.size()-1) v.push_back(i+1);
    else if(s[i] == 'L' && s[i+1] == 'R') v.push_back(i+1);
    else if(s[i] == 'R' && s[i+1] == 'L') u.push_back(i);
  }
  rep(i, s.size()){
    int a = 0;
    if(i == u[t]){
      a += (v[t]-v[t-1])/2;
      if((v[t]-v[t-1])%2 == 1 && (u[t]-v[t-1])%2 == 0) ++a;
    }
    else if(i == u[t]+1){
      a += (v[t]-v[t-1])/2;
      if((v[t]-v[t-1])%2 == 1 && (u[t]-v[t-1])%2 == 1) ++a;
      if(t < u.size()-1) ++t;
    }
    cout << a;
    if(i == s.size()-1) cout << endl;
    else cout << " ";
  }
  return 0;
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(max(a,b),c)-min(min(a,b),c);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
char s[200003];
long long n,nr[200];
long long sol;
int main()
{
    cin.getline(s+1,200003);
    n=strlen(s+1);
    for(int i=1;i<=n;++i) ++nr[s[i]];
    for(int i='a';i<'z';++i)
    {
        for(int j=i+1;j<='z';++j) sol+=nr[i]*nr[j];
    }
    cout<<sol+1;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
  int A,B;
  vector<int> vec(3);
  int result;
  cin >> A;
  cin >> B;

  vec[0] = A+B;
  vec[1] = A-B;
  vec[2] = A*B;

  result = *std::max_element(vec.begin(), vec.end());
  cout << result << "\n";
  
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> a_1,c_1;
    int a,b,c,d;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        a_1.emplace_back(make_pair(a,b));
    }
    for(int i=0;i<m;i++){
        cin >> c >> d;
        c_1.emplace_back(make_pair(c,d));
    }
    int ans,check;
    for(int i=0;i<n;i++){
        ans=1e9;
        for(int j=0;j<m;j++){
            if(ans>abs(a_1[i].first-c_1[j].first)+abs(a_1[i].second-c_1[j].second)){
                ans=abs(a_1[i].first-c_1[j].first)+abs(a_1[i].second-c_1[j].second);
                check=j+1;
            }


        }
        cout << check << endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    LL N,M,X; cin >> N >> M >> X;
    VL C(N);
    vector<VL> A(N,VL(M));
    REP(i,N){
        cin >> C[i];
        REP(j,M){
            cin >> A[i][j];
        }
    }
    LL ans = LINF;
    for(LL mask = 0; mask < (1 << N); mask++){
        dump(mask)
        VL acc(M);
        LL tmp = 0;
        REP(i,N){
            if((mask >> i) & 1){
                REP(j,M){
                    acc[j] += A[i][j];
                }
                tmp += C[i];
            }
        }
        bool ok = true;
        REP(i,M){
            dump(acc[i])
            if(acc[i] < X) ok = false;

        }
        if(ok){
            chmin(ans,tmp);

        }
    }
    if(ans == LINF) cout << -1 << endl;
    else cout << ans << endl;

}

Measured memory_bytes: 3652
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;

#[fastout]
fn main() {
    input!{
        K: usize,
        S: Chars,
    }

    if S.len() <= K {
        println!("{}", S.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(""));
    } else {
        let forword = S.iter().map(|x| x.to_string()).take(K).collect::<Vec<String>>().join("");
        let ans = format!("{}...", forword);
        println!("{}", ans)
    }
}


Measured memory_bytes: 2188
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace AtcoderSubmit
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            Console.WriteLine(Console.ReadLine().Split(' ').Select((x, i) => (A: int.Parse(x), I: i + 1)).Count(x => x.I % 2 == 1 && x.A % 2 == 1));
        }
    }
}


Measured memory_bytes: 27800
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    double a, b;
    cin >> a >> b;
    if (a > b)
    {
        cout << "GREATER" << endl;
    }
    else if (a < b)
    {
        cout << "LESS" << endl;
    }
    else
    {
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256