akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const long long INF = 1e15;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int andd(int a,int b){
    int n = max(a,b);
    int t = 1;
    int p = 0;
    while(a>0 || b>0){
        if(a%2==1 || b%2==1) p+=t;
        t*=2;a/=2;b/=2;
    }
    return p;
}
int main(){
    int n,m;
    cin >> n >> m;
    pair<long long,int> a[m];
    int b,c;
    for(int i = 0;i<m;i++){
        cin >> a[i].first >> b;
        int tmp = 0;
        for(int j = 0;j<b;j++){
            cin >> c;
            tmp+=pow(2,c-1);
        }
        a[i].second = tmp;
        //cout << a[i].first << " " << a[i].second << endl;
    }
    //cout << endl;
    //for (int i = 0;i<m;i++) cout << a[i].first << " " << a[i].second << endl;;
    int t = pow(2,n);
    long long dp[t];
    fill_n(dp,t,INF);
    dp[0]=0;
    for(int i = 0;i<m;i++){
        for(int j = 0;j<t;j++){
            dp[andd(j,a[i].second)] = min(dp[andd(j,a[i].second)],dp[j]+a[i].first);
        }
    }
    if(dp[t-1]==INF) cout << -1 << endl;
    else cout << dp[t-1] << endl;
    /*int a,b;
    cin >> a >> b;
    cout << andd(a,b) << endl;*/
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fast_io ios :: sync_with_stdio(false); cin.tie(NULL)
using namespace std;


int main() {
	string s;
	string aux;
	cin >> s;
	aux = s;
	int count = 0;
	reverse(aux.begin(), aux.end());
	for (int i = 0; i<s.size(); i++) {
		if (s[i] != aux[i])count++;
	}
	cout << count/2 << "\n";

	
	return(0);
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

int main() {
  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  ll tmp = n%k, tmp_prev = tmp;
  for (;;) {
    tmp = abs(tmp - k);
    if (tmp > tmp_prev) {
      ans = tmp_prev;
      break;
    }
    tmp_prev = tmp;
    // cout << tmp << " " << tmp_prev<< endl;
  }
  // tmp = n;
  // rep(i,n){
  //   tmp = abs(tmp - k);
  //   cout << tmp << " " << tmp_prev<< endl;
  // }
  cout << ans << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int n, m;
  cin >> n >> m;
  map<ll, int> mp;
  int tmp;
  REP(i, n) { cin >> tmp; if(mp.count(tmp)) mp[tmp]++; else mp[tmp]=1; }
  REP(i, m){
    int b, c;
    cin >> b >> c;
    if(mp.count(c)) mp[c]+=b; else mp[c]=b;
  }
  ll res = 0;
  tmp = 0;
  auto it = prev(mp.end());

  while(tmp<n){
    if(it->second < n-tmp) { res += it->first * it->second; tmp+=it->second; it = prev(it); }
    else { res += it->first * (n-tmp); break; }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 12800
import fractions

a, b, c, d = map(int, input().split())

a = a - 1
lcm = (c * d) // fractions.gcd(c, d)

ansb = b // c + b // d - b // lcm
ansa = a // c + a // d - a // lcm

print(b - ansb - (a - ansa))

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

int main() {
    int k, x;
    cin >> k >> x;
    
    rep(i,k) {
     cout << x - k + i + 1 << ' ';
     }
    rep(i,k - 1) {
     cout << x + 1 + i << ' ';
     }

}
  

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = map(int,input().split())
#x = (A-T)/0.006
diff = float("inf")
ret = 0
for i,h in enumerate(H):
  if abs(T-h*0.006-A) < diff:
    diff = abs(T-h*0.006-A)
    ret = i
print(ret+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
const int INF = 1000000000;

char maze[50][51];
int sx,sy,gx,gy;
int H,W;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int d[50][51];

int bfs(){
    queue<P> que;
    rep(i,0,50) rep(j,0,51) d[i][j]=INF;
    d[sy][sx]=0;
    que.push(P(sy,sx));
    while(que.size()){
        P p=que.front(); que.pop();
        if(p.first==gy&&p.second==gx) break;
        rep(i,0,4){
            int ny=p.first+dy[i], nx=p.second+dx[i];
            if(0<=ny&&ny<H&&0<=nx&&nx<W&&d[ny][nx]==INF&&maze[ny][nx]=='.'){
                que.push(P(ny,nx));
                d[ny][nx]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gy][gx];
}

int main(){
    cin>>H>>W;
    int white=0;
    rep(i,0,H) rep(j,0,W){
        cin>>maze[i][j];
        if(maze[i][j]=='.') white++; 
    }
    sx=0,sy=0,gx=W-1,gy=H-1;
    int rec=bfs();
 
    if(rec==INF) cout<<-1<<endl;
    else cout<<white-rec-1<<endl;
    
  
}

Measured memory_bytes: 256
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
int n,m;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n>>m;
	cout<<n*1ll*m/gcd(n,m);
}





Measured memory_bytes: 256
N,A,B,C=map(int,input().split())
li=[A,B,C]
ans=""
Q=[]
for i in range(N):
  Q.append(input())
Q.append(Q[-1])
for i in range(N):
  S=Q[i]
  target=[0,1,2]
  ta1 = target[ord(S[0])-ord("A")]
  ta2 = target[ord(S[1])-ord("A")]
  
  if li[ta1] > li[ta2]:
    ans+=chr(ord("A")+ta2)
    li[ta1]-=1
    li[ta2]+=1
  elif li[ta1] < li[ta2]:
    ans+=chr(ord("A")+ta1)
    li[ta1]+=1
    li[ta2]-=1
  else:
    if li[ta1]+li[ta2]>=4:
      ans+=chr(ord("A")+ta2)
      li[ta1]-=1
      li[ta2]+=1
    elif li[ta1] == 0 and li[ta2] == 0:
      print("No")
      exit()
    else:
      if S[0] in Q[i+1] and S[1] in Q[i+1]:
        ans+=chr(ord("A")+ta2)
        li[ta1]-=1
        li[ta2]+=1
      else:
        if S[0] in Q[i+1]:
          ans+=chr(ord("A")+ta1)
          li[ta1]+=1
          li[ta2]-=1
        else:
          ans+=chr(ord("A")+ta2)
          li[ta1]-=1
          li[ta2]+=1
          
    

print("Yes")
for s in ans:
  print(s)
    
  


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();

        char[] c = new char[n];
        Arrays.fill(c, 'a');

        if (n == 1) {
            System.out.println("a");
            return;
        }

        solve(c, 1);
    }

    private static void solve(char[] c, int index) {

        if (index < c.length - 1) {

            while (true) {
                // 指定されたindexより先に文字が存在する場合、再帰的に呼び出す。
                solve(c, index + 1);
                //まだいける？
                if (moumuri(c, index)) {
                    break;
                }
                // 指定されているindexを1こ上げて、その先の文字を全部aにしちゃう。
                c[index]++;
                Arrays.fill(c, index + 1, c.length, 'a');
            }
        } else {

            while (true) {
                // 配列のお尻を指定されている場合、出力処理をする。
                System.out.println(String.valueOf(c));
                //まだいける？
                if (moumuri(c, index)) {
                    break;
                }
                // 指定されているindexを1こ上げる
                c[index]++;
            }
        }
    }

    private static boolean moumuri(char[] c, int index) {
        for (int i = 0; i < index; i++) {
            if (c[i] >= c[index]) {
                return false;
            }
        }
        return true;
    }
}


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

namespace AtCoderExamCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, answer;
            double tmp;

            a = int.Parse(Console.ReadLine());
            answer = a + a * a + a * a * a;

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27444
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int s,ans;
	const int max = 2000000;
	cin >> s;
	vll a(max,0);
	vll memo(max,0);

	rep(i, 1, max) {
		if (i == 1)a[i] = s;
		else {
			if (a[i-1] % 2 == 0)a[i] = a[i-1] / 2;
			else a[i] = 3 * a[i-1] + 1;
		}
		memo[a[i]]++;
		if (memo[a[i]] >= 2) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 31736
n, q = map(int, input().split())

tree = {i:[] for i in range(1, n + 1)}
for _ in range(1, n):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

cnt = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x

check = [0]*n

tmp = [1]
while len(tmp) != 0:
    tmp2 = tmp
    tmp = []
    for oya in tmp2:
        check[int(oya)-1] = 1
        for ko in tree[oya]:
            if check[ko-1] == 0:
                cnt[ko-1] += cnt[oya-1]
                tmp.append(ko)


print(" ".join(map(str, cnt)))

Measured memory_bytes: 83804
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val A, B, Q = sc.nextInt()
    val S = Array.fill(A)(sc.nextLong())
    val T = Array.fill(B)(sc.nextLong())
    val X = Array.fill(Q)(sc.nextLong()).zipWithIndex.sortBy(_._1)

    // 必ず, 一方向に進めばいいわけではない.
    // 行って戻ってくる方が近いケースもある.
    // 必ずsとtを一つ選ぶことになる.
    // xから見て, 選んだs,tが同じ方向にある場合には, xから遠い方の距離分移動すればいい
    // dist = max(|x - s|, |x - t|)
    // xから見て, 選んだs,tが異なる方向にある場合には, xから近い方の距離を往復して, 遠い方の距離分移動すればいいので
    // dist = 2 * min(|x - s|, |x - t|) + max(|x - s|, |x - t|)
    // なので, 実際, あるxについて候補があり
    // * xiから見て, 西側にペアがある場合
    //    xi から西にある si, ti の点について max(xi - si, xi - ti)
    // * xiから見て, 東側にペアがある場合
    //    xi から東にある si, ti の点について max(si - xi, ti - xi)
    // * xiから見て, 西にある si と 東にある ti を選択する場合
    //    2 * min(xi - si, ti - xi) + max(xi - si, ti - xi)
    // * xiから見て, 東にある si と 西にある ti を選択する場合
    //    2 * min(si - xi, xi - ti) + max(si - xi, xi - ti)
    // この4つの中で最初の値が最小の移動距離となる

    // つまり, xi から 1つ隣にある 寺院, 神社を高速に探す必要がある.
    // 全ての寺と, 全ての神社と, 全ての始点は全て異なる点に位置するので,
    // 開始点を小さい順にソートしておくと, 開始点の位置は, 寺院, 神社の間に属することになる
    // 開始点基準でインクリメントしていき, 10^5 回の繰り返しで十分にする

    val res = new Array[Long](Q)
    val Inf = Math.pow(10, 12).toLong

    var i = 0
    var sidx = 0
    var tidx = 0
    while (i < Q) {
      val (x, xidx) = X(i)

      while (sidx < A && S(sidx) < x) sidx += 1
      while (tidx < B && T(tidx) < x) tidx += 1

      val sldist = if (sidx - 1 >= 0) Math.abs(S(sidx - 1) - x) else Inf
      val srdist = if (sidx < A) Math.abs(S(sidx) - x) else Inf
      val tldist = if (tidx - 1 >= 0) Math.abs(T(tidx - 1) - x) else Inf
      val trdist = if (tidx < B) Math.abs(T(tidx) - x) else Inf

      res(xidx) =
        (sldist max tldist) min
          (srdist max trdist) min
            (2 * (sldist min trdist) + (sldist max trdist)) min
              (2 * (srdist min tldist) + (srdist max tldist))

      i += 1
    }

    println(res.mkString("\n"))
  }

}


Measured memory_bytes: 109200
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

H, W, D = LI()
data = H*W
cur = int(0)
A = [LI() for _ in range(H)]
ALocat = [None]*(data+1)
a = -1
for i in A:
    a +=1
    b = 0
    for j in i:
        ALocat[j] = [a, b]
        b +=1

#print(ALocat)
ALocat[0] = [0,0]
movecost = [0]*(data+1)
for i in range(D,data+1):
    movecost[i] = movecost[i-D] + abs(ALocat[i][0]-ALocat[i-D][0])\
                                + abs(ALocat[i][1]-ALocat[i-D][1])

#print(movecost)
ans = []
Q = I()
for _ in range(Q):
    L, R = LI()
    cur = movecost[R]-movecost[L]
    ans.append(cur)
for v in ans:
    print(v)

Measured memory_bytes: 63452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if (s == "a") {
    cout << "vowel" << endl;
  }
  else if (s == "i") {
    cout << "vowel" << endl;
  }
  else if  (s == "u") {
    cout << "vowel" << endl;
  }
  else if  (s == "e") {
    cout << "vowel" << endl;
  }
  else if  (s == "o") {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      string str;
      cin>>str;
      for(int i=0;i<n;i++)
	{
	  string tmp=str;
	  str="";
	  char s=tmp[0];
	  int cnt=1;
	  for(int j=1;j<tmp.size();j++)
	    {
	      //cout<<j<<" "<<s<<" "<<cnt<<endl;
	      if(tmp[j]!=s)
		{  
		  str+=toString(cnt);
		  str+=s;
		  s=tmp[j];
		  cnt=1;
		  
		}
	      else
		cnt++;
	      if(j==tmp.size()-1)
		{
		  str+=toString(cnt);
		  str+=s;	  
		}
	       
	    }
	  //	  cout<<"i="<<i<<" "+str<<endl;
	}
      cout<<str<<endl;
    }
}

Measured memory_bytes: 1360
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n):
    if a[i] < 0:
        a[i] = -a[i]
        s += 1
if s % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - 2 * min(a))


