akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
int main()
{
    l n ; 
    cin>>n;
    vector<vector<l> > v(n+1);
    l t = n;
    if(n%2==1)
    t = n-1;
    l left = 1;
    l right = t;
    l count = 0;
    while(left<right)
    {
        for(l i = left+1; i<right ; i++)
        {
            v[left].push_back(i);
            //v[i].push_back(left);
            count++;
        }
        for(l j = right-1 ; j>left ; j--)
        {
            v[j].push_back(right);
            //v[right].push_back(j);
            count++;
        }
        left++;
        right--;
    }
    if(n%2==1)
    {
        for(l i = 1 ; i<n ; i++)
        {
            v[i].push_back(n);
            //v[n].push_back(i);
            count++;
        }
    }
    cout<<count<<endl;

    for(l i = 1 ; i<=n ; i++)
    {
        for(l j =  0 ; j<v[i].size() ; j++)
        cout<<i<<" "<<v[i][j]<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

const inf = int(1e9)

func nextperm(p []int) bool {
	i := len(p) - 1
	for i > 0 && p[i-1] > p[i] {
		i--
	}
	if i == 0 {
		return false
	}
	i--
	j := len(p) - 1
	for p[j] < p[i] {
		j--
	}
	p[i], p[j] = p[j], p[i]
	i, j = i+1, len(p)-1
	for i < j {
		p[i], p[j] = p[j], p[i]
		i, j = i+1, j-1
	}
	return true
}

func main() {
	var N, M, R int
	fmt.Scan(&N, &M, &R)
	G := make([][]int, N)
	for i := range G {
		G[i] = make([]int, N)
		for j := range G[i] {
			if i != j {
				G[i][j] = inf
			}
		}
	}
	r := make([]int, R)
	for i := range r {
		fmt.Scan(&r[i])
		r[i]--
	}
	for i := 0; i < M; i++ {
		var A, B, C int
		fmt.Scan(&A, &B, &C)
		A--
		B--
		G[A][B] = min(G[A][B], C)
		G[B][A] = min(G[B][A], C)
	}
	// ワーシャルフロイド法で全点間の最短経路を計算する
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				G[i][j] = min(G[i][j], G[i][k]+G[k][j])
			}
		}
	}
	// 指定された街のめぐりかたを全列挙して最小距離を求める
	sort.Ints(r)
	ans := inf
	for {
		cost := 0
		for j := 0; j+1 < R; j++ {
			cost += G[r[j]][r[j+1]]
		}
		ans = min(ans, cost)
		if !nextperm(r) {
			break
		}
	}
	fmt.Println(ans)
}

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


Measured memory_bytes: 2688
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());

		String N = st.nextToken();
		int iN = parseInt(N);
		String[] out = {"0","1","2","4","6","8","9"};
		int count =0;

		int inc = 2;
		label :for(int i=357;i<=iN;i+=inc) {
			String si = String.valueOf(i);
//			System.out.println("文字列 :" + si);
			for(int k=0;k<out.length;k++) {
				if(si.contains(out[k])) {
//					System.out.println("だめ変換まえ:" + i);
					int index = si.indexOf(out[k]);
					int pl = (int)Math.pow((double)10, (double)(si.length()-1 - index));
					i +=  pl;
					i = (int) (Math.floor(i /pl) * pl) -inc;
//					System.out.println("だめ変換後 :" + i);
					continue label;
				}
			}
			if(!(si.contains("7") && si.contains("5") && si.contains("3"))) {
				continue;
			}
//			System.out.println("ans : " +i);
			count ++;
		}
		System.out.println(count);


	}


}


