akhauriyash/Code-Regression huggingface dataset:
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

int main()
{
    optimizeIO();

    LL a;
    cin>>a;

    cout<<a+a*a+a*a*a<<endl;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 3648
#include <iostream>

using namespace std;

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

  for (int ttId = 0; ttId <= N; ttId++)
    for (int ftId = 0; ftId <= N; ftId++)
    {
      int otId = N - (ttId + ftId);
      if (otId < 0) continue;

      if (ttId * 10000 + ftId * 5000 + otId * 1000 == Y)
      {
        cout << ttId << " " << ftId << " " << otId << endl;
        return 0;
      }
    }

  std::cout << "-1 -1 -1" << endl; 
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int ct = 0;
    while(true) {
        sort(a, a+3);
        if(a[0]==a[2]) break;
        ct++;
        if(a[0]==a[1]) {
            a[0]++;
            a[1]++;
        } else {
            a[0] += 2;
        }
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


ll searchMax(ll c[], ll sd[], ll picked[]){
    ll max = -1;
    ll maxP = -1;
    REP(i, 26){
        if(max < sd[i]){
            max = sd[i];
            maxP = i;
        }
    }

    return maxP;
}

int main(){
    // input
    ll D;
    cin >> D;

    ll c[27];
    ll s[D + 1][27];
    REP(i, 26){
        cin >> c[i];
    }
    REP(i, D){
        REP(j, 26){
            cin >> s[i][j];
        }
    }

    // preparation
    ll t[D + 1];
    ll picked[27];

    // main
    REP(i, D){
        t[i] = searchMax(c, s[i], picked);
        picked[t[i]] = 1;
    }

    // output
    REP(i, D){
        cout << t[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int r;
    cin >> r;
    
    cout << 3 * r * r << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Main me = new Main();
		System.out.println(me.fact(Integer.parseInt(in.readLine())));
	}
	private long fact(long n){
		if(n==0)
			return 1;
		else
			return n*fact(n-1);
	}
}

Measured memory_bytes: 16852
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    string s ;
    cin >> s ;
    int a[26] ;
    fill(a , a+26 , 0) ;
    for(int i = 0 ; i < s.length() ; i++ ){
        a[s[i]-65]++ ;
    }
    int cnt = 0 ;
    for(int i = 0 ; i < 26 ; i++){
        if(a[i] == 2)cnt++ ;
    }
    if(cnt==2)cout << "Yes" ;
    else cout << "No" ;

























return 0 ;
}


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    static final int MAX_PRICE = 1000000000;
    static final int MIN_PRICE = 1;

    public static void main(String[] args) {
        // 標準入力の読み込み開始
        Scanner scanner = new Scanner(System.in);

        // 価格の数
        int n = scanner.nextInt();

        // 価格のリスト
        List<Integer> priceList = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            priceList.add(scanner.nextInt());
        }

        // 標準入力の読み込み終了
        scanner.close();

        // 処理実行
        System.out.println(getMaxProfit(priceList, MIN_PRICE - MAX_PRICE, -1));
    }

    static int getMaxProfit(List<Integer> priceList, int tempMaxProfit, int index_prevMax) {
        // 終了条件
        if (index_prevMax + 1 == priceList.size()) {
            // リストの最後まで検索した場合、これまでの最大値を返して処理終了
            return tempMaxProfit;
        }

        // 引数index_prevMax以降の最大値取得
        int max_index = getMaxIndexInArrayList(priceList, index_prevMax + 1, priceList.size());
        int max_price = priceList.get(max_index);

        // (引数index_prevMax以降、)最大値以前で最小値取得(初回実行の場合はindex_prevMax=0として実行)
        int min_index_before = getMinIndexInArrayList(priceList, ((index_prevMax == -1)? 0: index_prevMax), max_index);
        if (min_index_before == -1) {
            // 最大値以前で最小値が取得できない(最大値=最小値)場合
            // 以降の処理は不要なのでさっさと再実行
            return getMaxProfit(priceList, tempMaxProfit, max_index);
        }
        int min_price_before = priceList.get(min_index_before);

        // 最大値以降(、リストの最後まで)で最小値取得
        int min_price_after = priceList.get(getMinIndexInArrayList(priceList, max_index, priceList.size()));

        // 引数tempMaxProfitを再設定
        if((max_price - min_price_before) > tempMaxProfit) {
            tempMaxProfit = max_price - min_price_before;
        }

        // 最大値以前の最小値のほうが小さい場合
        if (min_price_before <= min_price_after) {
            // 処理終了
            return tempMaxProfit;
        }

        // 再実行
        return getMaxProfit(priceList, tempMaxProfit, max_index);
    }

    // リストから最大値のインデックスを取得する
    static int getMaxIndexInArrayList(List<Integer> priceList, int index_start, int index_end) {
        int max_price = MIN_PRICE - 1;
        int max_index = -1;

        for (int i = index_start; i < index_end; i++) {
            if (priceList.get(i) > max_price) {
                max_price = priceList.get(i);
                max_index = i;
            }
        }

        return max_index;
    }

    // リストから最小値のインデックスを取得する
    static int getMinIndexInArrayList(List<Integer> priceList, int index_start, int index_end) {
        int min_price = MAX_PRICE + 1;
        int min_index = -1;

        for (int i = index_start; i < index_end; i++) {
            if (priceList.get(i) < min_price) {
                min_price = priceList.get(i);
                min_index = i;
            }
        }

        return min_index;
    }
}