Measured memory_bytes: 14332
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=500;

int n;
int cost[MAXN][MAXN];

ll dp[MAXN][MAXN]; // dp[i][j]=minimum cost when last group is [i..j]

ll sumforwardcost[MAXN][MAXN];
ll sumbackwardcost[MAXN][MAXN];

ll solve() {
	REP(i,n) FOR(j,i,n) { sumforwardcost[i][j]=0; FOR(k,i,j) sumforwardcost[i][j]+=cost[k][j]; if(i<j) sumforwardcost[i][j]+=sumforwardcost[i][j-1]; }
	REP(i,n) FOR(j,i,n) { sumbackwardcost[i][j]=0; FOR(k,i,j) sumbackwardcost[i][j]+=cost[j][k]; if(i<j) sumbackwardcost[i][j]+=sumbackwardcost[i][j-1]; }

	REP(i,n) REP(j,n) dp[i][j]=LLONG_MAX;
	REP(j,n) dp[0][j]=sumforwardcost[0][j];
	REP(i,n) FOR(j,i,n) if(dp[i][j]!=LLONG_MAX) {
		FOR(k,j+1,n) dp[j+1][k]=min(dp[j+1][k],dp[i][j]+sumforwardcost[j+1][k]+sumbackwardcost[i][n-1]-sumbackwardcost[i][k]-sumbackwardcost[j+1][n-1]+sumbackwardcost[j+1][k]);
	}
	ll ret=LLONG_MAX; REP(i,n) ret=min(ret,dp[i][n-1]); return ret;
}