Measured memory_bytes: 39376
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define yn(i) ((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n,k; cin >>n >>k;
  vector<li> a(n);
  rep(i,n) cin >>a[i];
  rep(i,n-k){
    print(yn(a[i+k]>a[i]));
  }
}


Measured memory_bytes: 4832
n=int(input())
s=input()
r=s.count('R')
g=s.count('G')
b=s.count('B')
ans=r*g*b

for i in range(n-2):
    for j in range(i+1 , n-1):
        k=2*j-i
        if k <= n-1:
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                ans-=1
print(ans)

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

int main() {
	int N, M; cin >> N;
	vector<string> A(N);
	for( string &k : A ) cin >> k;
	cin >> M;
	
	string B;
	for( int i = 0; i < M; i++ ){
		B.clear();
		cin >> B;
		auto itr = find(A.begin(),A.end(),B);
		if( itr != A.end() )
		A.erase(itr);
	}
	
	sort(A.begin(), A.end());
	
	int ans = 0, ren = 1;
	N = A.size();
	for( int i = 0; i < N-1; i++ ){
		if( A[i] == A[i+1] ){
			ren++;
		} else {
			ren = 1;
		}
		ans = max(ans, ren);
	}
	
	if( N == 1 ){cout << 1 << endl; return 0;}
	
	cout << ans << endl;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,count=0,a=0,k;
  bool flag=false;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  while(a<n){
    k=a;
    
    while(v[k]>0 && k<n){
      v[k]--;
      k++;
      flag=true;
    }
    if(flag){
      count++;
      flag=false;
    }
    
    if(v[a]==0){
      a++;
    }
  }
  cout<<count<<endl;
  
  
}
///////////////////////////




Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <set>
using namespace std;

int main(){
	int n;
	set<int> ansset;
	while (cin >> n, !cin.eof()){
		ansset.clear();
		for (int i = 9; i >= 0; i--){
			int hundou = pow(2, i);
			if (n >= hundou){
				ansset.insert(hundou);
				n -= hundou;
			}
		}
		// output
		set<int>::iterator it = ansset.begin();
		while (it != ansset.end()){
			cout << *it;
			++it;
			if (it != ansset.end())	
				cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 1000000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//edge cases when n=1 , m=1. wrong variable in loop. if<->while;merge resize;LLONG_MAX
signed main()
{
	speed
	//global var
	int w,h,x,y;cin>>w>>h>>x>>y;
	int tmp=w*h;
	cout<<tmp/2.0<<" ";
	if(2*x==w and 2*y==h){
		cout<<1;
	}
	else{
		cout<<0;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int h1,m1,h2,m2,k;
  int min;

  scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
  min = (h2-h1)*60+m2-m1;

  if(min<k){
    printf("0");
  }
  else{
    printf("%d",min-k);
  }
}

Measured memory_bytes: 1732
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };


string S;

ll vis[40];
int main() {

	cin >> S;

	rep(i, S.size()) {
		vis[S[i] - 'a'] = 1;

	}

	char s;
	S.push_back('a' - 1);


	for (int i = S.size()-1; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			if (vis[j] == 0 && S[i] - 'a' < j) {
				s = j + 'a';
				for (int k = 0; k < i; k++) {
					cout << S[k];
				}
				cout << s << endl;
				return 0;
			}
		}

		if (S[i] >= 'a') {
			vis[S[i] - 'a'] = 0;
		}
	}
	

	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(int argc, char *argv[])
{
  int n;
  std::vector<int> a, b, c;
  std::cin >> n;
  for (int i = 0; i < n; i++)
  {
    int a_i;
    std::cin >> a_i;
    a.push_back(a_i);
  }
  for (int i = 0; i < n; i++)
  {
    int b_i;
    std::cin >> b_i;
    b.push_back(b_i);
  }
  for (int i = 0; i < n - 1; i++)
  {
    int c_i;
    std::cin >> c_i;
    c.push_back(c_i);
  }

  int sum(0);
  for (int i = 0; i < n - 1; i++)
  {
    sum += b[a[i] - 1];
    if (a[i + 1] - a[i] == 1)
    {
      sum += c[a[i] - 1];
    }
  }
  sum += b[a[n - 1] - 1];
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import defaultdict as dd    
n=int(input())
l=list(map(float,input().split()))
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(n+1):
        if(j==0):
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])
        else:
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])+dp[i-1][j-1]*l[i-1]
ans=0
for i in range(n//2+1,n+1):
    ans+=dp[n][i]
print(ans)

Measured memory_bytes: 259720
puts Array.new(gets.to_i) { gets.chomp.split("").sort.each_with_object({}) { |s, h| h.key?(s) ? (h[s] += 1) : (h[s] = 1) } }
          .reduce { |a, b| a.each { |k, v| a[k] = v < b[k].to_i ? v : b[k].to_i } }
          .each_with_object("") { |(k, v), str| str << k * v }

Measured memory_bytes: 1916
def f(l,s):
	c=0
	for i in range(len(l)):
		if l[i]==s[i]:
			c+=1
	return len(l)-c

t=input()
sub=input()
n=len(t)
m=len(sub)
c=m
for i in range(0,n-m):
	c=min(c,f(t[i:i+m],sub))
if n==m:
	c=f(sub,t)
print(c)

Measured memory_bytes: 9104
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var InputList = System.Console.ReadLine().Split(' ');
            var A = int.Parse(InputList[0]);
            var B = int.Parse(InputList[1]);

            var result = GetLarge(Add(A,B), GetLarge(Sub(A,B),Mul(A,B)));
            System.Console.WriteLine(result);
        }

        static int Add(int num1, int num2)
        {
            return num1 + num2;
        }

        static int Sub(int num1, int num2)
        {
            return num1 - num2;
        }
        static int Mul(int num1, int num2)
        {
            return num1 * num2;
        }
        static int GetLarge(int num1,int num2)
        {
            return (num1 >= num2) ? num1 : num2;
        }



    }
}



Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main() {
  long long n, m, x, y;
  cin >> n >> m;
  vector<long long> a(m), b(m);
  for(int i = 0; i < m; ++i){
    cin >> a[i];
    cin >> x;
    for(int j = 0; j < x; ++j){
      cin >> y;
      y--;
      b[i] |= 1 << y;
    }
  }
  long long nn = 1 << n;
  vector<long long> d(nn, 1e9);
  d[0] = 0;
  for(int i = 0; i < nn; ++i){
    if(d[i] == 1e9) continue;
    for(int j = 0; j < m; ++j){
      long long ii = i | b[j];
      d[ii] = min(d[ii], d[i] + a[j]);
    }
  }
  cout << (d[nn - 1] == 1e9? -1: d[nn - 1]);
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main(){

	int n, k;
	cin >> n >> k;

	string s;
	cin >> s;

	int m=1;
	for(int i=1; i<n; i++){
		if(s[i-1]!=s[i]) m++;
	}

	//cout << m << endl;

	if(m%2==0){
		if(0<m-2*k) cout << n-(m-2*k) << endl;
		else cout << n-1 << endl;
	}else{
		if(1<m-2*k) cout << n-(m-2*k) << endl;
		else if(0==m-2*k) cout << n-2 << endl;
		else cout << n-1 << endl;
	}

	return 0;

}




Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
S = readline().decode("utf-8").rstrip()

left_cnt = 0
right_cnt = 0
for c in S:
    if '(' == c:
        left_cnt += 1
    elif left_cnt == 0:
        right_cnt += 1
    else:
        left_cnt -= 1

print('(' * right_cnt + S + ')' * left_cnt)


Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;


    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    util::get::<usize>();

    let s: Vec<char> = {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let mut l: isize = 0;
    let mut r: isize = 0;

    for &c in s.iter() {
        if c == '(' {
            l += 1;
        } else {
            if l > 0 {
                l -= 1;
            } else {
                r += 1;
            }
        }
    }

    let prefix: String = (0..r).map(|_| '(').collect();
    let suffix: String = (0..l).map(|_| ')').collect();

    println!("{}{}{}", prefix, s.into_iter().collect::<String>(), suffix);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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

vector<string> s(60);
vector<vector<int> > d(60, vector<int>(60, -1));

int h, w;

int bfs(void){
  int gx = w - 1;
  int gy = h - 1;
  queue<pair<int, int> > que;

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

  que.push(make_pair(0, 0));

  d[0][0] = 0;

  while(que.size()) {
    pair<int, int> p = que.front(); que.pop();
    if(p.first == gx && p.second == gy) break;
    for(int i = 0; i < 4; ++i){
      int nx = p.first + dx[i], ny = p.second + dy[i];

      if(nx >= 0 && nx < w && ny >= 0 && ny < h && d[ny][nx] == -1 && s[ny][nx] == '.'){
        que.push(make_pair(nx, ny));
        d[ny][nx] = d[p.second][p.first] + 1;

      }
    }
  }

  return d[gy][gx];
}

int main(){


  cin >> h >> w;

  rep(i, h) cin >> s[i];

  int ans = bfs();
  int count = 0;
  if(ans == -1) cout << -1 << endl;
  else {
    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
        if(s[i][j] == '.') ++count;
      }
    }
    ans++;

    cout << count - ans << endl;
  }



}


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

