akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        ArrayList<ArrayList<Integer>> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int l = ni();
            int r = ni();
            ArrayList<Integer> val = new ArrayList<>();
            val.add(l);
            val.add(r);
            list.add(val);
        }
        Collections.sort(list, (x,y)->(y.get(0)+y.get(1)) - (x.get(0)+x.get(1)));
        long tak = 0;
        long aok = 0;
        for (int i = 0; i < N; i++) {
            if(i%2==0){
                tak += list.get(i).get(0);
            }else{
                aok += list.get(i).get(1);
            }
        }
 
        long ans = tak-aok;
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 68576
import sys
import math
import heapq
from collections import deque
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

FIFO=deque()
N,M=LI()
MP=[[[],[],[]] for i in range(N+1)]

# グラフ作成
for _ in range(M):
    i,j=LI()
    MP[i][0].append((j,1))
    MP[i][1].append((j,2))
    MP[i][2].append((j,0))

S,T=LI()
FIFO.append((S,0,0))
visited = [[False,False,False] for i in range(N+1)]
visited[S][0] = True

res = -1
while FIFO:
    i, rest_i, dist = FIFO.popleft()
    if i == T and rest_i == 0:
        res = dist // 3
        break
    for j, rest_j in MP[i][rest_i]:
        if not visited[j][rest_j]:
            visited[j][rest_j] = True
            FIFO.append((j, rest_j, dist+1))

print(res)


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

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

using namespace std;
vector<int> adj[100];
int res[105][105] = {0};