void run() {
	scanf("%d",&n);
	REP(i,n) REP(j,n) if(i==j) cost[i][j]=0; else scanf("%d",&cost[i][j]);
	printf("%lld\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 7040
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,a=0;
    double b=0;
    
    cin>>n;
    a=n/100;
    b=(double)n/(double)(111*a);
    //cout<<a<<" "<<b<<endl;
    
    if(b==1) cout<<n<<endl;
    else if(b>1) cout<<(a+1)*111<<endl;
    else if(b<1) cout<<a*111<<endl;
    
    return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split()))
a+=list(map(int,input().split()))
a+=list(map(int,input().split()))
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))

for i in range(9):
  if a[i] in b:
    a[i] = 'x'
  else:
    next
if a[0]is a[1]is a[2] is 'x' or a[3]is a[4]is a[5]is 'x' or a[6]is a[7]is a[8]is 'x' or a[0]is a[3]is a[6]is 'x' or a[1]is a[4]is a[7]is 'x' or a[2]is a[5]is a[8]is 'x' or a[0]is a[4]is a[8]is 'x' or a[2]is a[4]is a[6]is 'x':
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3188
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    int left = 0;
    int right = 0;
    int digit = A[0];

    int ret = 0;

    while (true) {
        if (right == N - 1 || (digit & A[right + 1])) {
            ret += (right - left) + 1;
            if (left == N - 1) break;

            digit &= ~(A[left]);
            left++;
            if (left > right) {
                digit |= A[right + 1];
                right++;
            }
        } else {
            digit |= A[right + 1];
            right++;
        }
    }

    cout << ret << endl;

    return 0;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  set<int> S;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int d;
    cin >> d;
    S.insert(d);
  }
  cout << S.size() << endl;
}

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