using namespace std;

typedef long long int ll ;  

#define pb push_back

ll sum = 0 ;

int a[100001]={0};

int main() {
    ll x , n , m , rd , ans=0 ; 
    
    vector<ll> v ;
    
    cin>>n>>x>>m;
    
    if((x*x)==x){ cout<<n*x ; return 0 ; }
    
    rd=x ;
    
    while(!a[rd])
    {
        a[rd] = 1 , v.pb(rd) ;
        rd=(rd*rd);
        rd%=m ;
    }
    
    ll len = v.size() ;
    
    vector<ll>::iterator it ;
    
    it=find(v.begin(),v.end(),rd) ;
    
    vector<ll> v1 ;
    
    ll sum = 0 , dist = it-v.begin() ;
    
    for(int i = 0 ;i<v.size();i++){
        v[i]=(sum+=v[i]) ;
    }
    ll y ;
    
    if(dist-1<0) y=0 ;
    
    else y = v[dist-1] ;
    
    for(;it!=v.end();it++) v1.pb(*it-y) ;
    
    ll len2 = v1.size() ;
    
    if(n<=len) cout << v[n-1] ;
    
    else
    {
        //cout<<sum<<endl ;
        ans+=sum ;
        n-=len ;
        //cout<<n<<endl ;
        ans+=((n/len2)*(sum-y)) ;
        if((n%len2)!=0)ans+=v1[(n%len2)-1] ;
        cout<<ans ;
    }
}


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

