akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n, k;
    cin>>n>>k;
    if (n + 1 >= k * 2) {
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }

    return 0;
}


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

#define ll long long
#define P pair<int, int>
#define F first
#define S second

const ll mod = 1000000007LL;

ll n, W, w[105];
int v[105];
vector<ll> dp, pre;

void solve() {
  cin >> n >> W;
  for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

  int V = 0;
  for (int i = 0; i < n; i++) V += v[i];

  dp = vector<ll>(V + 1, INT_MAX);
  for (int i = 0; i < n; i++) {
    pre = dp;
    for (int j = 0; j <= V; j++) {
      dp[j] = pre[j];
      if (j == v[i]) {
        dp[j] = min(dp[j], w[i]);
      }
      if (v[i] <= j) {
        dp[j] = min(dp[j], w[i] + pre[j - v[i]]);
      }
    }
  }

  for (int i = V; i >= 0; i--) {
    if (dp[i] <= W) {
      cout << i;
      return;
    }
  }
  cout << 0;
  return;
}

int main(int argc, char const *argv[]) {
/*#ifndef ONLINE_JUDGE
  freopen("practice/input.txt", "r", stdin);
  freopen("practice/output.txt", "w", stdout);
#endif*/

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int T = 1;
  while (T--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>

int main(){
    char c;
    scanf("%c",&c);
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        printf("vowel\n");
    else
        printf("consonant\n");

    return 0;
}

Measured memory_bytes: 128
import numpy as np


# 整数の入力
N = int(input())
# スペース区切りの整数の入力
b = np.zeros(N)
b = input().split()
for i in range(N):
    b[i] = int(b[i])
# 文字列の入力
# 出力

error = 0
for i in range(N):
    if b[i] > i+1:
        error += 1

if error != 0:
    print(-1)
else:
    c = []
    while len(b) > 1:
        for i in range(len(b)-1,-1,-1):
            if b[i] == i+1:
                c.append(b.pop(i))
                break
    c.append(1)
    c.reverse()
    for i in range(N):
        print(c[i])


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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    int n;
    cin>>n;

    int x;
    set <int> s;
    FOR(i,0,n)
    {
        cin>>x;
        s.insert(x);
    }

    if (s.size() == n)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
def main():
    H, W, D = map(int, input().split())
    coordinate = [None] * (H*W)
    for i in range(H):
        for j, A in enumerate(list(map(int, input().split()))):
            coordinate[A-1] = (i, j)
    
    cost = [0] * (H*W)
    dist = lambda X, Y: abs(X[0]-Y[0]) + abs(X[1]-Y[1])
    for i in range(D, H*W):
        u,v = divmod(i, D)
        cost[i] = cost[i-D] + dist(coordinate[i], coordinate[i-D])

    Q = int(input())
    query = [tuple(map(int, input().split())) for _ in range(Q)]
    for l, r in query:
        print(cost[r-1]-cost[l-1])

main()

Measured memory_bytes: 32888
#include <stdio.h>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if(A>B)
    {
        A+=(A-1);
        printf("%d\n",A);
    }
    else if(B>A)
    {
        B+=(B-1);
        printf("%d\n",B);
    }
    else if(A==B)
    {
        printf("%d\n",A+B);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
#include <cassert>
#include <cmath>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ld = long double;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES(x, y) ifstream fin(x); ofstream fout(y);
#define PI_NUM acos(-1.0)

int digitAt(ll num, int p) {
    return (num & (1ll << p)) != 0ll ? 1 : 0;
}

void solveD() {
    const ll mod = 1e9 + 7;

    int n;
    cin >> n;

    vll a(n);
    for (auto &i : a) {
        cin >> i;
    }

    ll ans = 0;
    unordered_map<int, unordered_map<int, ll> > cnt;
    for (const auto &num : a) {
        for (int digit = 0; digit < 60; digit++) {
            ll value = (1ll << digit) % mod;
            ans += (value * cnt[digit][digitAt(num, digit) ^ 1]) % mod;
            ans %= mod;
        }

        for (int digit = 0; digit < 60; digit++) {
            cnt[digit][digitAt(num, digit)] += 1;
            cnt[digit][digitAt(num, digit)] %= mod;
        }
    }

    cout << ans % mod;
}

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

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int n,m,a,b,d[N];
vector<int> v[N];
int main(){
    cin>>n>>m;
    while(m--){
	scanf("%d%d",&a,&b);
	v[a].push_back(b);
    }
    for(int i=0;i<=n;i++)d[i]=0;
    for(int i=0;i<=n;i++){
	for(auto x:v[i])d[x]=max(d[x],d[i]+1);
	d[i+1]=max(d[i+1],d[i]);
    }
    cout<<d[n]<<endl;
    return 0;
}


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

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

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  IOS;
  constexpr char endl = '\n';

  int N;
  cin >> N;
  vi A(N, 0);
  rep(i, N - 1) {
    int a;
    cin >> a, a--;
    A[a]++;
  }

  rep(i, N) cout << A[i] << endl;
}

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

#define F first
#define S second

using namespace std;

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

const int N = 100010, M = 10, P = 13, mod = 1e9 + 7;

int n;
int f[N][P];
string s;

int main()
{
	cin >> s;
	n = s.size();
	
	f[0][0] = 1;
	
	for (int i = 0; i < n; i ++ )
		for (int j = 0; j < 10; j ++ )
		{
			int ne = s[i] == '?' ? j : s[i] - '0';
			for (int k = 0; k < P; k ++ )
			{
				int t = (k * 10 + ne) % P;	
				f[i + 1][t] = (f[i + 1][t] + f[i][k]) % mod;
			}
			if (s[i] != '?') break;
		}
	
	cout << f[n][5] << endl;
	return 0;
}

Measured memory_bytes: 5504
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String line = in.nextLine();
		if (line.equals("A")) {
			System.out.println("T");
		} else if (line.equals("T")) {
			System.out.println("A");
		} else if (line.equals("G")) {
			System.out.println("C");
		} else {
			System.out.println("G");
		}
		in.close();
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

void solve(){
	int n ;
	re(n);
	cout << n*(n-1)/2 << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3652
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};


// abcde
fn read_string() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_string();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_string();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_string();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();    
    (
        elems[0].parse().ok().expect("failed to parse"), 
        elems[1].parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"), 
        elems[1].parse().ok().expect("failed to parse"),
        elems[2].parse().ok().expect("failed to parse"),
    )
}

fn main() {

    let (n, m): (usize, usize) = read_as_pair();
    let mut xs: Vec<i64> = read_as_collection();
    xs.sort();
    let dist = xs[m - 1] - xs[0];
    let mut diffs : Vec<i64> = xs.windows(2).map(|v| v[1] - v[0]).collect();
    diffs.sort_by(|a, b| b.cmp(a));
    let ans: i64 = dist - &diffs[0..min(n, m)-1].iter().sum();
    println!("{}", ans);
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int h, w, n;
    cin >> h >> w >> n;

    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    vector< vector<int> > ans(h, vector<int>(w));
    int y = 0, x = 0, dx = 1, cnt = 0, col = 0;
    rep(i, h * w){
        ans[y][x] = col + 1;
        ++cnt;
        if(cnt == a[col]){
            cnt = 0;
            ++col;
        }
        if(0 <= x + dx && x + dx < w){
            x += dx;
        }else{
            ++y;
            dx = -dx;
        }
    }

    rep(i, h){
        rep(j, w){
            cout << ans[i][j];
            if(j < w - 1){
                cout << " ";
            }else{
                cout << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include <cmath>
#include <limits>
#include <numeric>
#include <bits/stdc++.h>

using namespace std;

int main(){
    int N, a;
    queue<int> q;
    cin >> N;
    for (auto i = 0; i < N; i++){
        cin >> a;
        q.push(a);
    }
    int count = 0;
    int now_block = 1;
    for (auto i = 0; i < N; i++){
        if (q.front() == now_block){
            count++;
            now_block++;
            q.pop();
        }else{
            q.pop();
        }
    }
    int answer = N - count;
    if (answer == N){
        answer = -1;
    }
    cout << answer << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  string s;
  char c='0';
  int i,d=0;
  cin>>s;
  for(i=0;i<s.size();i++){
    if(c=='0') c='1';
    else c='0';
    if(s[i]==c) d++;
  }
  if(s.size()-d<d) d=s.size()-d;
  cout<<d<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  	int n;
  	scanf("%d", &n);
	int ans[n];
    int middle = n/2;
  	int a;
  	scanf("%d", &a);
    ans[middle] = a;
    int diff = n%2 == 0? -1: 1;
    int j = 1;
	
    for(int i = 1; i < n; i++){
      scanf("%d", &a);
      ans[middle + j*diff] = a;
      diff *= -1;
      if(i > 1 && i % 2 == 0) j++;
    }
    
    for(int i = 0; i < n; i++)
      printf("%d ", ans[i]);  
}

Measured memory_bytes: 2816
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

// aba 3 > 3
// a 3 > 1
// a 5 > 2
// aaaba 3 > 5

//aaaba aaaba aaaba
// a1aba 2a3ba 4a5ba

// abaaa abaaa abaaa
// aba1a 2ba3a 4ba5a

// aabaa aabaa aabaa
// a1ba2 a3ba4 a5ba6

// a1a2a 3a4a5 a6a7a 8a9a10 a11a12a

// aaa aaa aaa
// a1a 2a3 a4a

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 文字列の入力
			String s = sc.next();
			// 整数の入力
			int k = sc.nextInt();
//			long cnt = 0;

			// sが奇数個つながりの同じ文字列の場合だけ変わる。
			boolean spFlag = false;
			if (s.length() % 2 == 1) {
				Set<Character> cs = new HashSet<>();
				for (int i = 0; i < s.length(); i++) {
					cs.add(s.charAt(i));
				}
				if (cs.size() == 1) {
					spFlag = true;
				}
			}
			if (spFlag) {
				long result = (((long) k + 1l) / 2l) * ((long) s.length() / 2l);
				result = result + ((long) k / 2l * ((long) s.length() + 1l) / 2l);
				System.out.println(result);
			} else {
				// 1回目
				List<Integer> idxList = new ArrayList<>();
				long res = 0;
				for (int i = 0; i < s.length(); i++) {
					char now = s.charAt(i);
					if (i != 0) {
						char bef = s.charAt(i - 1);
						if (now == bef && !idxList.contains(i - 1)) {
							idxList.add(i);
							res++;
						}
					}
				}

				// 2回目以降
				List<Integer> nextIdxList = new ArrayList<>();
				long nextRes = 0;
				for (int i = 0; i < s.length(); i++) {
					char now = s.charAt(i);
					if (i != 0) {
						char bef = s.charAt(i - 1);
						if (now == bef && !nextIdxList.contains(i - 1)) {
							nextIdxList.add(i);
							nextRes++;
						}
					} else {
						char bef = s.charAt(s.length() - 1);
						if (now == bef && !idxList.contains(s.length() - 1)) {
							nextIdxList.add(i);
							nextRes++;
						}
					}
				}

//			cnt = cnt * k;
//			if (spFlag) {
//				cnt = cnt + (k / 2);
//			}
				long result = res + nextRes * (k - 1);
				// 出力(整数)
				System.out.println(result);
			}
		}
	}
}


Measured memory_bytes: 21972
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<Integer> d = new HashSet<>();
		for (int i = 0; i < N; i++) d.add(sc.nextInt());
		System.out.println(d.size());
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;

class UnionFind{
    public:
        vector<int> par, ran;

        UnionFind(int N){
            par.resize(N,0);
            ran.resize(N,0);
            for(int i=0;i<N;i++){
                par[i] = i;
            }
        }

        int root(int x){
            return x == par[x] ? x : par[x] = root(par[x]);
        }

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

            if(x==y) return;

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

        bool same(int x, int y){
            return root(x) == root(y);
        }
};

int main(){
    int N,K,L;
    cin >> N >> K >> L;
    UnionFind uf_road = UnionFind(N);
    UnionFind uf_rail = UnionFind(N);
    int p,q,r,s;
    for(int i=0;i<K;i++){
        cin >> p >> q;
        p--; q--;
        uf_road.unite(p,q);
    }
    for(int i=0;i<L;i++){
        cin >> r >> s;
        r--; s--;
        uf_rail.unite(r,s);
    }
    //vector<int> par_road = uf_road.par;
    //vector<int> par_rail = uf_rail.par;
    map<pair<int,int>, int> count;
    for(int i=0;i<N;i++){
        //if(par_road[i] == par_rail[i]){
            //count[make_pair(par_road[i],par_rail[i])]++;
            count[make_pair(uf_road.root(i),uf_rail.root(i))]++;
    }

    for(int i=0;i<N;i++){
        //cout << count[make_pair(par_road[i],par_rail[i])]+1 << " ";
        cout << count[make_pair(uf_road.root(i), uf_rail.root(i))];
        if(i!=N-1)cout << " ";
        else      cout << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

const int mod = 998244353;


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


ll powmod(ll x, int y)
{
	return y ? (y & 1 ? x * powmod(x, y - 1) : sqr(powmod(x, y / 2))) % mod : 1;
}


void fft_stupid(vector<ll> &arr)
{
	if (arr.size() < 2)
		return;


}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<int> arr(n);

	for (auto &it : arr)
		cin >> it;

	int sum = accumulate(arr.begin(), arr.end(), 0);

	vector<int> ddp(sum + 1), sdp(sum + 1);
	ddp[0] = 1;
	sdp[0] = 1;

	for (auto it : arr)
	{
		for (int i = sum; i >= it; i--)
		{
			ddp[i] += ddp[i - it];
			if (ddp[i] >= mod)
				ddp[i] -= mod;
			ddp[i - it] <<= 1;
			if (ddp[i - it] >= mod)
				ddp[i - it] -= mod;
		}
	}

	for (auto it : arr)
	{
		for (int i = sum; i >= it; i--)
		{
			sdp[i] += sdp[i - it];
			if (sdp[i] >= mod)
				sdp[i] -= mod;
		}
	}

	int cnt = 0;

	for (int i = (sum + 1) / 2; i < (int) ddp.size(); i++)
	{
		cnt += ddp[i];
		if (cnt >= mod)
			cnt -= mod;
	}

	if (sum % 2 == 0)
	{
		cnt -= sdp[sum / 2];
	}

	cnt = (cnt * 3ll) % mod;

	cout << (mod + powmod(3, arr.size()) - cnt) % mod << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");

	solve(fin);

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,c=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        
        
    }
    
    sort(a,a+n);
    c=a[(n/2)]-a[(n/2)-1];
    cout<<c<<endl;
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if((c+b-1)/b <= (a+d-1)/d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    dsu d(N);
    while(Q--) {
        int t; cin >> t;
        if(t == 0) {
            int a, b;
            cin >> a >> b;
            d.merge(a, b);
        } else {
            int a, b;
            cin >> a >> b;
            if(d.same(a, b)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3888
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

r = I()
if r < 1200:
    print('ABC')
elif 1200 <= r < 2800:
    print('ARC')
else:
    print('AGC')

Measured memory_bytes: 63852
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int ans = 0;
	int a, b, c; cin >> a >> b >> c;
	for (ans = 0; ans < c;) {
		if (b >= a) {
			ans++;
			b -= a;
		}
		else break;
	}
	cout << ans << endl;
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int n;
vector<int> a;

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        int _a;
        cin >> _a;
        a.push_back(_a);
    }

    sort(a.begin(),a.end());
    int count=0;
    for(int i=0;i<n;){
        int j;
        for(j=1;a[i]==a[i+j];j++){
        }
        if(j%2==1){
            count++;
        }
        i+=j;
    }

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>    
using namespace std;    
string s;    
unordered_map<int, int>cnt;    
int main(){    
    cin>>s;    
    int cur = 0, x;    
    cnt[cur] = 1;    
    for(int i = 0; i < s.size(); ++i){    
        cur ^= (1 << (s[i] - 'a'));    
        if(cur ==  0){    
            continue;    
        }    
        else{    
            x = 1e8;    
            if(cnt[cur] > 0){    
                x= min(x, cnt[cur]);    
            }    
            for(int j = 0; j < 26; ++j){    
                if((cur ^ (1 << j)) == 0){ x = 1; break;}    
                else{    
                    if(cnt[cur ^ (1 << j)] > 0) x = min(x, cnt[cur ^ (1 << j)] + 1);    
                    else{    
                        x = min(x, cnt[cur ^ (1 << (s[i] - 'a'))] + 1);    
                    }    
                }    
            }    
            cnt[cur] = x;    
        }    
    }    
    cout << cnt[cur] << endl;    
}    
     
/*  
题意：  
长度2e5的字符串，问最少需要分成多少个连续的子串，在子串内部的字符可以随意排列的情况下使得这些子串都是回文串。  
   
思路：对于子串，只要出现奇数次的字符不超过1个，该子串就是回文串。一共26个小写字母，可以用一个整数状压记录，第i  
位表示该字母出现多少次。某位为0表示出现偶数次，为1表示出现奇数次。这样就很容易维护答案了。  
*/  

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    char c;
    cin>>c;
    c+=1;
    cout<<c<<"\n";
    return 0;

}
/*


*/


Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	var cnt, hasABCnt, hasACnt, hasBCnt int
	for i := 0; i < N; i++ {
		S := nextString()
		cnt += strings.Count(S, "AB")

		hasB := strings.HasPrefix(S, "B")
		hasA := strings.HasSuffix(S, "A")
		if hasB && hasA {
			hasABCnt++
		} else if hasB {
			hasBCnt++
		} else if hasA {
			hasACnt++
		}
	}

	if hasACnt == 0 && hasBCnt == 0 && hasABCnt > 0 {
		hasABCnt--
	}

	m := min(hasACnt+hasABCnt, hasBCnt+hasABCnt)
	fmt.Println(cnt + m)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int N;
int t, x, y;
int a = 0, b = 0, c = 0;
string ans;

string solve() {
	ans = "No";
	if ((x - a) + (y - b) == t) {
		ans = "Yes";
	}
	else if ((x - a) + (y - b) < t) {
		if (((t-c) - ((x - a) + (y - b))) % 2 == 0) {
			ans = "Yes";
		}
		
	}
	a = x;
	b = y;
	c = t;
	return ans;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> t >> x >> y;
		string ans = solve();
		if (ans == "No") {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string a,b;
  	cin>>a>>b;
  
  	int n=a.size(),m=b.size();
  if(n==m){
  	for(int i=0;i<n;i++){
		cout<<a[i]<<b[i];
    }
  }else{
    for(int i=0;i<n-1;i++){
		cout<<a[i]<<b[i];
    }
    cout<<a[n-1];
  }

}
  	

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        String origin = "CODEFESTIVAL2016";
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.nextLine();
            int total = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) != origin.charAt(i)) total++;
            }
            System.out.println(total);
        }
    }
}