using namespace std;
typedef long long ll;
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

int main()
{
    ll N;
    cin >> N;
    ll a[N];
    for (int i = 0; i < N; i++)
        cin >> a[i];

    sort(a, a + SIZE(a));
    cout << a[N - 1] - a[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node{
    int key;
    Node *parent,*left,*right;
};
Node *root,*NIL;
void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key<x->key) x=x->left;
        else x=x->right;
    }
    z->parent=y;
    if(y==NIL) root=z;
    else{
        if(z->key<y->key) y->left=z;
        else y->right=z;
    }
}
void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(){
    int n,x;
    string com;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 26716
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 300005;
const int mod = 998244353;

int n, m, cna, cnb, cnc, cnd, fac[MAXN], inv[MAXN];
bool a[MAXN], b[MAXN], c[MAXN], d[MAXN];
char s[MAXN];

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

inline int Solve(int n, int m, bool *a, bool *b, bool *c, bool *d, int cna, int cnb, int cnc, int cnd)
{
	int leu = 0, led = 0, riu = cna, rid = cnb, cur = 0, ret = 0;
	for (int i = 1; i <= n; i ++)
		if (a[i] || b[i])
		{
			(cur += (cnc ? C(leu + led + cnc - 1, cnc - 1) : (leu + led == 0))) %= mod;
			if (a[i] && b[i])
				cur = (cur << 1) % mod;
			if (a[i])
				leu ++, riu --;
			if (b[i])
				led ++, rid --;
			ret = (1LL * cur * (cnd ? C(riu + rid + cnd - 1, cnd - 1) : (riu + rid == 0)) + ret) % mod;
		}
	return ret;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read(), fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i < MAXN; i ++)
		fac[i] = 1LL * fac[i - 1] * i % mod, inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i < MAXN; i ++)
		inv[i] = 1LL * inv[i - 1] * inv[i] % mod;
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i ++)
		a[i] = s[i] == '1', cna += a[i];
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i ++)
		b[i] = s[i] == '1', cnb += b[i];
	scanf("%s", s + 1);
	for (int i = 1; i <= m; i ++)
		c[i] = s[i] == '1', cnc += c[i];
	scanf("%s", s + 1);
	for (int i = 1; i <= m; i ++)
		d[i] = s[i] == '1', cnd += d[i];
	if (!cna && !cnb && !cnc && !cnd)
		return puts("1"), 0;
	return printf("%d\n", (Solve(n, m, a, b, c, d, cna, cnb, cnc, cnd) + Solve(m, n, c, d, a, b, cnc, cnd, cna, cnb)) % mod), 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    int l=0,r=n;
    for(int i=0;i<m;i++){
        int lc,rc;
        cin>>lc>>rc;
        if(lc>l)
            l=lc;
        if(rc<r)
            r=rc;
    }
    if(l<=r)
        cout<<r-l+1;
    else
        cout<<0;
    
}

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