int main() {
  int Q=2019,x=1;
  string S;
  cin>>S;
  reverse(S.begin(), S.end());
  int N=S.size();
  vector<int> p(N+1);
  for(int i=0;i<N;i++){
    int a;
    if(S.at(i)=='0'){
      a=0;
    }
    if(S.at(i)=='1'){
      a=1;
    }
    if(S.at(i)=='2'){
      a=2;
    }
    if(S.at(i)=='3'){
      a=3;
    }
    if(S.at(i)=='4'){
      a=4;
    }
    if(S.at(i)=='5'){
      a=5;
    }
    if(S.at(i)=='6'){
      a=6;
    }
    if(S.at(i)=='7'){
      a=7;
    }
    if(S.at(i)=='8'){
      a=8;
    }
    if(S.at(i)=='9'){
      a=9;
    }
    p.at(i+1)=(p.at(i)+a*x)%2019;
    x=(x*10)%2019;
  }
  sort(p.begin(), p.end());
  int64_t A=1,Z=0;
  for(int i=0;i<N;i++){
    if(p.at(i)==p.at(i+1)){
      A++;
    }
       else{
         Z+=A*(A-1)/2;
         A=1;
       }
       }
  Z+=A*(A-1)/2;
  cout<<Z<<endl;
}




Measured memory_bytes: 4260
#include <iostream>
using namespace std;
int main()
{
    long long int x, points;
    cin >> x;

    long long int a = x/500;
    points = a*1000;
    x = x-a*500;
    a = x/5;
    points = points + a*5;
    cout << points << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n, k;
    cin >> n >> k;
    cout << min(n % k, k - n % k) << endl;
}

Measured memory_bytes: 256
S = input()
cnt = S[2:-1].count('C')
 
for s in S[1:]:
    if s.isupper() and s != 'C':
        print('WA')
        break
else:
    if S[0] == 'A' and cnt == 1:
        print('AC')
    else:
        print('WA')

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int p[10];
	int q[10];
	int sum = 0;
	int sum2 = 0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> q[i];
	}
	int ans=1;
	int a = n;
	while (a != 0) {
		ans *= a;
		a--;
	}
	
	for (int i = 0; i < n; i++) {
		int count = 0,count2 = 0;
		for (int j = 0; j < i; j++) {
			if (p[j] < p[i]) {
				count++;
			}
			if (q[j] < q[i]) {
				count2++;
			}
		}
		ans = ans / (n - i);
		int kai = p[i] - 1 - count;
		int kai2 = q[i] - 1 - count2;
		if (kai< 0) {
			kai = 1;
		}
		if (kai2 < 0) {
			kai2 = 1;
		}
		
		sum += kai* ans;
		sum2+= kai2 * ans;
		
	}
	
	cout << abs(sum - sum2) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    A, B = MI()
    for i in range(1009):
        if int(i*0.08) == A and int(i*0.1) == B: print(i); sys.exit()
    print(-1)
if __name__ == '__main__':
    main()

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