Measured memory_bytes: 105756
N,M = map(int,input().split())

wa_count = { i+1: 0 for i in range(N) }
ac_count = { i+1: False for i in range(N) }
wa,ac = 0,0

for _ in range(M):
  p,s = map(str,input().split())
  p = int(p)
  if s == "AC" and not ac_count[p]:
    ac += 1
    wa += wa_count[p]
    ac_count[p] = True
  else:
    wa_count[p] += 1

print(ac, wa)

Measured memory_bytes: 64484
# -*- coding: utf-8 -*-

n = input()
s = raw_input()
cnt = 0
flg = 1
while(flg):
    for i in range(len(s)):
        if(s[i] == '('):
            cnt += 1
        elif(s[i] == ')'):
            cnt -= 1
            if(cnt<0):
                s = '('+s
                cnt = 0
                break
        if(i==len(s)-1):
            flg = 0
for i in range(cnt):
    s = s+')'
print(s)

Measured memory_bytes: 2568
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define ll long long 
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
using namespace std;
using namespace std::chrono;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int h,w;
	cin>>h>>w;
	string s[h];
	in(h)
	{
		cin>>s[i];
	}
	int dp[h][w]={0};
	memset(dp,0,sizeof(dp));
	// in(h)
	// {
	// 	inj(w)
	// 	{
	// 		cout<<dp[i][j]<<' ';
	// 	}
	// 	cout<<endl;
	// }
	dp[h-1][w-1]=1;
	for(int i=h-1;i>=0;i--)
	{
		for(int j=w-1;j>=0;j--)
		{
			if(!(i==h-1 and j==w-1))
			{
				if(s[i][j]=='.')
				{
					if(i+1<h)
					{
						dp[i][j]+=dp[i+1][j];
					}
					if(j+1<w)
					{
						dp[i][j]+=dp[i][j+1];
					}
					dp[i][j]%=mod;
				}
				else
				{
					dp[i][j]=0;
				}
			}
		}
	}
	// in(h)
	// {
	// 	inj(w)
	// 	{
	// 		cout<<dp[i][j]<<' ';
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[0][0]%mod;
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}

Measured memory_bytes: 9088
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (_n, q) = i.read2::<usize, usize>();
    let s: Vec<_> = i.read_line().as_bytes().iter().cloned().collect();
    let mut td = Vec::new();

    for _ in 0..q {
        let mut tdi = i.read_line().split(' ');
        let t = tdi.next().unwrap().as_bytes()[0];
        let d = tdi.next().unwrap().as_bytes()[0];
        let d = if d == b'L' { Dir::L } else { Dir::R };
        td.push((t, d));
    }
    let ans = solve(&s, &td);
    writeln!(o, "{}", ans).unwrap();
}
#[derive(Eq, PartialEq, Clone, Copy)]
enum Dir {
    L,
    R,
}
fn solve(s: &[u8], td: &[(u8, Dir)]) -> usize {
    let mut l = 0;
    let mut r = 0;
    for &(t, d) in td.iter().rev() {
        match d {
            Dir::L => {
                if s[l] == t {
                    l += 1;
                }
                if r != 0 && s[s.len() - r] == t {
                    r -= 1;
                }
            }
            Dir::R => {
                if s[s.len() - r - 1] == t {
                    r += 1;
                }
                if l != 0 && s[l - 1] == t {
                    l -= 1;
                }
            }
        }
        if l + r == s.len() {
            break;
        }
    }
    s.len() - (l + r)
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let mut n:usize = read!();
    let mut m:usize = read!();
    if n>12 {println!("{}",m); }
    else if n>5 {println!("{}",m/2); }
    else {println!("0",); }
}

Measured memory_bytes: 2072
S = list(map(int, input().split('/')))