using namespace std;
const int N = 1e6 + 77 , Mod = 1e9 + 7;
long long X,Y;
int main(){
	cin >> X >> Y;
	if(abs(X - Y) <= 1)return cout << "Brown",0;
	cout << "Alice";
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

string n;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int ans = 0;
    for(char i : n) ans += i - '0';
    cout << ((ans % 9) ? "No\n" : "Yes\n");
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, K;
    cin >> A >> B >> K;
    if (A <= K) {
        K -= A;
        A = 0;
        if (B <= K) {
            B = 0;
        } else {
            B -= K;
        }
    } else {
        A -= K;
    }
    cout << A << " " << B << '\n';

}

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


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int sum;
    char str[1000];
    while(true){
        sum = 0;
        scanf("%s", str);
        if (str[0] == '0'){
            break;
        }
        for (int i = 0; str[i] != '\0'; i++){
            sum += (int)(str[i] - '0');
        }
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 2732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> h(N);

    rep(i,N)cin>>h[i];
    ll flag = 0;
    ll ans = 0;
    ll fin = 0;
    while(1){
        fin = 0;
        flag =  0;
        rep(i,N){
            if(h[i]!=0 && flag==0){
                ans++;
                flag = 1;
            }
            if(h[i]!=0){
                h[i]--;
                fin = 1;
            }else{
                flag = 0;
                
            }

        }
        if(fin ==0){
            cout<<ans<<endl;
            return 0;
        }
    }
  


    return 0;
    

}

