akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
void low(char &c){
c=tolower(c);
}
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
        cout << n << " ";
}

#include <iostream>
using namespace std;
void fast();
long long arr[200005];
long long arr2[200005];


int main() {
fast();
double n,x;
cin >> n >> x;
cout <<(int) ceil((x-1)/(n-1));

}





void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

}


Measured memory_bytes: 256
import java.io.*;

public class Main {


    void solve() {
        int n = io.nextInt();
        int[] A = new int[n];
        for(int i = 0; i < n; i++) {
            A[i] = io.nextInt();
        }
        int q = io.nextInt();
        int[] m = new int[q];
        for(int i = 0; i < q; i++) {
            m[i] = io.nextInt();
        }

        for(int x : m) {
            System.out.println(f(x, A, 0, 0) ? "yes" : "no");
        }

    }

    boolean f(int n, int[] A, int idx, int sum) {
        if(idx == A.length) return n == sum;
        return f(n, A, idx+1, sum+A[idx]) || f(n, A, idx+1, sum);
    }

    public static void main(String[] args) {
        new Main().solve();
    }
    IO io = new IO();

    class IO {
        private final int SIZE = 1 << 12;
        private final InputStream stream = System.in;
        private final byte[] buffer = new byte[SIZE];
        private int ptr = 0, buffLen = 0;
        private boolean hasNextByte() {
            if(ptr < buffLen) return true;
            ptr = 0;
            try {
                buffLen = stream.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return buffLen > 0;
        }
        private byte readByte() {
            if(hasNextByte()) return buffer[ptr++];
            return -1;
        }
        private boolean isAscii(byte i) {
            return '!' <= i && i <= '~';
        }
        public char nextChar() {
            byte b = readByte();
            while(!isAscii(b)) b = readByte();
            return (char)b;
        }
        public String next() {
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while(isAscii(b)) {
                sb.append((char)b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return Integer.valueOf(next());
        }
        public long nextLong() {
            return Long.valueOf(next());
        }
        public double nextDouble() {
            return Double.valueOf(next());
        }
    }
}



Measured memory_bytes: 24776
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if(b%a==0) cout << a+b <<endl;
  else cout << b-a << endl;
}



Measured memory_bytes: 256
import Control.Arrow
import Data.Bits
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
main=print.solve.map(V.unfoldr$B.readInt.B.dropWhile isSpace).B.lines=<<B.getContents
solve(n:fp)=maximum$map g[1..1023]where
  fps=uncurry zip.(first$map(V.foldl'(\v f->v*2+f)0))$splitAt(n V.! 0)fp
  g b=sum$map(\(f,p)->p V.! popCount(f.&.b))fps

Measured memory_bytes: 4700
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, m: usize, lr: [(usize1, usize1); m]);

    let mut acc = vec![0i64; n + 1];
    for i in 0..m {
        let (l, r) = lr[i];
        acc[l] += 1;
        acc[r + 1] -= 1;
    }
    for i in 0..n {
        acc[i + 1] += acc[i];
    }

    let mut ans = 0;
    for i in 0..n {
        if acc[i] == m as i64 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
def fact(a):
    b = 1
    for i in range(1,a+1):
        b = (b*i)%inf
    return b
inf = 10**9+7
N, M = map(int,input().split())
if abs(N-M) == 1:
    ans = fact(N)*fact(M)%inf
elif abs(N-M) == 0:
    ans = fact(N)*fact(M)*2%inf
else: ans = 0
print(ans)

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

#define ld long double
#define ll long long
#define ull unsigned long long
#define vll vector <ll>
#define pll pair <ll, ll>
#define vpll vector <pll>

#define f first
#define s second

#define ios ios_base::sync_with_stdio(0), cin.tie()
#define pb push_back
#define mp make_pair

#define FOR(i,n) for(ll i=0;i<n;i++)
#define FORIN(v) for(auto i:v)
#define ALL(v) (v.begin(),v.end())

#define pi 3.14159265358979323846264

using namespace std;
int K,N; string s;
int main(){
    ios;
    cin>>N>>K>>s;
    s[K-1]+=32;
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
class ConvexHullTrick():
    def __init__(self, xlist, INF=10**18):
        xlist = sorted(xlist)
        self.comp = {x : k for k, x in enumerate(xlist)}
        self.h = (len(xlist) - 1).bit_length()
        self.n = 2**self.h
        self.ie = (0, INF)
        self.inf = INF
        self.x = xlist + [INF] * (self.n - len(xlist))
        self.tree = [self.ie for _ in range(2 * self.n)]

    def val(self, line, x):
        a, b = line
        return a * x + b

    def _add_(self, line, idx, lt, rt):
        while True:
            mid = (lt + rt) // 2
            lx = self.x[lt]
            mx = self.x[mid]
            rx = self.x[rt - 1]
            lu = self.val(line, lx) < self.val(self.tree[idx], lx)
            mu = self.val(line, mx) < self.val(self.tree[idx], mx)
            ru = self.val(line, rx) < self.val(self.tree[idx], rx)
            if lu and ru:
                self.tree[idx] = line
                return
            if not lu and not ru:
                return
            if mu:
                self.tree[idx], line = line, self.tree[idx]
            if lu != mu:
                rt = mid
                idx = 2 * idx
            else:
                lt = mid
                idx = 2 * idx + 1

    def add_line(self, line):
        self._add_(line, 1, 0, self.n)

    def add_seg(self, line, lt, rt):
        lidx = self.comp[lt] + self.n
        ridx = self.comp[rt] + self.n
        lt = self.comp[lt]
        rt = self.comp[rt]
        size = 1
        while ridx - lidx > 0:
            if lidx & 1:
                self._add_(line, lidx, lt, lt + size)
                lidx += 1
                lt += size
            if ridx & 1:
                ridx -= 1
                rt -= size
                self._add_(line, ridx, rt, rt + size)
            lidx >>= 1
            ridx >>= 1
            size <<= 1

    def get_min(self, x):
        idx = self.comp[x] + self.n
        res = self.inf
        while idx:
            res = min(res, self.val(self.tree[idx], x))
            idx >>= 1
        return res

N = int(input())
T = list(map(int, input().split()))
V = [0] + list(map(int, input().split())) + [0]
X = [0]

for i in range(N):
    X.append(X[-1] + 2 * T[i])

cht = ConvexHullTrick(range(X[-1] + 2))

for i in range(N):
    cht.add_seg((0, 2 * V[i + 1]), X[i], X[i + 1] + 1)

for i in range(N):
    cht.add_seg((1, 2 * V[i] - X[i]), X[i], X[-1] + 1)

for i in range(N):
    cht.add_seg((-1, 2 * V[i + 2] + X[i + 1]), X[0], X[i + 1] + 1)

D = [0 for _ in range(X[-1] + 1)]

for i in range(X[-1] + 1):
     D[i] = cht.get_min(i)

S = 0

for i in range(X[-1]):
    S += D[i] * 2 + (D[i + 1] - D[i])

print(S / 8)

Measured memory_bytes: 52716
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
#include <cmath>

typedef long long ll;

ll gcd(ll x, ll y)
{
    return y ? gcd(y, x % y) : x;
}

int main()
{
    ll A = 0, B = 0;

    scanf("%lld %lld", &A, &B);
    ll p = gcd(A, B);

    int ans = 1;
    ll t = 2;
    // printf("0- p = %lld, t = %lld\n", p, t);
    while (p >= t)
    {
        if (p % t == 0)
        {
            while (p % t == 0)
            {
                p /= t;
                // printf("1- p = %lld, t = %lld\n", p, t);
            }
            ans++;
        }
        else if (p < t * t)
        {
            ans++;
            // printf("2- p = %lld, t = %lld\n", p, t);
            break;
        }
        t++;
    }
    printf("%d\n", ans);
    return 0;
}


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

public class Main {

	static int MAXW = 100000+1;
	static int MAXN = 101;
	
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int n = Integer.parseInt(st.nextToken());
		int mw = Integer.parseInt(st.nextToken());
		
		long[] maxv = new long[mw+1];
		
		for(int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			int w = Integer.parseInt(st.nextToken());
			int v = Integer.parseInt(st.nextToken());
			for(int j = mw-w; j >=0; j--) {
				maxv[j+w] = Math.max(maxv[j] + v, maxv[j+w]);
			}
		}
		
		bw.write(""+maxv[mw]);
		bw.close();
	}

}


Measured memory_bytes: 22484
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int N,A,B;
  scanf("%d%d%d",&N,&A,&B);
  int P[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%d", &P[i]);
  }
  int Q,R,S;
  Q=0;R=0;S=0;
  for (size_t i = 0; i < N; i++) {
    if (P[i]<=A) {Q++;}
    if (A+1<=P[i] && P[i]<=B) {R++;}
    if (B+1<=P[i]) {S++;}
  }
  int ans=Q;
  if (ans>R) {ans=R;}
  if (ans>S) {ans=S;}
  printf("%d", ans);
  return 0;
}

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

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

    int n, m;
    cin >> n >> m;

    vector<int> num(n, 1);
    vector<bool> cand(n, false);
    cand[0] = true;
    int ptr = 0;
    rep(i, m){
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        --num[x];
        ++num[y];
        if(cand[x]) {
            cand[y] = true;
            if(num[x]==0) cand[x] = false;
        }
    }

    int res = 0;
    rep(i, n){
        if(num[i] && cand[i]) ++res;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

long long MOD = 1000000007;

int main(){
  long long N, K;
  cin >> N >> K;
  long long A[N];
  rep(i, N)
    cin >> A[i];
  // 入力終了

  long long ans = 0;
  
  // 自分自身の中にある転倒数の数
  long long inner = 0;
  rep(i, N-1){
    for(int j=i+1; j<N; j++){
      if(A[i] > A[j])
	inner = (inner+1)%MOD;
    }
  }

  // inner分をansに反映
  ans = (inner * K) % MOD;

  // A[i]より小さい数がA[]の中にいくつあるか
  long long cnt[2001] = {0};
  rep(i, N){
    rep(j, N){
      if(A[j] < A[i])
	cnt[ A[i] ]++;
    }
  }

  // 繰り返しでは，題意をみたすcnt[A[i]]回が(K-1)回繰り返される
  // i回目の繰り返しで，(i+1)回目以降の繰り返しにも関係する
  // (説明適当)
  rep(i, 2001){
    long long tmp = (K-1)*K/2%MOD;
    ans = (ans + (cnt[ i ]*tmp % MOD) ) % MOD;
  }

  // 解答
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620
// In the name of Allah //
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = (1e5 + 10) * 2;
ll a[maxn] , mx , n;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i ++){
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i ++){
        mx = max (mx , a[i]);
        if (a[i] < mx)
            ans += mx - a[i];
    }
    cout << ans;
    
}



Measured memory_bytes: 5148
from collections import defaultdict,deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


from itertools import combinations_with_replacement
n, m, q = inpl()
ans=0
data=[inpl() for _ in range(q)]
for t in combinations_with_replacement(range(1,m+1), n):
    tmp = 0
    for a,b,c,d in data:
        if t[b - 1] - t[a - 1] == c:
            tmp += d
    ans = max(tmp, ans)
print(ans)

Measured memory_bytes: 70824
package main

import (
  "fmt"
  "os"
  "bufio"
  "strconv"
)

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())