def main():
    if S[0]>2019:
        print('TBD')
        return
    elif S[0]==2019 and S[1]>4:
        print('TBD')
        return
    else:
        print('Heisei')
        return 

main()
    

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

#define pb(a) push_back(a)
#define vi vector<int>
#define loop(i, n) for(int i=1;i<=n;i++)
#define loop0(i, n) for(int i=0;i<n;i++)
#define in(i) scanf("%d", &i);
#define out(i) printf("%d", i)
#define inc(i) scanf("%c", &i)

int h, w, lastI=INT_MIN, lastJ=INT_MIN;
char grid[1001][1001];
int dp[1001][1001];
const int mod=1000000007;

int solve(int x, int y)
{
  if(x==h && y==w)
    return 1;
  if(grid[x][y]!='.')
    return 0;
  if(dp[x][y]!=-1)
    return dp[x][y];
  if(x==h || grid[x+1][y]=='#')
    return dp[x][y]=solve(x, y+1)%mod;
  if(y==w || grid[x][y+1]=='#')
    return dp[x][y]=solve(x+1, y)%mod;
  return dp[x][y]=(solve(x+1, y)%mod+solve(x, y+1)%mod)%mod;
}
int main()
{
  memset(dp, -1, sizeof(dp));
  in(h);
  in(w);
  loop(i, h)
  {
    loop(j, w)
    {
      cin>>grid[i][j];
      if(i==h && grid[i][j]=='#')
        lastJ=j;
      if(j==w && grid[i][j]=='#')
        lastI=i;
    }
  }
  cout<<solve(1, 1);
}



Measured memory_bytes: 8720
def C_TypicalStairs():
    N, M = map(int, input().split())
    am = [int(input()) for i in range(M)]
    can_move = True
    num_move = 0
    if(M == 0):
        num_move = fib(N+1)
    else:
        # 到達不可を除く
        for i in range(M-1):
            if ((am[i] + 1) == am[i+1]):
                can_move = False
        if (can_move):
            num_move = fib(am[0])
            if (M <= 1):
                pass
            else:
                for i in range(M-1):
                    num_move *= fib(am[i+1] - am[i] - 1)
            num_move *= fib(N - am[M-1])
    print(num_move % 1000000007)

def fib(n):
    if (n <= 1):
        a0 = n
    else:
        a0, a1 = 0, 1
        for _ in range(n):
            a0, a1 = a1, a0 + a1
    return a0
if __name__ == "__main__":
    C_TypicalStairs()

Measured memory_bytes: 7080
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(void){
  int N;
  string s;

  cin >> N;
  cin >> s;

  bool t[N];
  for(int i=0;i<s.size();++i){
    if(s[i] == 'o') t[i] = true;
    else t[i] = false;
  }

  bool ans[N];

  for(int cas=0;cas<4;cas++){
    if(cas == 0){
      ans[0] = true;
      ans[1] = true;
    }
    else if(cas == 1){
      ans[0] = true;
      ans[1] = false;
    }
    else if(cas == 2){
      ans[0] = false;
      ans[1] = true;
    }
    else if(cas == 3){
      ans[0] = false;
      ans[1] = false;
    }

    for(int i=1;i<N-1;++i){
      if(ans[i] == true){
        if(t[i] == true) ans[i+1] = ans[i-1];
        else ans[i+1] = !ans[i-1];
      }
      else{
        if(t[i] == true) ans[i+1] = !ans[i-1];
        else ans[i+1] = ans[i-1];
      }
    }

    if(!(ans[1] ^ ans[N-1])){
      if(ans[0] && !t[0]) continue;
      if(!ans[0] && t[0]) continue;
    }
    else{
      if(ans[0] && t[0]) continue;
      if(!ans[0] && !t[0]) continue;
    }

    if(!(ans[N-2] ^ ans[0])){
      if(ans[N-1] && !t[N-1]) continue;
      if(!ans[N-1] && t[N-1]) continue;
    }
    else{
      if(ans[N-1] && t[N-1]) continue;
      if(!ans[N-1] && !t[N-1]) continue;
    }

    for(int i=0;i<N;++i){
      if(ans[i]) cout << "S";
      else cout << "W";
    }
    cout << endl;
    return 0;
  }

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


Measured memory_bytes: 768
from collections import defaultdict
dic = defaultdict(list)
n, m = map(int, input().split())
seen = set()
l = [None] * n
for i in range(m):
    x, y, _ = map(int, input().split())
    dic[x-1].append(y-1)
    dic[y-1].append(x-1)
for i in range(n):
    if i in seen:
        continue
    seen.add(i)
    l[i] = i
    stack = [i]
    while stack:
        q = stack.pop()
        for child in dic[q]:
            if child not in seen:
                seen.add(child)
                l[child] = i
                stack.append(child)
print(len(set(l)))

    

Measured memory_bytes: 87640
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n, a, b;string s;
    cin >> n>>  a >> b >> s;
    ll f = 0, f1 = 0;
    rep(i, n)
    {
        if(s[i] == 'c') cout << "No\n";
        else if(s[i] == 'a'){
            if(f >= a+b)cout << "No\n";
            else { cout << "Yes\n"; f++;}
        }
        else{ //cout << f1 << " ";
            if(f >= a+b || f1 >= b)cout << "No\n";
            else { cout << "Yes\n"; f++; f1++; }
        }
    }

}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