int main() {
  string S;
  cin >> S;
  int l = S.size() - 2;
  string L;
  
  if (l < 10) {
    if (l == 1 ) L = "1";
    if (l == 2 ) L = "2";
    if (l == 3 ) L = "3";
    if (l == 4 ) L = "4";
    if (l == 5 ) L = "5";
    if (l == 6 ) L = "6";
    if (l == 7 ) L = "7";
    if (l == 8 ) L = "8";
    if (l == 9 ) L = "9";
  }
  
  else {
    if (l / 10 == 1 ) L = "1";
    if (l / 10 == 2 ) L = "2";
    if (l / 10 == 3 ) L = "3";
    if (l / 10 == 4 ) L = "4";
    if (l / 10 == 5 ) L = "5";
    if (l / 10 == 6 ) L = "6";
    if (l / 10 == 7 ) L = "7";
    if (l / 10 == 8 ) L = "8";
    if (l / 10 == 9 ) L = "9";
    
    if (l % 10 == 1 ) L += "1";
    if (l % 10 == 2 ) L += "2";
    if (l % 10 == 3 ) L += "3";
    if (l % 10 == 4 ) L += "4";
    if (l % 10 == 5 ) L += "5";
    if (l % 10 == 6 ) L += "6";
    if (l % 10 == 7 ) L += "7";
    if (l % 10 == 8 ) L += "8";
    if (l % 10 == 9 ) L += "9";
    if (l % 10 == 0 ) L += "0";
  }
  
  cout << S.at(0) + L + S.at(S.size() - 1) << endl;
  
}


Measured memory_bytes: 256
from collections import defaultdict
H,W,N=map(int,input().split())

ans=[(H-2)*(W-2)]+[0]*9
blacks=defaultdict(int)
for i in range(N):
  a, b = map(int,input().split())
  for dx in [-1,0,1]:
    for dy in [-1,0,1]:
      if 2<=a+dx<H and 2<=b+dy<W:
        ans[blacks[(a+dx,b+dy)]]-=1
        ans[blacks[(a+dx,b+dy)]+1]+=1
      blacks[(a+dx,b+dy)]+=1

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

Measured memory_bytes: 159688
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  string s;cin >> s;
  bool valid = true;
  int pos = 1;
  for(int i=0;i<s.size();++i){
    string sub = s.substr(i,1);
    string check = "L";
    if(pos%2 == 0) check = "R";
    if(sub == check) {
      valid = false;
      break;
    }
    ++pos;
  }
  if(valid){
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int small;
		int big;
		if (A <= B) {
			small = A;
			big = B;
		} else {
			small = B;
			big = A;
		}
		for (int i = small; i <= big; i++) {
			if (((small * i * big) % 2) != 0) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

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

int main() {
    int a,b,c; cin >> a >> b >> c;
    bool ans = false;
    if (a==b and a!=c) ans = true;
    if (b==c and b!=a) ans = true;
    if (a==c and a!=b) ans = true;
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3520
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextInt();
        long b = sc.nextInt();
        n %= 12;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                a = a - b;
            } else {
                b = a + b;
            }
        }
        System.out.println(a + " " + b);
    }
}



Measured memory_bytes: 26416
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
  int a,b,c,diff,ans;
  scanf("%d%d%d",&a,&b,&c);
  ans=b+c;
  if(a>ans)
  {
    diff=0;
  }
  else
  {
  diff=abs(a-(b+c));
  }
  printf("%d",diff);
  return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

struct Work {
    ll d, p;
    Work(ll d = 0, ll p = 0) : d(d), p(p) {}
    bool operator<(const Work& w) const { return (p != w.p ? p < w.p : d < w.d); }
};