Measured memory_bytes: 3640
var
   n: integer;
   a: integer;
   b: integer;
   h: array of integer;
   i: integer;
   l: integer;
   r: integer;
   m: integer;
   diff: int64;
   cnt: int64;
begin
   readln(n, a, b);
   setlength(h, n);
   for i := 0 to n - 1 do begin
      readln(h[i]);
   end;
   l := 0;
   r := 1000000000;
   while r - l > 1 do begin
      cnt := 0;
      m := (r + l) div 2;
      for i := 0 to n - 1 do begin
         diff := h[i] - b * m;
         if diff > 0 then begin
            cnt := cnt + (diff div (a - b));
            if diff mod (a - b) <> 0 then begin
               inc(cnt);
            end;
         end;
      end;
      if cnt > m then begin
         l := m;
      end
      else begin
         r := m;
      end;
   end;
   writeln(r);
end.

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

struct Mystruct{
    long long atack;
    long long mp;
    double cost;

    Mystruct(long long input_a, long long input_b){
        atack = input_a;
        mp = input_b;
        cost = input_a*1.0 / input_b;
    }
    bool operator<(const Mystruct &another) const
    {
        if(cost == another.cost){
            return mp < another.mp;
        }
        return cost < another.cost;//年齢を比較
    };
};

int main()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  long long ans = 1000000000;
  for (int i = 0; i <= max(x, y) * 2; i += 2) {
    long long tmp = max(0,(x - i / 2)) * a + max(0,(y - i / 2)) * b + i * c;
    ans = min(ans, tmp);
  }
  ANS(ans);
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ITP1_4-C
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

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

    int a,b;
    string op;
    
    while (true) {
        
    cin >> a >> op >> b;
    
        int result;
        
    if (op == "+"){
        
        result = a + b;
    }else if (op == "-"){
        result = a - b;
    }else if (op == "*"){
        result = a * b;
    }else if (op == "/"){
        result = a / b;
    }else{
        break;
    }
        
        printf("%d\n", result);
    }
    
    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sa,sb;
	cin>>sa>>sb;
	a=0;
	for(i=0;i<sa.size();i++){
		if(sa[i]!=sb[i])a++;
	}
	cout<<a<<endl;
}

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

int main() {
	int a[100], n;
	cin >> n;
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for (int i = n-1; i >= 0; i--){
		cout << a[i];
	    if (i != 0){
		   cout << " ";
	} else {
		cout  << endl;
	  }
	}	
	return 0;
}


Measured memory_bytes: 3096
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter {
            s: String::new(),
        }
    }

    fn print<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