  cnt := 0
  for i := 1; i <= n; i++ {
    sc.Scan()
    a, _ := strconv.Atoi(sc.Text())
    if a != i {
      cnt++
    }
  }
  if cnt <= 2 {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }


}



Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,x;
   
    
    while(true){
         int c=0;
        cin>>n>>x;
        if(n==0&&x==0) break;
        
        for(int i=1;i<=n;i++){
          for(int j=i+1;j<=n;j++){
            for(int k=j+1;k<=n;k++){
               
        if((i+j+k)==x) c++;
        if((i+j+k)>x) break;
        }
         }
        }
        
        cout<<c<<endl;
    }
    
    
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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


struct Node {
  vector<int> to;
  vector<int> cost;
  bool done = false;
  int minCost = INT_MAX;
};

int dijkstra(vector<Node> v, int start, int goal){
  int nodeNum = int(v.size());
  v[start].minCost = 0;
  int now = start;
  while(true) {
    // printNode(v);
    v[now].done = true;
    if(now == goal) return v[now].minCost;
    int edgeNum = int(v[now].to.size());
    for (int i = 0; i < edgeNum; i++) {
      int nextNodeIndex = v[now].to[i];
      v[nextNodeIndex].minCost =
        min(v[nextNodeIndex].minCost, v[now].minCost + v[now].cost[i]);
    }

    int minNodeIndex = -1;
    int minNodeCost = INT_MAX;
    for (int i = 0; i < nodeNum; i++) {
      if(i == now) continue;
      if(minNodeCost > v[i].minCost && !v[i].done){
        minNodeIndex = i;
        minNodeCost = v[i].minCost;
      }
    }
    now = minNodeIndex;
  }
}

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<int>> field(h,vector<int>(w));
  vector<vector<int>> cost(10,vector<int>(10));
  vector<Node> cost_field(10);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      cost_field[i].to.push_back(j);
      cost_field[j].cost.push_back(tmp);
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> field[i][j];
    }
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cost[i][j] = dijkstra(cost_field, j, i);
    }
  }

  ll res = 0;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(field[i][j] == -1) continue;
      res += cost[field[i][j]][1];
    }
  }

  cout << res << endl;


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	char s;cin>>s;
	if(int(s)-'a'>=0 && int(s)-'a'<=25){
		cout<<"a"<<endl;
	}
	else{
		cout<<"A"<<endl;
	}
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
	using namespace std;
	int main()
	{
	  ios::sync_with_stdio(false);
	  cin.tie(0);
	  string s,t;
	  cin>>s;
	  cin>>t;
	  if(s.size()>=1&&s.size()<=10&&s.size()+1==t.size())
	  {
		 t.pop_back();
		 if(s==t)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	  }
	  else
	  cout<<"No"<<endl;  
	return 0;
	}