/*int main(){
    int N;
    cin >> N;
    vector <int> a(N);
    for(int i=0;i<N;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int A=0,B=0;
    for(int i=0;i<N;i++){
        if(i%2==0) A+=a.at(i);
        else B+=a.at(i);
    }
    cout << (1+7/3)*3 <<endl;
    return 0;
}*/

int main(){
    bool flag =false;
    bool flag2 =false;
    vector<vector<int>> c(3,vector<int>(3));
    rep(i,0,3) rep(j,0,3) cin >> c.at(i).at(j);
    vector<int> b(3);
    rep(i,0,3) b.at(i)=c.at(0).at(i);
    if(c.at(1).at(0)-b.at(0)==c.at(1).at(1)-b.at(1)&&c.at(1).at(1)-b.at(1)==c.at(1).at(2)-b.at(2)){
        flag=true;
    }
    if(c.at(2).at(0)-b.at(0)==c.at(2).at(1)-b.at(1)&&c.at(2).at(1)-b.at(1)==c.at(2).at(2)-b.at(2)){
        flag2=true;
    }
    if(flag==true&&flag2==true) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
use input::Input;

fn main() {
    let mut input = Input::default();

    let n = input.parse();
    let mut v = (0..n).map(|_| input.parse::<u64>()).collect::<Vec<_>>();

    v.sort_by(|a, b| b.cmp(a));

    let mut sum = 0;
    let mut curr = 0usize;
    let mut w = true;

    for _ in 1..n {
        sum += v[curr];
        if w {
            curr += 1;
            w = false;
        } else {
            w = true;
        }
    }

    println!("{}", sum);
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


Measured memory_bytes: 15076
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int len = sc.nextInt();
        List<String> retList = new ArrayList<>();
        getNormalFormNumbers(retList, "a", 1, len);
        retList.forEach(System.out::println);
    }

    private static void getNormalFormNumbers(List<String> normalForms, String intermediate, int usedChars, int len) {
       if (intermediate.length() == len) {
           normalForms.add(intermediate);
           return;
       }
       for (int i=0; i<=usedChars; i++) {
           getNormalFormNumbers(normalForms, intermediate + (char) ('a' + i), usedChars + (i < usedChars ? 0 : 1), len);
       }
    }
}

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

int main() {
  int N;
  vector<double> x(N), y(N);
  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> x.at(i) >> y.at(i);
  }
  double ans = 0;
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      ans += sqrt((x.at(i) - x.at(j))*(x.at(i) - x.at(j)) + (y.at(i) - y.at(j))*(y.at(i) - y.at(j)));
    }
  }
  ans /= N;
  ans *= 2;
  printf("%.10lf",ans);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    list<pair<double,double>> res={{0,0},{100,0}};
    rep(i,n){
        list<pair<double,double>> tmp={};
        tmp.push_back(*res.begin());
        while(res.size()>1){
            pair<double,double> p=*res.begin();
            res.pop_front();
            pair<double,double> q=*res.begin();
            pair<double,double> r1,r2,r3;
            r1.first=(2*p.first+q.first)/3;
            r1.second=(2*p.second+q.second)/3;
            r3.first=(p.first+2*q.first)/3;
            r3.second=(p.second+2*q.second)/3;
            r2.first=r1.first+((r3.first-r1.first)-sqrt(3)*(r3.second-r1.second))/2;
            r2.second=r1.second+(sqrt(3)*(r3.first-r1.first)+(r3.second-r1.second))/2;
            //tmp.push_back(p);
            tmp.push_back(r1);
            tmp.push_back(r2);
            tmp.push_back(r3);
            tmp.push_back(q);
        }
        res=tmp;
    }
    for(auto itr=res.begin(); itr!=res.end(); itr++){
        pair<double,double> p=*itr;
        cout<<setprecision(10)<<p.first<<' '<<p.second<<endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll cnt[100];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n),B(n);
  for(auto &a:A)cin>>a;
  for(auto &a:B)cin>>a;
  sort(ALL(B));
  B.pb(llINF);
  for(int i=28;i>=0;i--){
    ll num=pow(2,i+1);
    ll num2=pow(2,i);
    for(int j=0;j<n;j++)B[j]%=num;
    for(auto &a:A)a%=num;
    sort(ALL(B));
    for(int j=0;j<n;j++){
     
      if(num2-A[j]>=0){
	cnt[i]+=lower_bound(ALL(B),num-A[j])-lower_bound(ALL(B),num2-A[j]);
      }else{
	cnt[i]+=lower_bound(ALL(B),num-A[j])-B.begin();
	cnt[i]+=lower_bound(ALL(B),num)-lower_bound(ALL(B),num+num2-A[j]);
      }
    }
  }
  ll ans=0;
  for(int i=0;i<=28;i++){
    //  cout<<cnt[i]<<" ";
    ans+=pow(2,i)*(cnt[i]%2);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> l(N+1);
  l.at(0) = 2;
  l.at(1) = 1;
  for(int i = 2; i < N+1; i++){
    l.at(i) = l.at(i-1) + l.at(i-2);
  }

  cout << l.at(N) << endl;
}