fn main() {
    let mut printer = ContestPrinter::new();
    let n = readl!(usize);
    let mut dif = vec![0; n];
    for _ in 0..n-1 {
        let (a, b, c) = readl!(usize, usize, usize);
        dif[a] ^= c;
        dif[b] ^= c;
    }

    let mut imask = 0;
    let mut iv = 0;
    for i in 0..n {
        if dif[i] != 0 {
            if (imask>>dif[i])&1 == 1 {
                iv += 1;
            }
            imask ^= 1<<(dif[i]);
        }
    }
    let imask = imask;
    let iv = iv;
    let dma = dif.iter().map(|&x| x).max().unwrap()+1;
    
    let inf = 1_000_000_000;
    let mut dp = vec![inf; 1<<dma];
    // dp[imask] = iv;
    dp[0] = 0;
    for mask in 1..1<<dma {
        let mut pmask = 0;
        while pmask != mask {
            let sx = (0..dma).fold(0, 
                |sum, x| if (pmask>>x)&1 == 1 {sum^x} else {sum});
            if sx == 0 {
                dp[mask] = std::cmp::min(dp[mask], dp[pmask]+(pmask^mask).count_ones()-1);
            }
            pmask = ((pmask as i64-mask as i64) & mask as i64) as usize;
        }
    }

    printer.println(dp[imask]+iv);
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

// Description: ??°??????????????????(?????????????°??????¨???)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
}

// Description: ????????°????????????????????? 
// TimeComplexity: $ \mathcal{O}(V + E) $
// Verifyed: AOJ GRL_3_B

auto bridge(const G& graph){
    int n=graph.size(),k=0;
    vector<int> par(n),ord(n,-1),low(n),root(n,0);

    auto dfs=[&](int v,int p,int &k){
        auto func=[&](int v,int p,int &k,auto func)->void{
            ord[v]=k++,low[v]=ord[v],par[v]=p;
            for(auto &e:graph[v]){
                if(e.to==p) continue;
                if(ord[e.to]==-1)
                    func(e.to,v,k,func),chmin(low[v],low[e.to]);
                else
                    chmin(low[v],ord[e.to]);
            }
        };
        return func(v,p,k,func);
    };

    rep(v,n) if(ord[v]==-1) dfs(v,-1,k),root[v]=1;

    using state=tuple<int,int>;
    vector<state> res;
    rep(v,n){
        if(par[v]==-1) continue;
        if(ord[v]<low[par[v]]||ord[par[v]]<low[v]){
            auto in=state(v,par[v]);
            if(get<1>(in)<=get<0>(in)) swap(get<0>(in),get<1>(in));
            res.push_back(in);
        }
    }
    sort(_all(res));
    return res;      
}

int main(void){
	int v,e;
	cin >> v >> e;
	G graph(v);
	rep(i,e){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a,b);
		add_edge(graph,b,a);
	}

	auto res=bridge(graph);
	
    for(auto &it:res){
        int a,b;
        tie(a,b)=it;
        cout << a << " " << b << endl;
    } 
	return 0;
}

Measured memory_bytes: 4500
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val (t, a) = readLine()!!.split(" ").map { it.toInt() }

    val h = readLine()!!.split(" ").mapIndexed { index, s -> index to s.toInt() }

    val ans = h.minBy { Math.abs(a - (t-it.second*0.006)) }!!

    println(ans.first+1)
}


Measured memory_bytes: 37672
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<string>
#include<math.h>
#include <vector>
#include <array>
using namespace std;

enum command {
	com_add = 0,		//add(i, x) : a_i???x??????????????????
	com_getSum = 1		//getSum(s, t) : as, as + 1, ???, at???????¨??????????????????????
	
};
const int INIT = 0;
int main(){
	std::istream & c_in = cin;
	int n, q;
	c_in >> n >> q;
	array<int, 100000> A;
	A.fill(INIT);

	for (int j = 0; j < q; ++j)
	{
		int com, x, y;
		c_in >> com >> x >> y;
		if (com == com_add)
		{
			A[x] += y;
		}
		else if (com == com_getSum)
		{
			//
			long m = 0;
			for (int i = x; i <= y; ++i)
			{
				m += A[i];
			}
			cout << m << endl;
		}
	}
}