Measured memory_bytes: 3620
t=list(map(int,input().split(" ")))
a=t[0]
b=t[1]
c=t[2]
k=t[3]
flag=0
sum = 0
if(a>k):
    sum=sum+k
    flag=1
    k=0
else:
    k=k-a
    sum=sum+a
    flag=1
    # print(k,sum)
if(flag==1):
    if(k!=0):
        if(b>k):
            k=0
            flag=2
        else:
            k=k-b
            flag=2
if(flag==2):
    if(k!=0):
        if(c>k):
            sum=sum-k
        else:
            k=k-c
            sum=sum-c
print(sum)
    

Measured memory_bytes: 81240
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        double W = sc.nextDouble();
        double H = sc.nextDouble();
        double x = sc.nextDouble();
        double y = sc.nextDouble();

        System.out.print(W*H/2.0);
        System.out.println(" " + ((x==W/2 && y==H/2)? 1:0));
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n, p, differ_num = 0;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		cin >> p;
		if(p != i + 1) differ_num++;
	}
	cout << (differ_num <= 2 ? "YES" : "NO");
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3604
class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1] * n

    # 根を返す
    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    # 合併する
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return

        if self.parents[x] > self.parents[y]:
            x,y=y,x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


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

for i in range(M):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    u.union(x,y)