int main() {
    int n; cin >> n;
    REP(i, n){
        int u, k;
        cin >> u >> k;
        REP(j, k) {
            int tmp;
            cin >> tmp;
            res[u][tmp] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < n ; j++)
            cout << res[i][j] << " ";
        cout << res[i][n] << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
/*
 © 2020-07-11 06:54:04 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
const int N = 1e4 + 5;
lli res[N];
int main(){ _
  lli n; cin >> n;
  for(lli i = 1; i < N; i++){
    for(lli j = 1; j < N; j++){
      for(lli k = 1; k < N; k++){
        if(i * i + j * j + k * k + i * j + j * k + k * i < N){
          res[i * i + j * j + k * k + i * j + j * k + k * i]++;
        }else break;
      }
    }
  }
  fore(i, 1, n + 1) {
    cout << res[i] << ENDL;
  }
  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  lint Asum = 0;
  REP(i, N) Asum += A[i];
  if(Asum % (N*(N+1)/2) != 0) {
    cout << "NO" << endl;
    return 0;
  }
  lint cnt = Asum / (N*(N+1)/2);
  REP(i, N) {
    lint diff = A[i] - A[(i+1)%N] + cnt;
    if(diff < 0 || diff%N != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    
    return 0;
}

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

int N, K;
vector<int> u, v;

int main()
{
    int d;
    cin >> d;
    cout << "Christmas";
    for (int i = d; i < 25; i++)
    {
        cout << " Eve";
    }
    cout << endl;
}

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

int p[100003];
int par[100003];

int root(int i) {
    if (par[i] == i)
        return i;
    return par[i] = root(par[i]);
}

void unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx != ry)
        par[rx] = ry;
}

int main() {
    int N, K;
    cin >> N >> K;
    rep2(i, N) {
        cin >> p[i];
        par[i] = i;
    }
    rep(i, K) {
        int a, b;
        cin >> a >> b;
        unite(p[a], p[b]);
    }
    int ans = 0;
    rep2(i, N) {
        if (root(i) == root(p[i]))
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	string s[3];
	rep(i,3)cin>>s[i];
	rep(i,3)cout<<(char)(s[i][0]-32);
	cout<<endl;
	return 0;
}

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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

    ll all = abs(a[0]);
    ll skip[n];
    skip[0] = abs(0 - a[1]);
    for(int i = 1; i < n; i++){
        all += abs(a[i-1] - a[i]);
        if(i < n-1){
            skip[i] = abs(a[i-1] - a[i+1]);
        }
    }
    all += abs(a[n-1]);
    skip[n-1] = abs(a[n-2]);

    cout << all - (abs(a[0]) + abs(a[0] - a[1])) + skip[0] << endl;
    for(int i = 1; i < n - 1; i++){
        ll ans = all - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1])) + skip[i];
        cout << ans << endl;
    }
    cout << all - (abs(a[n-1]) + abs(a[n-2] - a[n-1])) + skip[n-1] << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int n, m;
    cin >> n >> m;
    int data[110000][2];
    rep(i, m) cin >> data[i][0] >> data[i][1];
    if(m < 2) {
        cout << data[0][1] - data[0][0] + 1 << endl;
        return 0;
    }
    int low = max(data[0][0], data[1][0]);
    int high = min(data[0][1], data[1][1]);
    for (int i = 2; i < m; i++) {
        low = max(low, data[i][0]);
        high = min(high, data[i][1]);
    }
    int ans = high - low + 1;
    if (ans >= 0) cout << ans;
    else cout << 0 << endl;
}

Measured memory_bytes: 1024
fun bubbleSort(cards: List<String>, n: Int) : List<String> {
  var c = cards.toMutableList()
  for (i in (0 until n)) {
    for (j in (n-1 downTo i+1)) {
      val x = Integer.valueOf(c[j][1].toString())
      val y = Integer.valueOf(c[j-1][1].toString())
      if (x < y) {
        val tmp = c[j]
        c[j] = c[j-1]
        c[j-1] = tmp
      }
    }
  }
  return c
}

fun selectionSort(cards: List<String>, n: Int) : List<String> {
  var c = cards.toMutableList()
  (0 until n).forEach { i ->
    var minX = i
    (i until n).forEach { j ->
      val a = Integer.valueOf(c[j][1].toString())
      val b = Integer.valueOf(c[minX][1].toString())
      if (a < b) {
        minX = j
      }
    }
    val a = Integer.valueOf(c[i][1].toString())
    val b = Integer.valueOf(c[minX][1].toString())
    if (a != b) {
      val tmp = c[i]
      c[i] = c[minX]
      c[minX] = tmp
    }
  }
  return c
}

fun isStable(inArr: List<String>, outArr: List<String>, n: Int): Boolean {
  for (i in (0 until n)) {
    for (j in (i+1 until n)) {
      for (a in (0 until n)) {
        for (b in (a+1 until n)) {
          if (inArr[i][1] == inArr[j][1] && inArr[i] == outArr[b] && inArr[j] == outArr[a]) {
            return false
          }
        }
      }
    }
  }
  return true
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val cards = readLine()!!.split(" ")

  val bubbleSortedCards = bubbleSort(cards, n)
  val selectionSortedCards = selectionSort(cards, n)
  println(bubbleSortedCards.joinToString(" "))
  println(if (isStable(cards, bubbleSortedCards, n)) "Stable" else "Not stable")
  println(selectionSortedCards.joinToString(" "))
  println(if (isStable(cards, selectionSortedCards, n)) "Stable" else "Not stable")
}


Measured memory_bytes: 33120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

int main()
{
	int N, R; // 参加回数、表示レーティング
	cin >> N >> R;

	int answer; // 内部レーティング

	if (N > 9) 
	{
		answer = R; // 等しい
	}
	else 
	{
		answer = R + 100 * (10 - N); // R == answer - 100 * (10 - N) <=> answer = R + 100 * (10 - N) 
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
import math
a, b, n = map(int, input().split())
for i in range(a-1, -1, -1):
    if math.floor(b * i / a) + 1 < (i + 1) * b / a:
        if math.floor(b * i / a) + 1<=n:
            print(i)
            exit()
print(0)

Measured memory_bytes: 9044
#include <set>
#include <cstdio>
int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(auto s=t.begin(),S=s;s!=t.end();S=++s)for(;++S!=t.end();v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=1;i<=n/2;i++)printf("%d\n",v[i]);}}

Measured memory_bytes: 1300
n = int(input())
a = []
for i in range(n-1):
    a.append(list(map(int, input().split())))
import math
for i in range(n-1):
    ans = 0
    for j in range(i,n-1):
        x1 = math.ceil((ans-a[j][1])/ a[j][2])
        if x1 < 0:
            x1 = 0
        x2 = a[j][2]*x1 + a[j][1]
        ans = x2 + a[j][0]
    print(ans)
print(0)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  ll ans = 0;
  int absmin = 1e9 + 7, under_zero = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    ans += abs(a);
    chmin(absmin, abs(a));
    if (a < 0)
      under_zero++;
  }

  if (under_zero & 1)
    cout << ans - (absmin * 2) << endl;
  else
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int a, b, c;
   cin >> a >> b >> c;
   swap(a, b);
   swap(a, c);
   printf("%d %d %d\n", a, b, c);
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int f[100];
int main(int argc, char const *argv[]){
	char s[101];
	int n,i=0,j,p=0,e=0;
	scanf("%d",&n);
	scanf("%s",s);
	while(i<n){
		if(f[i]==0 && s[i]=='('){
			j=i+1;
			while(j<n && f[j]==1){
				j++;
			}
			if(j<n && s[j]==')'){
				f[i]=1;
				f[j]=1;
				i=-1;
			}else i=j-1;
		}
		i++;
		while(i<n && f[i]==1){
			i++;
		}
	}
	for(i=0;i<n;i++){
		if(f[i]==0){
			if(s[i]==')') p++;
			else e++;
		}
	}
	for(i=0;i<p;i++) printf("(");
	printf("%s",s);
	for(i=0;i<e;i++) printf(")");
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())

ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

res = 0
for i in range(1<<n):
    on = [0 for _ in range(n)]
    
    for j in range(n):
        if(i & (1<<j)): on[j] = 1
    
    all_on = True
    for j in range(m):
        
        on_num = 0
        for s in ks[j][1: ]:
            if(on[s-1]): on_num += 1

        if(on_num%2 != p[j]):
            all_on = False
            break

    if(all_on): res += 1

print(res)

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s, t; cin >> s >> t;

	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])ans++;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;

int main(){
  int n, m;
  cin >> n >> m;
  vector<P> key;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    int state = 0;
    rep(j,b){
      int c;
      cin >> c;
      c--;
      state |= (1<<c);
    }
    key.push_back({a,state});
  }
  vector<int> dp(1<<n,INF);
  dp[0] = 0;
  rep(i,m){
    rep(now,1<<n){
      dp[now | key[i].second] = min(dp[now | key[i].second], dp[now] + key[i].first);
    }
  }
  if (dp[(1<<n)-1] == INF) cout << -1 << endl;
  else cout << dp[(1<<n)-1] << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,k,num;
    cin>>n>>k;
    vector<int> d(k),ans(n);
    rep(i,n) ans[i]=0;
    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            cin>>num;
            ans[num-1]++;
        }
    }
    int cnt=0;
    rep(i,n) if(ans[i]==0) cnt++;
    cout<<cnt;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,m,x,y,sg1[111111],sg2[111111],sg3[111111],pos,ans;
long long a[111111],b[111111],c[111111];
vector<int> g1[111111],g2[111111],g3[111111];
bool used[111111];
int binpow(int a,int t)
{
	int res=1,p=a;
	for (int i=t;i;i>>=1)
	{
		if (i&1) res=1ll*res*p%mod;
		p=1ll*p*p%mod;
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	scanf("%d",&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		if (x>y) swap(x,y);
		g1[x].push_back(y);
	}
	for (int i=n;i>=1;i--)
	{
		for (int j=0;j<g1[i].size();j++)
		{
			used[sg1[g1[i][j]]]=1;
		}
		pos=0;
		while(used[pos]) pos++;
		sg1[i]=pos;a[pos]=(a[pos]+binpow(10,18*i))%mod;
		for (int j=0;j<g1[i].size();j++)
		{
			used[sg1[g1[i][j]]]=0;
		}
	}
	scanf("%d",&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		if (x>y) swap(x,y);
		g2[x].push_back(y);
	}
	for (int i=n;i>=1;i--)
	{
		for (int j=0;j<g2[i].size();j++)
		{
			used[sg2[g2[i][j]]]=1;
		}
		pos=0;
		while(used[pos]) pos++;
		sg2[i]=pos;b[pos]=(b[pos]+binpow(10,18*i))%mod;
		for (int j=0;j<g2[i].size();j++)
		{
			used[sg2[g2[i][j]]]=0;
		}
	}
	scanf("%d",&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		if (x>y) swap(x,y);
		g3[x].push_back(y);
	}
	for (int i=n;i>=1;i--)
	{
		for (int j=0;j<g3[i].size();j++)
		{
			used[sg3[g3[i][j]]]=1;
		}
		pos=0;
		while(used[pos]) pos++;
		sg3[i]=pos;c[pos]=(c[pos]+binpow(10,18*i))%mod;
		for (int j=0;j<g3[i].size();j++)
		{
			used[sg3[g3[i][j]]]=0;
		}
	}
	for (int i=0;i<=n;i++)
	{
		if (!a[i]) continue;
		for (int j=0;j<=n;j++)
		{
			if (!b[j] || !c[i^j]) continue;
			ans=(1ll*a[i]*b[j]%mod*c[i^j]+ans)%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16896
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> av(n), bv(n), cv(n);
  for (int i = 0 ; i < n; i++) {
    cin >> av.at(i);
  }
  for (int i = 0 ; i < n; i++) {
    cin >> bv.at(i);
  }
  for (int i = 0 ; i < n; i++) {
    cin >> cv.at(i);
  }

  sort(av.begin(), av.end());
  sort(bv.begin(), bv.end());
  sort(cv.begin(), cv.end());

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll a = lower_bound(av.begin(), av.end(), bv.at(i)) - av.begin();
    ll c = cv.end() - upper_bound(cv.begin(), cv.end(), bv.at(i));
    ans += a * c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if(A >= -100 && B >= -100 && C >= -100 && A <= 100 && B <= 100 && C <= 100){
    if(C >= A && C <= B){
      printf("Yes\n");
    }
    else{

    printf("No\n");
    }
    }

    return 0;
}


Measured memory_bytes: 384
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std; 
int main (){
    int k ,n;
    cin >> n >> k;
    char s[n];
    cin >> s;
    s[k-1] +=32;
    cout <<s<<endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;
    if (a > 12) cout << b << endl;
    else if (a > 5)cout << b/2 << endl;
    else cout << 0 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
 	string s;
  cin>>s;
  int zeros=0,ones=0;
  for(int i=0; i<s.size(); i++)
  {
   if(s[i]=='1')
   {
     ones++;
  }
    else
    {
     zeros++; 
    }
  }
    int pomal=min(zeros,ones);
    cout<<pomal*2<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int s;
	cin >> s;
	
	bool ok = false;
	int i = 1;
	int ans = 0;
	map<int, int> mp;
	mp[s]++;
	
	while( !ok ) {
		if( s % 2 == 0 )  s /= 2;
		else s = 3 * s + 1;
		
		mp[s]++;
		
		if( mp[s] > 1 ) {
			ans = i + 1;
			ok = true;
		}
		
		i++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int a = sc.nextInt();
            if (i % 2 == 0) continue;
            if (a % 2 == 1) count++;
        }

        System.out.println(count);
        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

int A[200000];
set<int> S;

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> A[i];

    int cnt = 0;
    int goodlen = 0;
    int ans = n - k + 1;
    for (int i = 0; i < n; i++) {
        if (i == 0 || A[i - 1] < A[i])
            goodlen++;
        else
            goodlen = 1;
        if (goodlen == k)
            cnt++;
        if (i >= k) {
            if (A[i] > *(S.rbegin()) && A[i - k] == *(S.begin()))
                ans--;
            S.erase(A[i - k]);
        }
        S.insert(A[i]);
    }
    if (cnt >= 2)
        ans -= cnt - 1;
    cout << ans << "\n";
}


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

using namespace std;

typedef long long ll;

const ll mod = 1e9+7;

ll take_mod(ll a) {
    return (a % mod + mod) % mod;
}

inline ll q_pow(ll a, ll b) {
    return b ? q_pow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1;
}

ll mod_inv(ll x) {
    return q_pow(x, mod - 2);
}

// k << n のときの話
ll comb(ll n, ll k) {
    ll fact_k = 1, nPk = 1;
    for (int i = 1; i <= k; ++i) {
        fact_k = fact_k*i%mod;
        nPk = nPk*(n-i+1)%mod;
    }
    return nPk * mod_inv(fact_k) % mod;
}

int main() {
    ll n, a, b, ans;
    cin >> n >> a >> b;

    ans = q_pow(2, n);
    ans--;
    ans -= comb(n, a);
    ans -= comb(n, b);
    ans = take_mod(ans);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect

n = int(input())
x = list(map(int, input().split()))
l = int(input())
q = int(input())

#r[i][j]: jから(2**i)日で行ける右端
r = [[i for i in range(n)] for _ in range(18)]
for j in range(n):
	r[0][j] = bisect(x, x[j]+l) - 1
for i in range(1, 18):
	for j in range(n):
		r[i][j] = r[i-1][r[i-1][j]]

def search(x, y):
	res = 0
	cur = x
	while True:
		for i in range(18):
			if r[i][cur] >= y:
				if i == 0:
					return res+1
				cur = r[i-1][cur]
				res += 1 << (i-1) 
				break

for _ in range(q):
	a, b = map(int, input().split())
	print(search(min(a, b)-1, max(a, b)-1))

Measured memory_bytes: 79060
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin>>N;
  if(N==3){
    cout<<2<<endl;
    cout<<5<<endl;
    cout<<63<<endl;
    return 0;
  }
  // cout<< N - 15000 << endl;
  int aho = max(0, N - 15000);
  if(N&1) aho++;
  int cnt3 = max(2, aho);
  int cnt2 = N - cnt3;
 //  cout<<aho<<' '<<cnt3<<' '<<cnt2<<endl;
  int tmp3=3;
  int tmp2=2;
  for(int i=0;i<cnt3;i++){
    cout<<tmp3<<endl;
    tmp3+=6;
  }
  int sum=0;
  for(int i=0;i<cnt2;i++){
    if(i==cnt2-1){
      if( (tmp2+sum)%3 == 1){
        tmp2+=2;
      }else if( (tmp2+sum)%3 == 2){
        tmp2+=4;
      }
    }
    cout<<tmp2<<endl;
    sum += tmp2;
    tmp2+=2;
  }
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  if (A > B) swap(A, B);

  if (A + D * (N - 1) < B) {
    cout << "NO" << endl;
    return 0;
  }

  bool ok = false;
  for (int i = 1; i <= N - 2; i++) {
    if (B - (N - 1 - i) * C < A - i * D) continue;
    if (B - (N - 1 - i) * D > A - i * C) continue;

    ok = true;
    break;
  }

  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0; 
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  string s,t;
  cin>>n>>s>>t;
  int a = s.size();
  int b = s.size();
  int c = min(a,b);
  FORR(l,1,c+1){
    if(s.substr(a-l) == t.substr(0,l)){
      printf("%d\n",a+b-l);
      return 0;
    }
  }
  printf("%d\n",a+b);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int day;
  int cost[30];
  int satisfied[370][30];
  
  scanf("%d",&day);
  
  for(int i=0;i<26;i++){
    cin>>cost[i];
  }
  
  for(int i=0;i<day;i++){
    for(int j=0;j<26;j++){
      cin>>satisfied[i][j];
    }
  }
  
  for(int i=0;i<day;i++){
    printf("%d\n",i%26+1);
  }
  return(0);
}

Measured memory_bytes: 3868
<?php
$str = trim(fgets(STDIN));
$q = trim(fgets(STDIN));
for($i = 0; $i < $q; $i++){
    $l = explode(" ",trim(fgets(STDIN)));
    $order = $l[0];
    $a = $l[1];
    $b = $l[2];
    $len = $l[2] -$l[1] + 1;
    if($order == "print"){
        echo substr($str,$a,$len)."\n";
    }elseif($order == "reverse"){
        $re = strrev(substr($str,$a,$len));
        $str = substr_replace($str,$re,$a,$len);
    }elseif($order == "replace"){
        $str = substr_replace($str,$l[3],$a,$len);
    }
}

Measured memory_bytes: 15412
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

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

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b;

	cin >> a >> b;

	if (a <= b){
		cout << a << endl;
	}else{
		cout << a-1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys

MOD = 10 ** 9 + 7
# MOD = 998244353
def make_tables(n=10 ** 9, r=2 * 10 ** 6, p=MOD):
  fac = [None] * (r + 1); fac[0] = 1
  for i in range(r): fac[i+1] = fac[i] * (i + 1) % p
  ifac = [None] * (r + 1); ifac[r] = pow(fac[r], p - 2, p)
  for i in range(r, 0, -1): ifac[i-1] = ifac[i] * i % p
  n_choose = [None] * (r + 1); n_choose[0] = 1
  for i in range(r): n_choose[i+1] = n_choose[i] * (n - i) % p
  for i in range(r + 1): n_choose[i] = n_choose[i] * ifac[i] % p
  return fac, ifac, n_choose

fac, ifac, n_choose = make_tables()

def mod_choose(n, r, p=MOD):
  if r > n or r < 0: return 0
  return fac[n] * ifac[r] % p * ifac[n-r] % p

def nHr(n, r, p=MOD):
  return fac[n-1+r] * ifac[n-1] % p * ifac[r] % p

def sieve_of_eratosthenes(n=10 ** 6):
  sieve = [1] * (n + 1); sieve[0] = sieve[1] = 0
  for i in range(2, int(n ** 0.5) + 1):
    if not sieve[i]: continue
    for j in range(i * 2, n + 1, i): sieve[j] = 0
  prime_numbers = [i for i in range(2, n + 1) if sieve[i]]
  return sieve, prime_numbers

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

n, m = map(int, sys.stdin.readline().split())

def main():
  res = 1
  for p, c in prime_factorize(m).items():
    res *= nHr(n, c)
    res %= MOD 
  print(res)

if __name__ == '__main__':
  main()

Measured memory_bytes: 253568
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
long double ff(long double a){
  
  a*=10000.0;
  //  cout<<a<<endl;
  long long c = a;
  if(c%10>4)c+=10;
  c/=10;
  return (long double)c/1000.0;
}



long double ax,ay,bx,by,cx,cy,ox,oy,dx,dy,ex,ey;
//ack はACの傾き  eos はEOの切片
long double abk,ack,dok,eok,eos,dos,eps=0.0;
int n;
int main(){

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ax>>ay>>bx>>by>>cx>>cy;
    //ABの中点をD,  ACの中点をE 外接円の中心をO とする
    dx=(ax+bx)/2.0;
    dy=(ay+by)/2.0;
    ex=(ax+cx)/2.0;
    ey=(ay+cy)/2.0;
    
    if(ax==bx){
      abk=(ay-by)/0.000000000001;
    }else{
      abk=(ay-by)/(ax-bx);
    }
    if(abk==0.0)abk=0.000000000001;
    dok=-1.0/abk;
    dos=dy-dx*dok;
    
    
    if(ax==cx){
      ack=(ay-cy)/0.000000000001;
    }else{
      ack=(ay-cy)/(ax-cx);
    }
    if(ack==0.0)ack=0.000000000001;
    eok=-1.0/ack;
    eos=ey-ex*eok;
    
    //Y  =  dok X  + dos
    //Y  =  eok X  + eos
    //dok X + dos = eok X + eos
    
    long double Y,X;
    if(dok-eok==0.0){
      X=(eos-dos)/0.000000000001;
    }else{
      X=(eos-dos)/(dok-eok);
    }
    Y= dok * X + dos;
    
    printf("%.3Lf %.3Lf ",X,Y);
    //cout<<ax<<' '<<X<<' '<<ay<<' '<<Y<<endl;
    printf("%.3Lf\n" ,  sqrt( pow(ax-X,2) + pow(ay-Y,2) ));

    
    
  }
  return 0;
}

Measured memory_bytes: 1248
use std::io;
use std::cmp;

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {

    let (n, m) = {
        let a = read::<isize>();
        (a[0], a[1])
    };

    if n == 1 && m == 1 {
        println!("1");
    } else if n < 2 || m < 2 {
        println!("{}", (cmp::max(n - 2, m - 2)));
    } else {
        println!("{}", (cmp::max(n - 2, 0)) * (cmp::max(m - 2, 0)));
    }

}

Measured memory_bytes: 4352
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
Graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = MI()
    Graph[a].append(b)
    Graph[b].append(a)
C = LI()
C.sort(reverse=True)
print(sum(C[1:]))

ANS = [-1]*(N+1)
index = 0


def dfs(x,i):
    global index
    ANS[x] = C[i]
    for y in Graph[x]:
        if ANS[y] == -1:
            index += 1
            dfs(y,index)


dfs(1,0)
print(*ANS[1:])


Measured memory_bytes: 82852
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

//aのp乗を求めるアルゴリズム
long modpow(long a, int p) {
	if (p == 0)return 1;
	if (p % 2 == 0) {
		//pが偶数のとき
		int halfP = p / 2;
		long half = modpow(a, halfP);
		return half * half % mod;
	}
	else {
		//pが奇数の時は、
		//pを偶数にするために1減らす
		return a * modpow(a, p - 1) % mod;
	}

}


//(10*9*8)/(3*2*1);
//10*9*8 -> ansMul
//3*2*1 -> ansDiv;
long calcComb(int a, int b) {
	if (b > a - b) return calcComb(a, a - b);
	long ansMul = 1;
	long ansDiv = 1;
	rep(i, 0, b) {
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}
	//ansMul /ansDivをやりたい
	//ansDivの逆元を使って求めよう。

	long ans = ansMul * modpow(ansDiv, mod - 2) % mod;
	return ans;

}

bool is_war(const vector<int>& x, const vector<int>& y) {
	for (int Z = -100; Z <= 100; Z++) {
		bool is_ok = true;
		rep(i, 0, x.size()) {
			if (x[i] >= Z) {
				is_ok = false;
			}
			rep(i, 0, y.size()) {
				if (y[i] < Z) {
					is_ok = false;
				}
			}
			
		}
		if (is_ok)return false;
		
	}
	return true;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s;
	rep(i, 0, s.size()) {
		if (s[i] == '1') {
			s[i] = '9';
		}
		else if (s[i] == '9') {
			s[i] = '1';
		}
	}

	cout << s << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void){
  int N, inputx, inputy, counter = 0;
  double sum = 0;
  vector<int> numList;
  vector<pair<int, int>> coor;

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> inputx >> inputy;
    coor.push_back(make_pair(inputx, inputy));
    numList.push_back(i);
  }

  do{
    for(int i=0; i<N - 1; i++){
      sum += sqrt(pow(coor[numList[i]].first - coor[numList[i + 1]].first, 2) + pow(coor[numList[i]].second - coor[numList[i + 1]].second, 2));
    }
    counter++;
  }while(next_permutation(numList.begin(), numList.end()));

  cout << fixed << setprecision(10) << sum / counter;
  return 0;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  char s;
  cin >> s;
  printf("%c\n", s+1);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k-1] -= 'A' - 'a';
    cout << s << endl;
}


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

int main() {
  int N; cin >> N;
  int H[N]; for (int i = 0; i < N; ++i) cin >> H[i];
  int max = 0, num = 0;
  for (int i = 1; i < N; ++i) {
    if (H[i] <= H[i - 1]) {
      ++num;
      if (num > max) max = num;
    } else {
      num = 0;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 640
def test():
    a,b = map(int,input().split())
    count = 0
    for i in range(a,b+1):
        j = list(map(int,list(str(i))))
        if j[0] == j[4] and j[1] == j[3]:
            count += 1
    print(count)


if __name__ == "__main__":
    test()


Measured memory_bytes: 3060
use std::io::*;
use std::str::*;
use std::collections::HashSet;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: usize = read().unwrap();
    let mut paper = HashSet::new();
    for _ in 0..n {
        let n: usize = read().unwrap();
        if !paper.contains(&n) {
            paper.insert(n);
        } else {
            paper.remove(&n);
        }
    }
    println!("{}", paper.len());
}


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

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

    bool taka = true;
    while(a>0 && c>0){
        if(taka){
            c-=b;
        }else{
            a-=d;
        }
        taka=!taka;
    }

    if(a>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3

N = int(input())
S = input()

left = [] 

for i, s in enumerate(S):
    if s == "(":
        left.append("(")
    else:
        if len(left) > 0:
            left.pop()
        else:
            S = "(" + S

for _ in range(len(left)):
    S += ")"

print(S)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll n,m,imos[100010]={},ans=0;

void init(){
	cin>>n>>m;
	rep(i,m){
		ll l,r;
		cin>>l>>r;
		imos[l]++;
		imos[r+1]--;
	}
	reg(i,0,n){
		imos[i+1]+=imos[i];
		if(imos[i+1]==m)ans++;
	}
}

int main(void){
	init();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int MOD = 1e9+7;
int64_t mpow(int64_t a, int64_t b , int64_t uMOD = (int64_t)1e9+7){
    int64_t res{1ll};
    while(b){
        if(b&1ll){
            (res*=a)%=uMOD;
        }
        (a*=a)%=uMOD;
        b>>=1ll;
    }
    return res;
}
signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout.tie(nullptr);
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int n; cin >> n; 
    if(n == 1){
        cout << 0 << '\n'; 
        return 0;
    }else if(n==2){
        cout << 2 << '\n';
        return 0;
    }
    int tenPowN = mpow(10ll , n); 
    int eightPowN = mpow(8ll , n); 
    int ninePowN = (mpow(9ll , n)*2ll)%MOD; 
    cout << (tenPowN + eightPowN - ninePowN + MOD +MOD+MOD)%MOD << '\n'; 
    return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    for (int i = 0;i < n;++i) cin >> a[i].second >> a[i].first;
    bool ans = true;
    ll t = 0;
    sort(a.begin(),a.end());
    for (int i = 0;i < n;++i) {
        t += a[i].second;
        if (t > a[i].first) ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *NIL, *root;


void insert(int key){

    Node *x, *y, *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    y = NIL;
    x = root;

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

Node* find(int key){
    Node *x, *y;
    int target = key;
    bool judge = false;
    x = root;
    while(x != NIL){
        if(target > x->key){
            x = x->right;
        }
        else if(target < x->key){
            x = x->left;
        }
        else{
            judge = true;
            break;
        } 
    }
    //if(judge) cout << "yes" << endl;
    //else cout << "no" << endl;
    return x;
}

void preorder(Node *node){
    if(node == NIL) return ;
    cout << " " << node->key;
    if(node->left != NIL) preorder(node->left);
    if(node->right != NIL) preorder(node->right);
}

void inorder(Node *node){
    if(node == NIL) return;
    if(node->left != NIL) inorder(node->left);
    cout << " " << node->key;
    if(node->right != NIL) inorder(node->right);
}


void print(){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}

int main(){
    int i, m, key;

    string command;

    cin >> m;
    for(i = 0; i < m ; i++){
        cin >> command;
        if(command[0] == 'i'){
            cin >> key;
            insert(key);
        } else if(command[0] == 'p'){
            print();
        }
        else{
            cin >> key;
            //find(key);
            if (find(key) != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 21808
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
struct P{string a;int t,xh;}z,lins;
int op[]={1,4,-1,-4},sz[9];
map <string,int> dp;
void bfs(){
	queue <P> que;
	que.push(z);
	while (!que.empty()){
		for (int i=0;i<4;i++){
			lins=que.front();
			int j,xh=lins.xh+op[i],sum=0;
			if (xh<0||xh>7||(lins.xh==3&&op[i]==1)||(lins.xh==4&&op[i]==-1)) continue ;
			swap(lins.a[lins.xh],lins.a[xh]);
			map <string,int>::iterator it=dp.find(lins.a);
			if (it != dp.end()) continue;//dp.count(lins.a)!=0
			lins.xh=xh;
			lins.t++;
			dp[lins.a]=lins.t;			
			que.push(lins);
		}
		que.pop();
	}
}
int main()
{
	int i,j;
	char c[9];
	z.a="01234567",z.xh=0,z.t=0;
	bfs();
	while (~scanf("%d",&sz[0]))
	{
		for (i=1;i<8;i++)
			scanf("%d",&sz[i]);
		for (i=0;i<8;i++)
			c[i]=sz[i]+'0';
		c[8]='\0';
		string S=c;
		printf("%d\n",dp[S]);
	}
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  string s1 = "",s2 = "";
  for ( int i = 0; i < b; i++){
    ostringstream oss;
    oss << a;
    s1 += oss.str();
  }
  for ( int i = 0; i < a; i++){
    ostringstream oss;
    oss << b;
    s2 += oss.str();
  }

  if ( s1 < s2){
    cout << s1 << endl;
  }else {
    cout << s2 << endl;
  }

  return 0;
}

Measured memory_bytes: 256