Measured memory_bytes: 3496
from statistics import mean, median,variance,stdev
import sys
import math

n=input().split()
a = []
for i in range(len(n)):
    a.append(int(n[i]))
if (a[0]+a[1])%2 :
    print(int((a[0]+a[1]+1)/2))
else: print(int((a[0]+a[1])/2))

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ans=0;
    for(int i = 0; i < k; i++) {
        ans+=p[i];
    }
    cout << ans << "\n";

    return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n;
	cin >> n;

	int a[n];
	map<int, int> mi;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		mi[a[i]]++;
	}

	int ans = 0;
	for (auto e : mi)
	{
		ans += e.ss * (e.ss - 1) / 2;
	}

	for (int i = 0; i < n; ++i)
	{
		int k = mi[a[i]];
		int ans1 = 0;
		ans1 = ans - k * (k - 1) / 2 + (k - 1) * (k - 2) / 2;

		cout << ans1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 11264
import java.util.ArrayDeque
import java.math.*

fun main(args: Array<String>) {
    val (H, W) = readInputLine().split(" ").map { it.toInt() }
    val ban = Array(H) { readInputLine().toCharArray() }
    
    val cost = Array(H) { IntArray(W) { Int.MAX_VALUE } }
    cost[0][0] = 1
    
    val queue = ArrayDeque<Pair<Int, Int>>()
    queue.add(Pair(0, 0))

    while (!queue.isEmpty()) {
        val (y, x) = queue.poll()!!
        
        for (i in y - 1..y + 1) {
            if (i < 0 || i >= H) {
                continue
            }
            for (j in x - 1..x + 1) {
                if (j < 0 || j >= W) {
                    continue
                }
                if (Math.abs(i - y) + Math.abs(j - x) != 1) {
                    continue
                }
                if (ban[i][j] == '#') {
                    continue
                }
                
                if (cost[i][j] > cost[y][x] + 1) {
                    cost[i][j] = cost[y][x] + 1
                    queue.add(Pair(i, j))
                }
            }
        }
    }
    
    if (cost[H - 1][W - 1] == Int.MAX_VALUE) {
        println(-1)
        return
    }

    println(ban.sumBy { it.count { it == '.' } } - cost[H - 1][W - 1])
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37916
using System;
using System.Linq;

namespace Array
{
    class Finding_Missing_Cards
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var cards = new Card[n];
            for (int i = 0; i < n; i++)
            {
                var array = Console.ReadLine().Split(' ');
                cards[i] = new Card(array[0], int.Parse(array[1]));
            }

            cards = cards.OrderBy(c => c.suitKey).ThenBy(c => c.rank).ToArray();

            int j = 0;
            for (int i = 0; i < 52; i++)
            {
                string s = "";
                switch (i / 13)
                {
                    case 0:
                        s = "S"; break;
                    case 1:
                        s = "H"; break;
                    case 2:
                        s = "C"; break;
                    case 3:
                        s = "D"; break;
                }
                if (s == cards[j].suit && (i % 13) + 1 == cards[j].rank)
                {
                    if (++j == n) j--;
                    continue;
                }
                Console.WriteLine(s + " " + ((i % 13) + 1));
            }
        }

        struct Card
        {
            public string suit;
            public int suitKey;
            public int rank;
            public Card(string suit, int rank)
            {
                this.suit = suit;
                this.rank = rank;
                switch (suit)
                {
                    case "S": suitKey = 0; break;
                    case "H": suitKey = 1; break;
                    case "C": suitKey = 2; break;
                    case "D": suitKey = 3; break;
                    default: suitKey = -1; break;
                }
            }
        }
    }
}

Measured memory_bytes: 10144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		string s;
      cin>>s;
      for(int i=0;i<3;i++){
      if(s[i]=='7'){
      cout<<"Yes";
        return 0;
      }
      }
      cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3640