x=u.parents
ans=10**10
for i in x:
    ans=min(ans,i)

print(ans*(-1))


Measured memory_bytes: 76912
n, x = input().split(" ")
a = input().split(" ")

n, x = int(n), int(x)
a = sorted([int(i) for i in a])

s = x
ret = 0
for i in a:
    if s >= i:
        ret += 1
        s -= i
        n -= 1

if s and n==0:
    ret -= 1

print(ret)


Measured memory_bytes: 3060
D,G=(int(i) for i in input().split())
p,c=[],[]

for i in range(D):
    tmpp,tmpd = (int(i) for i in input().split())
    p.append(tmpp)
    c.append(tmpd)

#まずはコンプ部分の点数を計算する
#コンプ報酬+基本スコア*問題数
comp = [100*(i+1)*p[i]+c[i] for i in range(D)]

#現時点では全問解かないと
#目標達成できないとする
ans = sum(p)

#D桁の2進数bを使ってコンプする問題を指定する
#00001=>100点問題をコンプする
b=[0]*D
while True:
    #コンプ部分のスコア
    score = sum([comp[i]*b[i] for i in range(D)])
    #この時点での問題数
    probCount = sum([p[i]*b[i] for i in range(D)])

    #目標達成までハイスコア問題を加算
    #まずはハイスコア問題はどれか
    hi = 'None' #全部コンプ問題としておく
    for i in range(D):
        k = D-i-1
        if b[k]==0:
            hi = k
            break
    #目標達成まで加算（コンプしても達成しない場合もある
    if hi != 'None':
        for i in range(p[k]):
            if score >=G:
                break
            else:
                score += 100*(hi+1)
                probCount += 1

    #目標達成なら現時点の最小問題数と比較
    if score>=G and ans > probCount:
        ans = probCount

    #全部コンプまでやったら終了
    if all(b):
        break
    
    #bに1を加算
    for i in range(D):
        if b[i]==0:
            for j in range(i):
                b[j]=0
            b[i]=1
            break
    
print(ans)

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

using namespace std;

int main() {
	int H,W; cin >> H >> W;
	int cnt[26]={};
	for(int i=0;i<H*W;++i) {
		char a;  cin >> a;
		++cnt[a-'a'];
	}
	int cnt4=0,cnt2=0,cnt1=0;
	for(int i=0;i<26;++i) {
		cnt4+=cnt[i]/4; cnt[i]%=4;
		cnt2+=cnt[i]/2; cnt[i]%=2;
		cnt1+=cnt[i];
	}
	bool flag=true;
	if(H%2==0&&W%2==0) {
		if(cnt2+cnt1) flag=false;
	} else if((H*W)&1) {
		cnt4-=(H/2)*(W/2);
		if(cnt4<0) flag=false;
		if(cnt2+cnt4*2<H/2+W/2) flag=false;
		if(!cnt1) flag=false;
	} else {
		if(cnt4<(H/2)*(W/2)) flag=false;
		if(cnt1) flag=false;
	}
	cout << (flag?"Yes":"No") << endl;
	
	return 0;
}
/*
偶*偶 -> 4*?
偶*奇 -> 4*((偶/2)*(奇/2)) + 2*?
奇*奇 -> 4*((奇/2)*(奇/2)) + 2*((奇/2)+(奇/2)) + 1

####
####
####
#### -> 4*4

###
###
### -> 4*1 + 2*2 + 1*1

####
####
#### -> 4*2 + 2*2

3x3 -> 4*1 + 2*2 + 1*1
3x5 -> 4*2 + 2*3 + 1*1
3x7 -> 4*3 + 2*4 + 1*1
7x5 -> 4*6 + 2*5 + 1*1
   #   
   #   
#######
   #   
   #   

 */


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

positive = false
c = a.count {|x| x >= 0}
if [0, n].include?(c)
  puts n-1
  if a[0] >= 0
    positive = true
  end
else
  puts 2*n-1
  ma, mi = a.max, a.min
  if ma.abs >= mi.abs
    positive = true
    mai = a.index(ma) + 1
    1.upto(n) do |i|
      puts "#{mai} #{i}"
    end
  else
    mii = a.index(mi) + 1
    1.upto(n) do |i|
      puts "#{mii} #{i}"
    end
  end
end

if positive
  1.upto(n-1) do |i|
    puts "#{i} #{i+1}"
  end
else
  n.downto(2) do |i|
    puts "#{i} #{i-1}"
  end
end

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