constexpr int MOD = 1000000007;

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

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

    priority_queue<Work> q;
    rep(i, 0, n) {
        ll d, p;
        cin >> d >> p;
        q.emplace(d, p);
    }

    set<ll> sets;
    rep(i, 0, m + 1) { sets.insert(i); }

    ll ans = 0;
    while (!q.empty()) {
        Work w = q.top();
        q.pop();

        auto itr = sets.lower_bound(w.d);
        if (itr != sets.end()) {
            ans += w.p;
            sets.erase(itr);
            if (sets.empty()) { break; }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6512
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

n, m = MAP()
a = sorted(divisor(m))
print(m//a[bisect_left(a,n)])

Measured memory_bytes: 10252
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;


public class Main {
	static Scanner sc = new Scanner(System.in);
	static final double EPS = 1e-8;
	public static void main(String[] args) {
		
		while (sc.hasNextDouble()) {
			double d = sc.nextDouble();
			if (d - EPS < 48.00) {
				System.out.println("light fly");
			} else if (d > 48.00 && d - EPS < 51.00) {
				System.out.println("fly");
			} else if (d > 51.00 && d - EPS < 54.00) {
				System.out.println("bantam");
			} else if (d > 54.00 && d - EPS < 57.00) {
				System.out.println("feather");
			} else if (d > 57.00 && d - EPS < 60.00) {
				System.out.println("light");
			} else if (d > 60.00 && d - EPS < 64.00) {
				System.out.println("light welter");
			} else if (d > 64.00 && d - EPS < 69.00) {
				System.out.println("welter");
			} else if (d > 69.00 && d - EPS < 75.00) {
				System.out.println("light middle");
			} else if (d > 75.00 && d - EPS < 81.00) {
				System.out.println("middle");
			} else if (d > 81.00 && d - EPS < 91.00) {
				System.out.println("light heavy");
			} else {
				System.out.println("heavy");
			}
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define R register int 
#define ll long long
#define inf 2147483647
using namespace std;
const int N=500000;
int n,w[N];
int ans1[2],fm1[2];
int ans2[2],fm2[2];
map<int,int>J,O;
map<int,int>::iterator it;
int gi(){
    R x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x;
}
int main(){
	n=gi();
	for(R i=1;i<=n;++i)w[i]=gi();
	for(R i=1;i<=n;i+=2)J[w[i]]++;
	for(R i=2;i<=n;i+=2)O[w[i]]++;
	for(it=J.begin();it!=J.end();++it){
		R u=it->first,v=it->second;
		if(v>ans1[0]){
			ans1[1]=ans1[0],fm1[1]=fm1[0];
			ans1[0]=v,fm1[0]=u;
		}
		else if(v>ans1[1])
			ans1[1]=v,fm1[1]=u;
	}
	for(it=O.begin();it!=O.end();++it){
		R u=it->first,v=it->second;
		if(v>ans2[0]){
			ans2[1]=ans2[0],fm2[1]=fm2[0];
			ans2[0]=v,fm2[0]=u;
		}
		else if(v>ans2[1])
			ans2[1]=v,fm2[1]=u;
	}
	if(fm1[0]!=fm2[0])
		printf("%d",n-ans1[0]-ans2[0]);
	else printf("%d",n-max(ans1[0]+ans2[1],ans1[1]+ans2[0]));
	return 0;
}


Measured memory_bytes: 5376
from math import factorial

mod=1000000000+7

def C(n,k):
    N=(factorial(n))
    K=(factorial(k))
    N_K=(factorial(n - k))
    return int( ( N // K // N_K )%mod )

n,k=list(map(int, input().split()))
blue=k
red=n-k
for i in range(1,blue+1):
    if i > red+1:
        print(0)
    else:
        print( (C(red+1,i)%mod)*(C(blue-1,i-1)%mod)%mod)

Measured memory_bytes: 3316
n = input()
a = n[0]
if (n[1] <= a and n[2] < a) or (n[1] < a):
  print(a+a+a)
elif n[1] == a and n[2] == a:
  print(n)
else:
  b = str(int(a) + 1)
  print(b+b+b)


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
#define double ld
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template<class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template<class T0, class T1>
inline istream &operator>>(istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template<class T0, class T1, class T2>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template<class T0, class T1, class T2, class T3>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}

template<class T>
inline ostream &operator<<(ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int i = 1; i <= m; ++i) {
        for (int j = 10; j <= d; ++j) {
            int f = j % 10;
            int s = j / 10;
            if (min(f, s) >= 2 && f * s == i) {
                ans++;
            }
        }
    }
    cout << ans;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n, x;
    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        int cnt = 0;
        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) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }

}


Measured memory_bytes: 3012
a,b,c,x,y=map(int,input().split())
if x>y:
  ans=min(a*x+b*y,2*c*x,2*c*y+a*(x-y))
else:
  ans=min(a*x+b*y,2*c*y,2*c*x+b*(y-x))
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int count(int n) {
	int a, cnt;

	cnt = 0;
	for (a = 1; a <= n / a; a++)
		if (n % a == 0) {
			cnt++;
			if (a != n / a)
				cnt++;
		}
	return cnt;
}

int main() {
	int n, a, cnt;

	scanf("%d", &n);
	cnt = 0;
	for (a = 1; a <= n; a += 2)
		if (count(a) == 8)
			cnt++;
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};
int n,w;
vector<vector<int>> goods;
signed main () {
    cin >> n >> w;
    goods.assign(n,vector<int>());
    REP(i,n){
        int a,b;cin >> a >> b;
        goods[i]={a,b};
    }
    vector<vector<ll>> dp(n+1,vector<ll>(10001,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<=w;j++){
            if(j-goods[i][1]>=0){
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-goods[i][1]]+goods[i][0]);
            }
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
    }
    cout << *max_element(ALL(dp[n])) << endl;
}


Measured memory_bytes: 10772
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = n;
		int prev = 10;
		int count = 0;
		int max = 0;
		while (x > 0) {
			if (prev == x % 10) {
				count++;
				if (max < count) {
					max = count;
				}
			} else {
				prev = x % 10;
				count = 1;
			}
			x /= 10;
		}
		if (max >= 3) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 200005;
const LL MOD = 998244353;

LL N, C, s, t, h[MAXN], dp[MAXN];
int deq[MAXN];

bool useless(int a, int b, int c) {
	LL m1 = -2 * h[a], b1 = dp[a] + h[a] * h[a];
	LL m2 = -2 * h[b], b2 = dp[b] + h[b] * h[b];
	LL m3 = -2 * h[c], b3 = dp[c] + h[c] * h[c];
	if ((b2 - b3) / (m3 - m2) < (b1 - b2) / (m2 - m1)) return true;
	if ((b2 - b3) / (m3 - m2) > (b1 - b2) / (m2 - m1)) return false;
	return (b2 - b3) % (m3 - m2) * (m2 - m1) <= (b1 - b2) % (m2 - m1) * (m3 - m2);
}

LL f(int j, LL x) {
	return dp[j] + h[j] * h[j] - 2 * h[j] * x;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> C;
	for (int i = 1; i <= N; i++) cin >> h[i];
	
	dp[1] = 0;
	for (int i = 2; i <= N; i++) {
		while (t - s >= 2 && useless(deq[t - 2], deq[t - 1], i - 1)) t--;
		deq[t++] = i - 1;
		
		while (t - s >= 2 && f(deq[s], h[i]) >= f(deq[s + 1], h[i])) s++;
		dp[i] = f(deq[s], h[i]) + h[i] * h[i] + C;
	}
	
	cout << dp[N] << "\n";
}


Measured memory_bytes: 4224
from collections import Counter
from itertools import combinations
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
A = Counter()
for (x1, y1), (x2, y2) in combinations(XY, 2):
    A[(x1-x2, y1-y2)] += 1
if N == 1:
    print(1)
else:
    print(N - max(A.values()))   

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

int main() {
  int N;
  string S;
  int count = 0;
  cin >> N >> S;
  for(int i=0; N-2 > i; i++){
    if(S.at(i) == 'A'){
      if(S.at(i+1) == 'B'){
        if(S.at(i+2) == 'C'){
          count ++;
        }
      }
    }
  }
  cout << count << endl;
}

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

using namespace std;

typedef long long ll;

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

        int n, a = 1;
        string s;
        cin >> n >> s;
        for (int i = 1; i < n; i++)
                a += (s[i] != s[i - 1]);
        cout << a << "\n";

        return 0;
}


Measured memory_bytes: 512
n, q = [int(i) for i in input().split()]
que = []
ans_count = 0 #出力数
time = 0 #経過時間
# data読み込み
for i in range(n):
    que.append([i for i in input().split()])

while(ans_count!=n):
    pop_process = que.pop(0)
    pop_process[1] = int(pop_process[1])
    # 末尾から追加、先頭から取り出す
    if pop_process[1] <= q:
        time += pop_process[1]
        print('{0} {1}'.format(pop_process[0], time))
        ans_count += 1
    else:
        time += q
        pop_process[1] -= q
        que.append(pop_process)


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

int main(void) {
    int A,B,C,X;
    int cnt = 0;
    cin >> A >> B >> C >> X;
    for(int i=0;i<=A;i++) {
        for(int j=0;j<=B;j++) {
            for(int k=0;k<=C;k++) {
                if((500*i+100*j+50*k) == X) cnt++;
            }
        }
    }
        
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOREACH(i, v) for(auto i = v.begin(); i != v.end(); i++)
#define PRINT(n) cout << n << endl
#define P pair<int, int>

using namespace std;
using ll = long long;

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

int h, w, c = 0, cc = 1;
char s[55][55];

int bfs(int sx, int sy, int gx, int gy, int N, int M){
    int distance[h][w];
    queue<P> que;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            distance[i][j] = -1;
        }
    }
    que.push(P(sx, sy));
    distance[sx][sy] = 0;

    while(que.size()){
        P p = que.front(); que.pop();
        if(p.first == gx && p.second == gy) break;  //ゴールなら探索終了
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];    //nx, nyは移動後の点
            if(0 <= nx && nx < N && 0 <= ny && ny < M && s[nx][ny] != '#' && distance[nx][ny] == -1){
                que.push(P(nx, ny));
                distance[nx][ny] = distance[p.first][p.second] + 1;
            }
        }
    }
    return distance[gx][gy];
}