Measured memory_bytes: 9684
#include<stdio.h>


int main()
{
	int x[10000];
	int n=0;
	int i;
	do{
		scanf("%d",&x[n]);
		++n;
	}while(x[n-1]!=0);
	
	for(i=0;i<n-1;i++) printf("Case %d: %d\n",i+1,x[i]);
	
return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int a = scan.nextInt();
     int b = scan.nextInt();
     int c = scan.nextInt();
     
     if( a < b ) {
         if(b < c){
    	    System.out.println("Yes");
         }else {
             System.out.println("No");
         }
     }else{
    	 System.out.println("No");
     }
    }
}



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

int main(){
 	int n,c=0;
  	cin>>n;
  	for(int i=0;i<n;i++){
    	string s;
      	cin>>s;
      	if(s=="Y")
          c++;
    }
  	if(c==0)
      cout<<"Three"<<endl;
  	else
      cout<<"Four"<<endl;
}

Measured memory_bytes: 256
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string p = Console.ReadLine();
            string r = Console.ReadLine();
            
            int count = 0;

            if(p[0] == r[0])
                count++;
            if(p[1] == r[1])
                count++;
            if(p[2] == r[2])
                count++;
            
            Console.WriteLine(count);
    
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N,K,R,S,P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    int ans = 0;
    bool add[N];
    //R-s S-p P-r

    REP(i,N){
        if(i< K){
            add[i] = true;
            if(T[i]== 's') ans+=R;
            if(T[i]== 'p') ans+=S;
            if(T[i] == 'r') ans+=P;
        }
        else{
            if(T[i]==T[i-K] && add[i-K]){
                add[i] = false;
            }
            else{ 
                add[i] = true;
                if(T[i]== 's') ans+=R;
                if(T[i]== 'p') ans+=S;
                if(T[i] =='r') ans+=P;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define debug (cout << "Sehen Sie mich!" << endl)

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

        cin >> a >> b >> c >> d;

        if (a + b > c + d) {
                cout << "Left" << endl;
        } else if (a + b < c + d) {
                cout << "Right" << endl;
        } else
                cout << "Balanced" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
int N,P;
struct mint {
    long long x; // typedef long long long long;
    mint(long long _x=0):x((_x%P+P)%P){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= P) x -= P;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += P-a.x) >= P) x -= P;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= P;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime P
    mint inv() const {
        return modpow(P-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin>>N>>P;
    string S;
    cin>>S;
    if(10 % P == 0){//2 or 5
        ll ans = 0;
        rep(r,N){
            if ((S[r] - '0') % P == 0){
                ans += r+1;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    vector<mint> cumsum(N+1, 0);
    rep(i,N){
        cumsum[i+1] = cumsum[i] + mint(10).modpow(N-1-i) * (S[i] - '0');
    }
    vector<int> cnt(P,0);
    ll ans = 0;
    rep(i,N+1){
        ans += cnt[cumsum[i].x];
        cnt[cumsum[i].x]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2196
#include<stdio.h>
 
int main (void)
 
{
int N,i;
int count = 0;
 
scanf("%d",&N);
 
for(i=1;i<(N+1)/2;i++)
{
if(i!=N - i)
count ++;
}
 
printf("%d",count);
 
return 0;
}

Measured memory_bytes: 128
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    let mut next = || { iter.next().unwrap() };
    input_inner!{next, $($r)*}
  };
  ($($r:tt)*) => {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
      bytes
        .by_ref()
        .map(|r|r.unwrap() as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect()
    };
    input_inner!{next, $($r)*}
  };
}
macro_rules! input_inner {
  ($next:expr) => {};
  ($next:expr, ) => {};

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

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

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

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

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

fn gcd(a: u64, b: u64) -> u64 {
  if b == 0 {
    a
  } else {
    gcd(b, a % b)
  }
}

fn main() {
  input!{
    N: u64,
  }
  let mut ans = 0;
  for i in 1..N+1 {
    for j in 1..N+1 {
      for k in 1..N+1 {
        if i > j || j > k {continue;}
        if i == j && j == k {
          ans += gcd(gcd(i, j), k) * 1;
        } else if i != j && j != k {
          ans += gcd(gcd(i, j), k) * 6;
        } else {
          ans += gcd(gcd(i, j), k) * 3;
        }
      }
    }
  }
  println!("{}", ans);

}



Measured memory_bytes: 2080
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        String ans = "";
       
        if( s.length() <= k ){
            ans = s;
        }else{
            ans = s.substring(0,k)+"...";
        }

        System.out.println( ans );

    }
}

Measured memory_bytes: 38640
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 1007;
const int MW = 20 * 1007;

ll f[MX][MW];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    vector<tuple<int, int, int>> a(n);
    for (auto& v : a) {
        cin >> get<0>(v) >> get<1>(v) >> get<2>(v);
    }

    sort(a.begin(), a.end(), [&](auto x, auto y) {
        return get<0>(x) + get<1>(x) < get<0>(y) + get<1>(y);
    });

    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j < MW; j++) {
            f[i + 1][j] = max(f[i + 1][j], f[i][j]);
            if (j <= get<1>(a[i]) && j + get<0>(a[i]) < MW) {
                f[i + 1][j + get<0>(a[i])] = max(f[i + 1][j + get<0>(a[i])], f[i][j] + get<2>(a[i]));
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < MX; i++) {
        for (int j = 0; j < MW; j++) {
            ans = max(ans, f[i][j]);
        }
    }

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



Measured memory_bytes: 157824
#include<iostream>
using namespace std;
int main() {
	int n;
	int a[250];
	cin >> n;
	for (int j = 0; j < n; j++) {
		cin >> a[j];
	}
	for (int j = 0; j < n; j++) {
		cout << "node " << j+1 << ": key = " << a[j]<<", " ;
			if (j != 0) {
				int k = (j -1)/ 2;
				cout << "parent key = " << a[k]<<", " ;
			}
			int right = j * 2 + 2;
			int left = j * 2 + 1;
			if (left < n) {
				cout << "left key = " << a[left] << ", ";
			}
			if (right < n) {
				cout << "right key = " << a[right] << ", ";
			}
			cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int x,a;
	cin >> x>>a;

	if (x < a) {
		cout << "0" << endl;
	} else {
		cout << "10" << endl;
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
//------------------変数-----------------------//

//-------------------関数----------------------//

int main() {
	ll x, y; cin >> x >> y; if (abs(x - y) <= 1) { cout << "Brown" << endl; }
	else { cout << "Alice" << endl; }
	return 0;
}





Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9 + 7

# map(int, input().split())
# list(map(int, input().split()))

N, K = map(int, input().split())

big_array = [0] * (10 ** 5 + 1)
for i in range(N):
    a, b = map(int, input().split())
    big_array[a] += b

count = 0
for i in range(1, 10 ** 5 + 1):
    count += big_array[i]
    if count >= K:
        print(i)
        break




Measured memory_bytes: 11836
#include <bits/stdc++.h>
#define INF 0x7f7f7f7f
using namespace std;
const int N = 15;
int G[N][N] = {};
int arr[N] = {};
int C[N] = {};
int n, m, x;
int ans = INF;
void dfs(int k, int cost) {
    if (cost >= ans) return;
    if (k == n + 1) {
        for (int i = 1; i <= m; i++)
            if (arr[i] < x) return;
        ans = cost;
    }
    for (int i = 1; i <= m; i++)
        arr[i] += G[k][i];
    dfs(k + 1, cost + C[k]);
    for (int i = 1; i <= m; i++)
        arr[i] -= G[k][i];
    dfs(k + 1, cost);
}
int main() {
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++) {
        cin >> C[i];
        for (int j = 1; j <= m; j++)
            cin >> G[i][j];
    }
    dfs(1, 0);
    cout << (ans == INF ? -1 : ans) << '\n';
    return 0;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	var S string
	fmt.Scanf("%s", &S)

	if len(S)%2 == 0 && (S[0:len(S)/2] == S[len(S)/2:len(S)]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    long long cnt=0;
    int mx=0;
    for(int i=0;i<n;i++)
    {
        mx=max(mx,arr[i]);
        cnt+=abs(arr[i]-mx);
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 4392
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    while(1){
        int n,l;
        cin >> n >> l;
        if(n==0) break;

        vector<int> d(n), p(n);
        int time = 0;
        for(int i=0; i<n; i++){
            char dir;
            int pos;
            cin >> dir >> pos;
            if(dir == 'L'){
                d[i]=-1;
                time = max(time, pos);
            }else{
                d[i]=1;
                time = max(time, l-pos);
            }
            p[i] = pos*2;
        }

        for(int t=1; t<=time*2; t++){
            for(int i=0; i<n; i++){
                p[i] += d[i];
            }
            for(int i=0; i<n; i++){
                for(int j=i+1; j<n; j++){
                    if(p[i]==p[j]){
                        if(t%2==0){ //narrow
                            d[i] = -d[i];
                            d[j] = -d[j];
                        }
                    }
                }
            }
        }

        int last;
        for(int i=0; i<n; i++){
            if(p[i]==l*2) last=i+1;
        }
        for(int i=0; i<n; i++){
            if(p[i]==0) last=i+1;
        }
        cout << time << " " << last << endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
	double x1, y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;

	double d = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
	printf("%lf\n", d);

	return 0;


}

Measured memory_bytes: 3212
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans = 0;
    if(b<n+1) {
        ans = (a*(b-1))/b;         
    }
    else {
        ans = (a*n)/b - a*(n/b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int X,Y;in(X,Y);
  if(X==1&&Y==1)out(1000000);
  else {
    int ans=0;
    if(X==1)ans+=300000;
    if(X==2)ans+=200000;
    if(X==3)ans+=100000;
    if(Y==1)ans+=300000;
    if(Y==2)ans+=200000;
    if(Y==3)ans+=100000;
    out(ans);
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 892