int main() {
	int hour, minute, second;

	cin >> second;

	hour = second / 3600;
	second = second - (3600 * hour);
	minute = second / 60;
	second = second - (60 * minute);

	cout << hour << ":" << minute << ":" << second << endl;

	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    ll n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int x=0; //初項
    int y=0; //交差
    rep(i,n){
        rep(j,n){
            if(i==j) continue;
            if(a[i]<a[j]){
                y++;
                if(i>j)
                    x++;
            }
        }
    }
    ll sum = (k-1)*y;
    sum+=2*x;
    sum%=MOD;
    sum*=k;
    sum%=MOD;
    sum = sum* modinv(2, MOD) % MOD;
    cout << sum << endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	puts((abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) ? "Yes" : "No");
        return 0;
}


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

int main(){

    int N,M;
    cin >> N >> M;
    vector<int> A(M),B(M);
    for(int i=0;i<M;i++)
        cin >> A[i] >> B[i];

    vector<vector<int>> G(N+1); //G(0) will not be used
    for(int i=0;i<M;i++){
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }

    queue<int> que;
    que.push(1);
    int nowdist = 1;
    const int NOT_REACHED = 1000000;
    int dists[N+1],signs[N+1];
    for(int i=0;i<=N;i++){
        dists[i] = NOT_REACHED;
        signs[i] = 0;
    }
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(auto v : G[now]){
            if(dists[v] > nowdist){
                que.push(v);
                dists[v] = nowdist;
                signs[v] = now;
            }
        }
    }

    cout << "Yes" << endl;
    for(int i=2;i<=N;i++){
        cout << signs[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 12028
def f(s):
  d=[-1]*-~n
  d[s]=0
  q=[s]
  while q:
    v=q.pop()
    c=d[v]+1
    for w in e[v]:
      if d[w]<0:
        d[w]=c
        q+=w,
  return d
n,u,v,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(*[iter(t)]*2):
  e[a]+=b,
  e[b]+=a,
m=0
for a,b in zip(*map(f,(u,v))):
  if a<b:m=max(m,b-1)
print(m)

Measured memory_bytes: 32084
import numpy as np

S=input()

half_a=''
half_b=''

if len(S)%2==0:
    half_a=np.array(list(S[int(len(S)/2):]))
    half_b=np.array(list(S[:int(len(S)/2)][::-1]))
    
if len(S)%2==1:
    half_a=np.array(list(S[int(len(S)/2)+1:]))
    half_b=np.array(list(S[:int(len(S)/2)][::-1]))


print(np.sum(half_a!=half_b))

Measured memory_bytes: 12504
def main():
  N, M, *AB = map(int, open(0).read().split())

  inter, goalable = set(), set()
  
  iterator = iter(AB)
  for a, b in zip(iterator, iterator):
    if a == 1:
      inter.add(b)
    
    if b == N: 
      goalable.add(a)
      
  flag = inter & goalable
  print("POSSIBLE" if flag else "IMPOSSIBLE")
  
if __name__ == "__main__":
    main()


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

int main(){
	int a[5];
	for(int i=0 ;i<5; ++i) scanf("%d", &a[i]);
	int k;
	scanf("%d", &k);

	if(a[4] - a[0] > k)
		printf(":(\n");
	else printf("Yay!\n");

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    sort(A, A+n, greater<>());
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            sum += A[i];
        }else{
            sum -= A[i];
        }
    }
    cout << sum << endl;
    return 0;
}


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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int m, n, l;
	int nowMoney;
	int completeMonth;

	while( 1 )
	{
		l = in();
		if( l == 0 )break;
		
		nowMoney = 0;
		completeMonth = 13;

		loop(i, 0, 12)
		{
			scanf("%d%d", &m, &n);
			nowMoney += m - n;
			if( nowMoney >= l && i + 1 < completeMonth )
			{
				completeMonth = i + 1;
			}
		}
		if( completeMonth == 13 )
		{
			cout << "NA" << endl;
		}
		else
		{
			cout << completeMonth << endl;
		}
	}

	return (0);
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Y cout << "YES\n"
#define N cout << "NO\n"
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define R(i, n) for (int i = 0; i < n; i++)
#define RE(i, a, b) for (int i = a; i >= b; i--)

long long mod = 1000000007 , ans = 1 ;
int p(long long a , long long b)
{
    while(b)
    {
        if(b%2)
        {
            ans = ( (ans%mod)*(a%mod) ) %mod ;
        }
        a = ((a%mod)*(a%mod))%mod ;
        b /= 2 ;
    }
    return ans ;
}


int prime[1000010] ;
void fun()
{
	for (int i = 1 ; i < 1000001; i++)
	{
		for (int j = i ; j < 1000001; j += i)
		{
               prime[j]++;
		}
	}
}
int x[1000010] ;

int gcd(ll a,ll b)
{
     if(b == 0)
     {
          return a ;
     }
     return gcd(b,a%b) ;
}
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int k ;
     cin >> k ; 
     R(i,k)
     {
          cout << "ACL" ;
     }
     cout << endl ;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string S;
  cin >> S;
  if(S[0]==S[1] ||  S[1]==S[2] || S[2]==S[3]){cout << "Bad" << endl;}
  else{cout << "Good" << endl;}
}


Measured memory_bytes: 256
import sys