void solve(){
    int a[3], b[3], c[3][3];
    REP(i, 3) REP(j, 3) cin >> c[i][j];

    a[0] = min(c[0][0], min(c[0][1], c[0][2]));
    b[0] = c[0][0] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0]; 

    REP(i, 3){
        REP(j, 3){
            if(c[i][j] != a[i]+b[j]){
                cout << "No" << endl;
                return;
            }
        }
    }
    cout << "Yes" << endl;
}

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


Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var str1 = Console.ReadLine();
        var str2 = Console.ReadLine();
        var aa = str1.Reverse().ToArray();
        var bb = str2.ToArray();
        if (new string(str2.ToArray()) ==  new string(str1.Reverse().ToArray()))
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }

        Console.ReadLine();
    }
    

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

  
  

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 13268
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;

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


int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int res = (a*b>c*d)?a*b:c*d;
    cout << res;
    return 0;   
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut p: Vec<usize> = sc.vec(n);
    p.sort();
    let mut sum = 0;
    for i in 0..k {
        sum += p[i];
    }
    println!("{}", sum);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

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

  int counter = 0;
  int flag = 1;

  while( 1 ) {
    for( int i = 0; i < N; i++ ) {
      if( A[i] % 2 != 0 ) {
        flag = 0;
        break;
      } else {
        A[i] /= 2;
      }
    }
    if( !flag ) {
      break;
    } else {
      counter++;
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
src = list(map(int,input().split()))
es = [tuple(map(int,input().split())) for i in range(M)]

if M == N-1:
    print(0)
    exit()
if M + N//2 < N-1:
    print('Impossible')
    exit()

parent = [i for i in range(N)]
rank = [0] * N
def root(a):
    if parent[a] == a:
        return a
    else:
        parent[a] = root(parent[a])
        return parent[a]
def same(a,b):
    return root(a) == root(b)
def unite(a,b):
    ra = root(a)
    rb = root(b)
    if ra == rb: return
    if rank[ra] < rank[rb]:
        parent[ra] = rb
    else:
        parent[rb] = ra
        if rank[ra] == rank[rb]: rank[ra] += 1

for a,b in es:
    unite(a,b)
trees = {}
for i in range(N):
    root(i)
for i in range(N):
    trees[root(i)] = False

costs = []
for i,c in enumerate(src):
    costs.append((c,i))
costs.sort()

used = [False] * N
ans = used_n = 0
for c,v in costs:
    t = root(v)
    if trees[t]:
        continue
    else:
        trees[t] = used[v] = True
        used_n += 1
        ans += c

for c,v in costs:
    if used_n == 2*(N-M-1): break
    if used[v]: continue
    used_n += 1
    ans += c
print(ans)


Measured memory_bytes: 33164
import kotlin.math.*
import java.util.*

const val MOD = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val s = readLine()!!
  println(s.substring(0, 3))
}


Measured memory_bytes: 34372
n=int(input())
A=[]
for i in range(n):
    a=str(input())
    A.append(a)
import collections
c = collections.Counter(A)
ma= c.most_common()[0][1]
C=[i[0] for i in c.items() if i[1] >=ma ]
C.sort(reverse=False)
for j in range(len(C)):
    print(C[j])

Measured memory_bytes: 49504
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	string S;
	cin>>S;
	
	cout<<S.substr(0,S.size()-8)<<endl;
	
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    while(cin >> n, n)
    {
        int dp[305][305] = {};
        vector<int> w(n);

        for(auto& _w : w)
        {
            cin >> _w;
        }

        for(int b = 2; b <= n; b++)
        for(int l = 0; l < n; l++)
        {
            int r = l + b - 1;
                if( r >= n )continue;


                if( abs(w[l] - w[r]) <= 1 && dp[l + 1][r - 1] == r - l - 1)
                {
                    dp[l][r] = r - l + 1;
                }

                for(int k = l; k < r; k++)                
                {
                    dp[l][r] = max( dp[l][r], dp[l][k] + dp[k + 1][r] );
                }
        }
        
        cout << dp[0][n - 1] << endl;

    }

    return 0;
}

Measured memory_bytes: 3436