Measured memory_bytes: 256
// abc060_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int N, T;
vector<ll> W, V;

void dp_rec(){


}


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    cin >> N >> T;
    W.assign(N, 0);
    V.assign(N, 0);
    REP(i, N) cin >> W[i] >> V[i];

    map<ll, ll> dp;
    dp[0] = 0;
    REP(i, N){
        auto dp_prev = dp;
        for (auto e: dp_prev){
            ll w = e.first;
            ll v = e.second;
            ll tmp = dp[w + W[i]];
            dp[w + W[i]] = max(tmp , v + V[i]);
        }
//        print(dp);
    }

    ll ans = 0;
    for (auto e: dp){
        ll w = e.first;
        ll v = e.second;
        if (w <= T){
            ans = max(ans, v);
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		long X = sc.nextLong();
		long K = sc.nextLong();
		long D = sc.nextLong();
		
		long i = Math.abs(X) / D;
		long r = Math.abs(X) % D;
		
		long result = 0;
		if (i >= K) {
			result = Math.abs(X) - (D * K);
		}
		else {
			if ((K - i) % 2 == 0) {
				result = r;
			}
			else {
				result = D - r;
			}
		}
		
		// 結果の出力
		System.out.println(result);
		
		sc.close();
	}
}


Measured memory_bytes: 27072
#include<iostream>
#include<map>
#include<string>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len; i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;                                                       

int main(){
  string w;
  cin >> w;
  map<char,int> m;
  rep(i,w.size()){ m[w.at(i)] += 1;}
  rep(i,w.size()){ if(m[w.at(i)] % 2 != 0){ cout << "No" << "\n";return 0;}}
  cout << "Yes" << "\n"; 
} 
  


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

using namespace std;

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

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

	sort(arr, arr+n);	
	double avg = arr[0];

	for(int i = 1 ; i < n ; ++i) {
		avg = (avg + arr[i]) / 2.0;
	}

	cout << fixed << setprecision(6);
	cout << avg;

	return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    v1 = 2*c*max(x, y)
    v2 = 2*c*min(x, y) + (y-x if x < y else x-y)*(b if x < y else a)
    v3 = a*x + b*y
    print(min(v1, v2, v3))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61904
n=int(input())
w=[]
for i in range(n):
    w.append(input())
if n==len(list(set(w))):
  ans='Yes'
else:
  ans='No'

for i in range(n-1):
    if w[i][-1:]==w[i+1][0]:
        a=0
    else:
        ans='No'
        break
print(ans)
        

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

using ll = long long;
const int N = 2e5L + 11;

ll a[N], d[N];