def solve(n, ls_xyh):
    x0 = None
    for i in range(n):
        if ls_xyh[i][2] > 0:
            [x0,y0,h0] = ls_xyh[i]
            break
    cands = [(cx, cy, h0 + abs(cx - x0) + abs(cy - y0))
             for cx in range(101) for cy in range(101)]
    for [x,y,h] in ls_xyh:
        cands = [(cx, cy, ch) for (cx, cy, ch) in cands
                    if max(ch - abs(cx - x) - abs(cy - y), 0) == h]
    (xx, yy, hh) = cands[0]
    return ' '.join([str(xx), str(yy), str(hh)])

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    ls_xyh = [list(map(int, sys.stdin.readline().strip().split()))
              for j in range(n)]
    return (n, ls_xyh)

def main():
    print(solve(*readQuestion()))

# Uncomment before submission
main()



Measured memory_bytes: 4980
n = int(input())
tp, xp, yp = 0, 0, 0
for _ in range(n):
    t, x, y = map(int, input().split())
    td = t - tp
    xd = x - xp
    yd = y - yp
    if td < abs(xd) + abs(yd) or (td - abs(xd) - abs(yd)) % 2 == 1:
        print('No')
        break
    tp = t
    xp = x
    yp = y
else:
    print('Yes')


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

int main() {
    long long int a,b,c;
    cin>>a>>b>>c;
    if(c-a-b<=0){
        cout<<"No"<<endl;
    }else{
        if(4*a*b<(c-a-b)*(c-a-b))cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using std::cin;
using std::cout;
using std::endl;
using std::max;
using std::min;

int main() {
    int n, index = 0;

    cin >> n;

    int maxGain = -1E09;
    int minElement, tempElement;

    while (index < n) {
        cin >> tempElement;

        if (index == 0){
            minElement = tempElement;
        }
        
        else {
            maxGain = max(maxGain, tempElement - minElement);
            minElement = min(minElement, tempElement);
        }  

        index ++;
    }

    cout << maxGain << endl;

    return 0;
}


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

int main()
{
	string S, T, U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if(S == U){
		cout << A-1 << " " << B;
	} else {
		cout << A << " " << B-1;
	}
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define sc(x) scanf("%d", &x)
#define sc2(x, y) scanf("%d%d", &x, &y)
#define sc3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sc4(x, y, z, t) scanf("%d%d%d%d", &x, &y, &z, &t)
#define print(x) printf("%d ", x)
#define println(x) printf("%d\n", x)
#define println2(x, y) printf("%d %d\n", x, y)
#define println3(x, y, z) printf("%d %d %d\n", x, y, z)
#define println4(x, y, z, t) printf("%d %d %d %d\n", x, y, z, t)
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define endl '\n'                           // CommentInInteractive
#define DB(x) cerr << #x << " = " << x << endl

const ld eps = 1e-6;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << a * (n / (a + b)) + (min(n % (a + b), a)) << endl;
}

//#define FILES
//#define TIME

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

#ifdef FILES
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    auto start = chrono::high_resolution_clock::now();
    solve();
    auto stop = chrono::high_resolution_clock::now();

#ifdef TIME
    cerr << chrono::duration_cast <chrono::milliseconds> (stop - start).count() << " ms\n";
#endif
    return 0;
}

Measured memory_bytes: 256
n= int(input())
a= list(map(int,input().split()))
maxa,mina=max(a),min(a)
if maxa==mina:print(0)
else:
    gmin=9999999
    for c in range(mina,maxa+1):gmin=min(gmin,sum([(c-b)*(c-b) for b in a]))
    print(gmin)

Measured memory_bytes: 3060
def mat_dot(one, two, mod):
	return [[sum([(one[i][k]*two[k][j])%mod for k in range(len(two))])%mod for j in range(len(two[0]))] for i in range(len(one))]

def mat_pow(mat, exp, mod):
	size = len(mat)
	res = [[0 for _ in range(size)] for _ in range(size)]
	for i in range(size):
		res[i][i] = 1
	cnt = 0
	while (1<<cnt) <= exp:
		if (exp>>cnt)&1:
			res = mat_dot(res, mat, mod)
		mat = mat_dot(mat, mat, mod)
		cnt += 1
	return res

l, a, b, m = map(int, input().split())
c = a + (l-1)*b
n = len(str(c))
dgt = [0 for _ in range(n+1)]
for i in range(1, n):
	dgt[i] = max(0, (10**i -a+b-1) // b) - max(0, (10**(i-1) -a+b-1) // b)
dgt[n] = l-sum(dgt)
d_sum = [0 for _ in range(n+1)]
for i in range(n-1, 0, -1):
	d_sum[i] = d_sum[i+1] + dgt[i+1]*(i+1)
fr = [0 for _ in range(n+1)]
fr[1] = a
for i in range(2, n+1):
	fr[i] = fr[i-1] + b*dgt[i-1]
l = [[0, a%m, 1]]
for d in range(1, n+1):
	k = [[(10**d)%m, 0, 0], [1, 1, 0], [0, b%m, 1]]
	j = mat_pow(k, dgt[d], m)
	l = mat_dot(l, j, m)

print(l[0][0]%m)

Measured memory_bytes: 3192
#include<algorithm>
#include<complex>
#include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

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

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;

const D EPS = 1e-8;

int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}

P cr[21], d;
int n;
D dis[21][21], limit[20];

bool solve(int bit, int p, D t) {
  if (bit == 0) return true;
  rep (i, n) if (bit & 1 << i) {
    rep (j, n) if (bit & 1 << j) {
      if (sig(t + dis[p][i] + dis[i][j], limit[j]) >= 0) goto next;
    }
    if (solve(bit ^ 1 << i, i, t + dis[p][i])) return true;
  next:;
  }
  return false;
}

int main() {
  while (true) {
    cin >> n;
    cin  >> cr[n].X >> cr[n].Y >> d.X >> d.Y;
    if (n == 0) break;
    rep (i, n) cin >> cr[i].X >> cr[i].Y;
    rep (i, n + 1) rep (j, n + 1) dis[i][j] = abs(cr[i] - cr[j]);
    rep (i, n) limit[i] = abs(cr[i] - d);
    cout << (solve((1 << n) - 1, n, 0) ? "YES" : "NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
n, m = gets.split.map(&:to_i)

na = Array.new(31, 0)

n.times.each {|i|
    ka = gets.split.map(&:to_i)
    k = ka[0]
    a = ka[1..ka.length-1]
    a.each{|j|
        na[j] += 1
    }
}
puts na.select{|i|i==n}.count


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int N; cin >> N;
	int x; cin >> x;
	vector<int> a;
	for (int i = 0; i < N; i++) {
		int pt; cin >> pt;
		a.push_back(pt);
	}
	sort(a.begin(), a.end());
	int sc = 0;
	while (a.size()>0) {
		if (a.front() <= x) {
			x -= a.front();
			a.erase(a.begin());
			sc++;
		}
		else {
			break;
		}
	}
	if (a.size() == 0 && x > 0)sc--;
	cout << sc << endl;





	return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int ans;
string s, t;

int main() {
	cin >> N >> s >> t;
	int sl = s.size();

	ans = N * 2;

	for (int j = 1; j <= N; ++j) {
		bool ok = 1;

		for (int k = 0; k < j; ++k) {
			if (s[N-j+k] != t[k]) {
				ok = 0;
				break;
			}
		}

		if (ok) {
			ans = min(ans, N*2 - j);
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n,k;
    cin >> n >> k;
    vector<int>hito(n,0);
    for(int i=0;i<k;i++){
        int d;
        cin >> d;
        for(int j=0;j<d;j++){
            int z;
            cin >> z;
            z--;
            hito.at(z)++;
        }
    }
    int ans =0;
    for(int i=0;i<n;i++){
        if(hito.at(i)==0)ans++;
    }
    cout << ans << endl;
}
    



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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = 0;
		
		boolean[] exits = new boolean[100];
		Arrays.fill(exits, false);
		for (int i = a; i < b; i++){
			exits[i] = true;
		}
		for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		scanner.close();
	}
}

Measured memory_bytes: 23124
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[MAX];

int H[MAX],D[MAX];

void depth(int , int);

int height(int);

int sibling(int);

void print(int);

int main(){
  int v,l,r,root=0;
  int num,i,j;
  

  scanf("%d",&num);

  for(i=0;i<num;i++) T[i].parent = NIL;

  for(i=0;i<num;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }


  for(i=0;i<num;i++) if(T[i].parent == NIL) root = i;

  depth(root,0);
  height(root);

  for(i=0;i<num;i++) print(i);

  return 0;

}

void depth (int x,int y){
  if(x == NIL) return;
  D[x] = y;
  depth (T[x].left,y+1);
  depth (T[x].right,y+1);
}

int height(int u)
{
  int h1=0;
  int h2=0;
  int value;

  if(T[u].left != NIL) h1 = height(T[u].left) + 1;
  if(T[u].right != NIL) h2 = height(T[u].right) + 1;

  if(h1 > h2) value = h1;
  else value = h2;
  return H[u] = value;
}

int sibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u &&T[T[u].parent].left != NIL){
    return T[T[u].parent].left;
  }

  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
    return T[T[u].parent].right;
  }

  return NIL;

}

void print(int u)
{

  int degree=0;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",sibling(u));

  if(T[u].left != NIL) degree++;
  if(T[u].right != NIL) degree++;
  printf("degree = %d, ",degree);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }

  else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }
  else printf("internal node\n");
}
  



Measured memory_bytes: 2716
l = []
for i in range(3):
    c1,c2,c3 = map(int, input().split())
    l.append([c1,c2,c3])

# assign a1 as 0
b1 = l[0][0]
b2 = l[1][0]
b3 = l[2][0]

flag = 0
for i in range(3):
    if not (l[0][1]-b1 == l[1][1]-b2 == l[2][1]-b3):
        flag = 1
    if not (l[0][2]-b1 == l[1][2]-b2 == l[2][2]-b3):
        flag = 1
if flag == 1:
    print('No' , flush=True)
else:
    print('Yes' , flush=True)

# TLE
# l = []
# for i in range(3):
#     c1,c2,c3 = map(int, input().split())
#     l.append([c1,c2,c3])