int main() {
	ios :: sync_with_stdio(false);
	int n, q; ll s, t;
	cin >> n >> q >> s >> t;
	ll ans = 0;
	auto f = [&](ll d) {
		if(d > 0)
			return -s * d;
		return t * (-d);
	};
	for(int i = 0; i <= n; i ++)
		cin >> a[i];
	for(int i = 1; i <= n; i ++) {
		d[i] = a[i] - a[i - 1];
		ans += f(d[i]);
	}
	while(q --) {
		int l, r, x;
		cin >> l >> r >> x;
		ans -= f(d[l]);
		d[l] += x;
		ans += f(d[l]);
		if(r != n) {
			ans -= f(d[r + 1]);
			d[r + 1] -= x;
			ans += f(d[r + 1]);
		}
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,m,s[2010],t[2010],dp[2010][2010];
signed main(){
	cin>>n>>m;
	rep(i,n)cin>>s[i+1];
	rep(i,m)cin>>t[i+1];
	rep(i,n+1){
		rep(j,m+1){
			if(i==0||j==0)dp[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i]==t[j]){
				dp[i][j]=dp[i][j-1]+dp[i-1][j];
			}
			else{
				dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
			}
			dp[i][j]+=MOD;
			dp[i][j]%=MOD;
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    --x,--y;
    vector<int>ans(n);
    rep(sv,n){
        vector<int>dist(n,1e9);
        queue<int>q;
        auto update=[&](int v,int d){
            if(dist[v]!=1e9)return;
            dist[v]=d;
            q.push(v);
        };
        update(sv,0);
        while(!q.empty()){
            int v=q.front(); q.pop();
            int d=dist[v];
            if(v-1>=0)update(v-1,d+1);
            if(v+1<n)update(v+1,d+1);
            if(v==x)update(y,d+1);
            if(v==y)update(x,d+1);
        }
        rep(i,n)ans[dist[i]]++;
    }
    rep(i,n)ans[i]/=2;
    for(int i=1; i<=n-1; ++i){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
ta_c,ao_c,num = map(int,input().split())

if num <= ta_c:
    print(ta_c-num,ao_c)
elif ta_c < num <= ta_c + ao_c:
    ao_c = ta_c+ao_c - num
    ta_c = 0
    print(ta_c,ao_c)
else:
    ta_c, ao_c = 0,0
    print(ta_c,ao_c)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

#define N 999999

int main()
{
  int i,j,n;

  char prime[N];
  while(scanf("%d",&n)!=EOF){
  int cnt=0;
  for (i=0;i<n;i++){
    prime[i]=1;
  }
  prime[0]=0;
  for (i=1;i<(int)sqrt(n);i++){
    if (prime[i]==1){
      for (j=i+1;(i+1)*j<=n;j++){
        prime[(i+1)*j-1]=0;
      }
    }
  }
  for (i=0;i<n;i++)
    if (prime[i]==1)
      cnt++;
  printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 1572
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int cnt(int i) {
    return i + i * (i - 1) / 2;
}

int n; 
vector<vector<int>> g;
vector<int> c;
vector<int> ans;
vector<int> co;
vector<map<int, int>> dp;

void dfs(int v, int p) {
    co[v] = 1;
    for(int nv: g[v]) {
        if(nv == p) continue;
        dfs(nv, v);
        co[v] += co[nv];
        int x = co[nv];
        if(dp[nv].count(c[v])) x -= dp[nv][c[v]];
        ans[c[v]] -= cnt(x);

        if(dp[v].size() < dp[nv].size()) swap(dp[v], dp[nv]);
        for(auto& pa: dp[nv]) {
            dp[v][pa.fr] += pa.sc;
        }
    }
    dp[v][c[v]] = co[v];
}

void solve() {
	cin >> n;
    g.assign(n, vector<int>());
    c.resize(n);
    rep(i, n) {
        cin >> c[i];
        -- c[i];
    }
    rep(i, n - 1) {
        int a, b; cin >> a >> b;
        --a, --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    ans.assign(n, cnt(n));
    co.resize(n);
    dp.resize(n);
    dfs(0, -1);
    rep(i, n) {
        int x = n;
        if(dp[0].count(i)) x -= dp[0][i];
        ans[i] -= cnt(x);
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 81284
s=int(input())
a=[s]
i=0
b=0
while b not in a:
    if a[i]%2==0:
        b=a[i]//2
    else:
        b=3*a[i]+1
    a.append(b)
    i+=1
    if a[i]%2==0:
        b=a[i]//2
    else:
        b=3*a[i]+1
print(len(a)+1)

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    N, X, T = map(int, input().split())
    ans = (N//X)*T
    if N%X != 0:
        ans += T
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include<iostream>
#include<cstdio>
#include<math.h>
#include<queue>
using namespace std;

struct worm{
	char part[11];
	int dep;
	worm(){
		dep = 0;
	}
};

int main(){
	worm input;
	while (cin >> input.part, input.part[0] != '0'){
		int len;
		for (len = 0; input.part[len] != '\0'; len++){
			if (input.part[len] == 'r') input.part[len] = 0;
			else if (input.part[len] == 'g') input.part[len] = 1;
			else input.part[len] = 2;
		}
		queue<worm> q;
		q.push(input);
		worm q_c;
		bool memo[1000000] = {};
		while (1){
			bool color[3] = {};
			int sum1 = 0, sum2 = 0;
			int cnt_clr = 0;

			if (q.empty()){
				printf("NA\n");
				break;
			}

			q_c = q.front();

			for (int i = 0; i < len; i++){
				color[q_c.part[i]] = true;
			}
			for (int i = 0; i < 3; i++) if (color[i]) cnt_clr++;
			if (cnt_clr == 1){
				printf("%d\n", q_c.dep);
				break;
			}

			/*for (int i = 0; i < len; i++){
				printf("%d", q_c.part[i]);
				}*/
			for (int i = 0; i < len; i++){
				sum1 += q_c.part[i] * pow(3, i + 1);
				sum2 += q_c.part[i] * pow(3, len - i);
				//printf(" %d*%d^%d", q_c.part[i], 3, i + 1);
			}
			//printf(" =%d\n", sum1);
			if (memo[sum1]){
				q.pop();
				continue;
			}
			memo[sum1] = true;
			memo[sum2] = true;

			for (int i = 1; i < len; i++){
				if (q_c.part[i - 1] != q_c.part[i]){
					for (int j = 0; j < 3; j++) color[j] = false;

					color[q_c.part[i - 1]] = true;
					color[q_c.part[i]] = true;

					for (int j = 0; j < 3; j++){
						if (!color[j]){
							q_c.part[i - 1] = j;
							q_c.part[i] = j;
							q_c.dep++;
							q.push(q_c);
							q_c = q.front();
						}
					}
				}
			}
			q.pop();
		}
	}
	return 0;
}

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

bool isPrime(int x){
	for(int i=2;i*i<=x;i++){
		if(x % i == 0){
			return false;
		}
	}
	return true;
}

int main(void){
	int n;

	while(cin>>n,n){
		for(int i=n;;i--){
			if(isPrime(i) && isPrime(i-2)){
				cout<<i-2<<" "<<i<<endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 864
#include<stdio.h>
int main(){
  int x, y, tmp;
  while(1){
    scanf("%d %d", &x, &y);
    if(y<x){
      tmp=x;
      x=y;
      y=tmp;
    }
    if(x==0&&y==0)break;
    printf("%d %d\n", x, y);
  }




  return 0;
  }

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

#define LL unsigned long long
#define pii pair<int, int>
#define mp make_pair

const int maxN = 505;

int n;
int oa[maxN + 1], ob[maxN + 1];
int G[maxN + 1][maxN + 1];
LL a[maxN + 1], b[maxN + 1];
LL ans[maxN + 1][maxN + 1];

inline void fail() { puts("-1"); exit(0); }

inline void work(int k)
{
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) G[i][j] = -1;
	
	vector<pii> t1, t2;
	for(int i = 1; i <= n; i++)
		if(oa[i])
		{
			if(!(a[i] >> k & 1))
				for(int j = 1; j <= n; j++) G[i][j] = 0;
			else t1.push_back( mp(i, 1) );
		}
		else
		{
			if(a[i] >> k & 1)
				for(int j = 1; j <= n; j++) G[i][j] = 1;
			else t1.push_back( mp(i, 0) );
		}
	for(int j = 1; j <= n; j++)
		if(ob[j])
		{
			if(!(b[j] >> k & 1))
			{
				for(int i = 1; i <= n; i++)
					if(G[i][j] == 1) fail();
					else G[i][j] = 0;
			}
			else t2.push_back( mp(j, 1) );
		}
		else
		{
			if(b[j] >> k & 1)
			{
				for(int i = 1; i <= n; i++)
					if(G[i][j] == 0) fail();
					else G[i][j] = 1;
			}
			else t2.push_back( mp(j, 0) );
		}

	if(min(t1.size(), t2.size()) >= 2)
	{
		for(int i = 0; i < t1.size(); i++)
			for(int j = 0; j < t2.size(); j++)
				G[ t1[i].first ][ t2[j].first ] = (i + j) & 1;
		return;
	}
	if(!t1.size() || !t2.size())
	{
		for(int i = 0; i < t1.size(); i++)
		{
			int x = t1[i].first, v = t1[i].second, f = 0;
			for(int j = 1; j <= n; j++) f |= (G[x][j] == v);
			if(!f) fail();
		}
		for(int i = 0; i < t2.size(); i++)
		{
			int x = t2[i].first, v = t2[i].second, f = 0;
			for(int j = 1; j <= n; j++) f |= (G[j][x] == v);
			if(!f) fail();
		}
		return;
	}
	if(t1.size() == 1)
	{
		for(int i = 0; i < t2.size(); i++)
		{
			int x = t2[i].first, v = t2[i].second, f = 0;
			for(int j = 1; j <= n; j++) f |= (G[j][x] == v);
			if(!f) G[ t1[0].first ][x] = v;
		}
		int x = t1[0].first, v = t1[0].second, f = 0;
		for(int i = 1; i <= n; i++)
			if(G[x][i] != (v ^ 1)) G[x][i] = v, f = 1;
		if(!f) fail();
		return;
	}
	if(t2.size() == 1)
	{
		for(int i = 0; i < t1.size(); i++)
		{
			int x = t1[i].first, v = t1[i].second, f = 0;
			for(int j = 1; j <= n; j++) f |= (G[x][j] == v);
			if(!f) G[x][ t2[0].first ] = v;
		}
		int x = t2[0].first, v = t2[0].second, f = 0;
		for(int i = 1; i <= n; i++)
			if(G[i][x] != (v ^ 1)) G[i][x] = v, f = 1;
		if(!f) fail();
		return;
	}
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &oa[i]);
	for(int i = 1; i <= n; i++) scanf("%d", &ob[i]);
	for(int i = 1; i <= n; i++) scanf("%llu", &a[i]);
	for(int i = 1; i <= n; i++) scanf("%llu", &b[i]);

	for(int k = 0; k < 64; k++)
	{
		work(k);
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				if(G[i][j]) ans[i][j] |= (1ull << k);
	}

	for(int i = 1; i <= n; i++, puts(""))
		for(int j = 1; j <= n; j++)
			printf("%llu ", ans[i][j]);
	return 0;
}


Measured memory_bytes: 8508
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder {

    public class Hoge {

        public string Name;
        public int Point;
        public int Index;
    }

    class Program {

        static void Main(string[] args) {


            var N = int.Parse(Console.ReadLine());
            var list = new List<Hoge>(N);

            for (int i = 0; i < N; i++) {

                var temp = Console.ReadLine().Split(' ');
                list.Add(new Hoge { Name = temp[0], Point = int.Parse(temp[1]), Index = i + 1 });
            }

            foreach (var result in list.OrderBy(o => o.Name).GroupBy(o => o.Name)) {

                foreach (var inn in result.OrderByDescending(o => o.Point)) {

                    Console.WriteLine(inn.Index);
                }
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

static const int N = 100;

int main(){
	int n;
	cin >> n;
	int p[N+1];
	int m[N+1][N+1];
	for(int i = 1; i <= n ;i++){
		cin >> p[i-1] >> p[i];
	}
	for(int i = 1; i <=n; i++){
		m[i][i] = 0;
	}
	for(int l = 2; l <=n;l++){
		for(int i = 1; i <=n-l+1; i++){
			int j = i + l-1;
			m[i][j] = 1e8;
			for(int k = i; k <= j-1;k++){
				m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
			}
		}
	}
cout << m[1][n] << endl;
}



Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11
{
    class Program
    {
       
        static int[,] GetMatrix(int a, int b)
        {
            int[,] m = new int[a,b];

            for (int i = 0; i < a; ++i)
            {
                string[] sArray = Console.ReadLine().Split(' ');

                for (int j = 0; j < b; ++j)
                {
                    m[i, j] = int.Parse(sArray[j]);
                }
            }
            return m;
        }
        

        static void Main(string[] args)
        {

            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            int l = int.Parse(str[2]);

            int[,] A = GetMatrix(n,m);
            int[,] B = GetMatrix(m,l);


            for (int i = 0; i < n; ++i)
            {
              
                for (int j = 0; j < l; ++j)
                {
                    long sum = 0;

                    for (int k = 0; k < m; ++k)
                    {
                        sum += A[i, k] * B[k, j];
                    }
                    if (j == (l-1))
                    {
                        Console.WriteLine(sum);
                    }
                    else
                    {
                        Console.Write("{0} ", sum);
                    }
                    

                }
                
            }
        }
    }
}

Measured memory_bytes: 5940
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m;
string s,a[55555];
ll h,w,x,y,ans=0,sum;
ll ite;

int main(){
	cin>>s;
	cin>>ii;
	n=s.length();
	for(i=1;i<=5;i++){
		for(k=0;k+i<=n;k++){
			a[l]=s.substr(k,i);
			l++;
		}
	}
	sort(a,a+l);
	unique(a,a+l);
	p(a[ii-1]);
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define lint __int128
#define vi vector<int>
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define pii pair<int,int>
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 1E5 ;

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    string s ; cin >> s ; puts(s == "ABC" ? "ARC" : "ABC") ;
}


Measured memory_bytes: 3592