# def check_sum(i,j):
#     for r in range(3):
#         if r == i:
#             continue;
#         for c in range(3):
#             if c == j:
#                 continue;
#             sum_a = l[i][j] + l[r][c]
#             sum_b = l[r][j] + l[i][c]
#             if sum_a == sum_b:
#                 return 1
#             else:
#                 return -1
#                 break;

# for i in range(3):
#     for j in range(3):
#         flag = check_sum(i, j)
#         if flag == -1:
#             break;

# if flag == 1:
#     print('Yes' , flush=True)
# else:
#     print('No' , flush=True)


Measured memory_bytes: 9204
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
const int MAX = 5000;
ll fac[MAX], finv[MAX], inv[MAX];
ll rui[MAX][MAX];
ll p;
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % p;
        inv[i] = p - inv[p%i] * (p/i) % p;
        finv[i] = finv[i-1] * inv[i] % p;
    }
	rep(i,p){
		rui[i][0]=1;
		rep(j,p-1){
			rui[i][j+1]=rui[i][j]*i%p;
		}
	}
}
long long COM(int n,int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % p) % p;
}
int main(){
	ll a[5001];
	ll b[5001]={};
	scan(p);
	COMinit();
	rep(i,p){
		scan(a[i]);
		if(a[i]){
			rep(j,p){
				int hugo=(p-j-1)%2*2-1;
				b[j]+=hugo*COM(p-1,j)*rui[i][p-j-1]%p;
				if(j==0) b[j]+=1;
				b[j]%=p;
				if(b[j]<0) b[j]+=p;
			}
		}
	}
	rep(i,p) printf("%lld ",b[i]);
	kaigyo;
	return 0;
}


Measured memory_bytes: 118656
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	int n;
	cin>>n;
	int f=0;
	while(n){
		if(n%10==7) f=1;
		n=n/10;
	}
	cout<<(f?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int charToInt(char c)
{
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main()
{
    int N, T;
    cin >> N >> T;
    vector<int> A(N+1), B(N+1);
    rep(i, N)
    {
        cin >> A.at(i+1) >> B.at(i+1);
    }

    //二つのDPを考える
    int DP1[N + 2][T + 1], DP2[N + 2][T + 1];
    rep(i, N + 2)
    {
        rep(j, T + 1)
        {
            DP1[i][j] = 0;
            DP2[i][j] = 0;
        }
    }

    //DP1[i][j]は1~i番目までの料理を使って、j分までに食べられる最大の点数
    for(int i=1;i<N+1;i++){
        //i番目の料理を食べる場合のスコア: DP[i][j] = DP[i-1][j-A[i]]+B[i]
        //i番目の料理を食べない場合のスコア: DP[i][j] = DP[i-1][j]
        for(int j=0;j<T+1;j++){
        if(j>=A[i]){
            DP1[i][j] = max(DP1[i-1][j], DP1[i-1][j-A[i]]+B[i]);
        }else{
            DP1[i][j] = DP1[i-1][j];
        }
      }
    }

    //DP2[i][j]はi~N番目までの料理を使って、j分までに食べられる最大の点数
    for(int i=N;i>0;i--){
        //i番目の料理を食べる場合のスコア: DP[i][j] = DP[i-1][j-A[i]]+B[i]
        //i番目の料理を食べない場合のスコア: DP[i][j] = DP[i-1][j]
        for(int j=0;j<T+1;j++){
        if(j>=A[i]){
            DP2[i][j] = max(DP2[i+1][j], DP2[i+1][j-A[i]]+B[i]);
        }else{
            DP2[i][j] = DP2[i+1][j];
        }
      }
    }
    for(int i=0;i<N+1;i++){
        for(int j=0;j<T;j++){
            //cout<<i<<" "<<j<<" "<<DP1[i][j]<<endl;
        }
    }

    int max_score = 0;
    for(int i=1;i<N+1;i++){
        //i番目のやつを最後に持ってくるときに、それ以外のやつでT-1分の間に食べられる料理のスコアの最大値を求めればよい
        for(int j=0;j<T;j++){
            //i-1までのやつをj分、i+1以降の奴をT-1-j分使って食べるときの最大値を求める
            if(max_score<DP1[i-1][j]+DP2[i+1][T-1-j]+B[i]){
                max_score = DP1[i-1][j]+DP2[i+1][T-1-j]+B[i];
            }
        }
    }

    cout << max_score << endl;

    return 0;
}

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

#define ll long long
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
pair<ll,ll>A[10000000] = {}, X[1000000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = INFL, b = 0, c = 0, n = 0, sum = 0, max = INF;
str S;
ll ans = 0;

int findDigits(int n) {
	int i = 0;
	while (n > 0) {

		sum += n % 10;
		n /= 10;
		i++;
	}
	return i;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n >> a >> S;
	a--;
	if (S[a] == 'A')S[a] = 'a';
	if (S[a] == 'B')S[a] = 'b';
	if (S[a] == 'C')S[a] = 'c';
	cout << S;
	
	//Code Line
	return 0;
}


Measured memory_bytes: 172160