akhauriyash/Code-Regression huggingface dataset:
struct Scaner<'a> {
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Scaner<'a> {
    fn new(input: &'a str) -> Self {
        Scaner {
            iter: input.split_whitespace(),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        self.iter.next().unwrap().parse().unwrap()
    }
}

fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut sc = Scaner::new(&input);
    let k: i64 = sc.read();
    let q: i64 = sc.read();
    let d: Vec<i64> = (0..k).map(|_| sc.read()).collect();
    for _ in 0..q {
        let n: i64 = sc.read();
        let x: i64 = sc.read();
        let m: i64 = sc.read();
        let mut a = x % m;
        let mut cnt_eq = 0;
        for i in 0..k {
            let di = d[i as usize] % m;
            let cnt = (n - 2 + k - i) / k;
            if di == 0 {
                cnt_eq += cnt;
            } else {
                a += di * cnt;
            }
        }
        println!("{}", n - 1 - cnt_eq - a / m);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

constexpr int MOD = 1e9 + 7;
string K;
int D;
int dp[10004][2][102];
int rec(int i, bool less, int m) {
    if (i == SZ(K)) {
        return m == 0;
    }

    auto &DP = dp[i][less][m];
    if (DP != -1) return DP;
    
    int ret = 0;
    if (less) {
        REP(d, 10) {
            ret += rec(i + 1, true, (m + d) % D);
            ret %= MOD;
        }
    } else {
        ret += rec(i + 1, false, (m + (K[i] - '0')) % D);
        REP(d, K[i] - '0') {
            ret += rec(i + 1, true, (m + d) % D);
            ret %= MOD;
        }
    }
    return DP = ret;
}
signed main() {
    REP(i, 10004) REP(j, 2) REP(k, 102) dp[i][j][k] = -1;

    cin >> K >> D;
    cout << (rec(0, 0, 0) + MOD - 1) % MOD << endl;
    return (0^_^0);
}



Measured memory_bytes: 17024
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)a[i]=-1;
    for(int i=0;i<m;i++){
        int s,c;
        cin>>s>>c;
        if(s==1&&c==0&&n!=1){
            cout<<"-1"<<endl;
            return 0;
        }
        if(a[s-1]==-1)a[s-1]=c;
        else if(a[s-1]!=c){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]!=-1)cout<<a[i];
        else{
            if(i==0&&n!=1)cout<<"1";
            else cout<<"0";
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

#define B 100

char used[B + 1];

int good(int x, int y, int z) {
	return used[x] && used[y] && used[z];
}

int main() {
	int a11, a12, a13;
	int a21, a22, a23;
	int a31, a32, a33;
	int n, b;

	scanf("%d%d%d", &a11, &a12, &a13);
	scanf("%d%d%d", &a21, &a22, &a23);
	scanf("%d%d%d", &a31, &a32, &a33);
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &b);
		used[b] = 1;
	}
	printf(good(a11, a12, a13) || good(a21, a22, a23) || good(a31, a32, a33) || good(a11, a21, a31) || good(a12, a22, a32) || good(a13, a23, a33) || good(a11, a22, a33) || good(a13, a22, a31) ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 128
'use strict'

function main(input) {
  input = input.trim().split('\n')
  // .map(v => v.split(''))

  const n = Number(input[0])
  const str = input[1].split('')
  let max = 0
  for (let i = 1; i < n; i++) {
    const a = str.slice(0, i)
    const b = str.slice(i)
    const set = {}

    a.forEach(el => {
      set[el] = el
    })
    let tmp = 0
    Object.keys(set).forEach(el => {
      // console.log(el)
      if (b.find(v => v == el)) tmp++
    })
    max = Math.max(tmp, max)
  }
  console.log(max)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7740
#include<iostream>
using namespace std;
const int N=200009;
long long a[N],sum,ans;
int l,n;
int main() {
    cin>>n;
    l=1;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        while((sum^a[i])!=sum+a[i]) sum^=a[l++];
        ans+=i-l+1;
        sum^=a[i];  //sum+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

int f(int x) {
    if (x < 400) return 0;
    if (x < 800) return 1;
    if (x < 1200) return 2;
    if (x < 1600) return 3;
    if (x < 2000) return 4;
    if (x < 2400) return 5;
    if (x < 2800) return 6;
    if (x < 3200) return 7;
    return -1;
}

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    int cnt = 0;
    set<int> S;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] >= 3200) cnt++;
        else S.insert(f(A[i]));
    }
    if (cnt == N) {
        cout << 1 << " " << N << endl;
        return;
    } else if (cnt > 0) {
        cout << S.size() << " " << S.size() + cnt << endl;
        return;
    } else {
        cout << S.size() << " " << S.size() << endl;
        return;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
// Problem: D - ###
// Contest: AtCoder - AtCoder Regular Contest 071
// URL: https://atcoder.jp/contests/arc071/tasks/arc071_b
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 5, mod = 1e9 + 7;

int n, m;
int x[N], y[N];

#define temptts template <class T, class... Ts>
temptts int add(T f) { return f; } temptts int add(T f, Ts... ts) { return (f + add(ts...)) % mod; }
temptts int sub(T f) { return f; } temptts int sub(T f, Ts... ts) { return (f - sub(ts...) + 1ll * mod * mod) % mod; }
temptts int mul(T f) { return f; } temptts int mul(T f, Ts... ts) { return (1ll * f * mul(ts...)) % mod; }

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m;
  int sumx = 0, sumy = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    x[i] = (x[i] + mod) % mod;
    sumx = sub(sumx, mul(x[i], n - i));
  }
  for (int i = 1; i <= m; i++) {
    cin >> y[i];
    y[i] = (y[i] + mod) % mod;
    sumy = sub(sumy, mul(y[i], m - i));
  }
  for (int i = n; i >= 2; i--) {
    x[i] = add(x[i], x[i + 1]);
    sumx = add(sumx, x[i]);
  }
  for (int i = m; i >= 2; i--) {
    y[i] = add(y[i], y[i + 1]);
    sumy = add(sumy, y[i]);
  }
  cout << mul(sumx, sumy);
}

Measured memory_bytes: 4404
#include<stdio.h>
#define ck 26

int d;
int c[32];
int s[512][32];
int res[512];

int eval(){
  int i,j,lc[32],r=0;
  for(i=1;i<=ck;i++){lc[i]=-1;}
  for(i=0;i<d;i++){
    r+=s[i][res[i]];
    lc[res[i]]=i;
    for(j=1;j<=ck;j++){
      r-=c[j]*(i-lc[j]);
    }
  }
  return r;
}

int sum(int x){
  return (x*(x+1))/2;
}

int delq(int tg,int x){
  int r,i;
  int bfb=-1,bff=d,afb=-1,aff=d;
  r=s[tg][x]-s[tg][res[tg]];

  for(i=tg-1;i>=0;i--){
    if(res[i]==res[tg]){bfb=i;break;}
  }
  for(i=tg+1;i<d;i++){
    if(res[i]==res[tg]){bff=i;break;}
  }

  for(i=tg-1;i>=0;i--){
    if(res[i]==x){afb=i;break;}
  }
  for(i=tg+1;i<d;i++){
    if(res[i]==x){aff=i;break;}
  }
  
  r+=c[res[tg]]*sum((tg-bfb)-1);
  r+=c[res[tg]]*sum((bff-tg)-1);
  r-=c[res[tg]]*sum((bff-bfb)-1);

  r-=c[x]*sum((tg-afb)-1);
  r-=c[x]*sum((aff-tg)-1);
  r+=c[x]*sum((aff-afb)-1);
  return r;
}

int main(){
  int i,j,q,r,tg,x;
  scanf("%d",&d);
  for(i=1;i<=ck;i++){scanf("%d",&c[i]);}
  for(i=0;i<d;i++){
    for(j=1;j<=ck;j++){
      scanf("%d",&s[i][j]);
    }
  }
  for(i=0;i<d;i++){
    scanf("%d",&res[i]);
  }
  r=eval();
  scanf("%d",&q);
  while(q>0){
    q--;
    scanf("%d%d",&tg,&x);
    tg--;
    r+=delq(tg,x);
    res[tg]=x;
    printf("%d\n",r);
  }
  return 0;
}

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

int main() {
  int N,dist,count=0;
  cin >> N >> dist;
  for (int i=0;i<N;i++) {
    double x,y;
    cin >> x >> y;
    if (sqrt(x*x+y*y)<=dist) count++;
  }
  cout << count;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define cel(xx,yy) (xx+yy-1)/yy
using namespace std;
int T,n,k,d,tp,ans;
int main(){
	for(scanf("%d",&T);T--;){
		scanf("%d%d",&n,&k);
		for(;n%k;){
			d=cel(n,k),tp=cel(n-(d-1)*k,d);
			n-=tp*d;
	//		cerr<<n<<' ';
		}
	//	cerr<<endl;
		ans^=n/k;
	}
	puts(ans?"Takahashi":"Aoki");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
//2≤N≤200000
//N is even.
//1≤Xi≤109
//All values in input are integers.

using namespace std;
long long s[200005];
long long B[200005];
inline bool cmp(int x,int y){
	return s[y]>s[x];
}
long long p[200005];
int main()
{   
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&s[i]);
		p[i]=i;
	}
	sort(p+1,p+n+1,cmp);
	sort(s+1,s+n+1);
	long long a=n/2,b=n/2+1;
	for(int i=1;i<=n;i++)
	{   
	   if(i<=a) B[ p[i] ] = s[b];
	   else B[p[i]]=s[a];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<B[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc1 = new Scanner(System.in);
		String line1 = sc1.nextLine();

		String[] inputText = line1.split(" ");

		int a = Integer.parseInt(inputText[0]) + Integer.parseInt(inputText[1]);
		int b = Integer.parseInt(inputText[2]);
		int c = a - b;

		if (c < 0) {
			System.out.print("No");
		} else {
			System.out.print("Yes");
		}
	}
}


Measured memory_bytes: 27040
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define VMAX 1002
#define EMAX 2002
#define INF (long long )1e18

//??????????????¢??????????????¨debug()??????????????????
// #define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
	ll from,to,cost;
};
edge es[EMAX];
ll V,E,r,ans,d[VMAX];
string S;
static const ll dx[8] = {0,1,1,1,0,-1,-1,-1},
dy[8] = {1,1,0,-1,-1,-1,0,1};
bool shortest_path(ll s){
	Fill(d,INF);
	d[s] = 0;
	bool	update = false;
	int j = 0;
	do{
		update = false;
		for (ll i = 0; i < E; ++i)
		{
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(j == V-1 && update){
			return true;
		}
		j++;
	}while(update);
	return false;
}

void solve(){
	if(shortest_path(r)){
		ans = INF;
	}
}

void debug(){
	for (ll i = 0; i < V; ++i)
	{
		cout << d[i] << " ";
	}
	cout << "\n";
}

void answer(){
	if(ans == INF){
		cout << "NEGATIVE CYCLE\n";
	}else{
		for (ll i = 0; i < V; ++i)
		{
			if(d[i] == INF){
				cout << "INF\n";
			}else{
				cout << d[i] << "\n";
			}
		}
	}
}

int main(){
	cin >> V >> E >> r;
	for (ll i = 0; i < E; ++i)
	{
		ll a,b,c;
		cin >> a >> b >> c;
		es[i] = (edge){a,b,c};
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int a[MAXN], b[MAXN], c[MAXN];
int X, n, q, r[MAXN];
int main() {
	read(X), read(n);
	b[0] = X;
	for (int i = 1; i <= n; i++) {
		read(r[i]);
		if (i % 2 == 1) {
			int delta = r[i] - r[i - 1];
			if (c[i - 1] >= delta) {
				a[i] = a[i - 1];
				b[i] = b[i - 1];
				c[i] = c[i - 1] - delta;
				continue;
			}
			int tmp = c[i - 1] + b[i - 1] - a[i - 1];
			if (tmp <= delta) {
				a[i] = b[i] = X;
				c[i] = 0;
				continue;
			}
			a[i] = a[i - 1] + delta - c[i - 1];
			b[i] = b[i - 1];
			c[i] = 0;
		} else {
			int delta = r[i] - r[i - 1];
			int tmp = c[i - 1] + b[i - 1] - a[i - 1];
			if (X - tmp >= delta) {
				a[i] = a[i - 1];
				b[i] = b[i - 1];
				c[i] = c[i - 1] + delta;
				continue;
			}
			if (X - c[i - 1] <= delta) {
				a[i] = b[i] = 0;
				c[i] = X;
				continue;
			}
			a[i] = a[i - 1];
			b[i] = b[i - 1] - (delta - (X - tmp));
			c[i] = X - (b[i] - a[i]);
		}
	}
	read(q);
	int pos = 0;
	for (int i = 1; i <= q; i++) {
		int t, x;
		read(t), read(x);
		while (pos < n && t >= r[pos + 1]) pos++;
		int tmp = c[pos], tnp = t - r[pos];
		if (x >= b[pos]) tmp = c[pos] + b[pos] - a[pos];
		else if (x >= a[pos]) tmp = c[pos] + x - a[pos];
		if (pos & 1) tmp = min(tmp + tnp, X);
		else tmp = max(tmp - tnp, 0);
		printf("%d\n", tmp);
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    if(n%2==0){
        for(int i=n-1;i>0;i-=2) cout<<v[i]<<" ";
        for(int i=0;i<n;i+=2) cout<<v[i]<<" ";
        cout<<endl;
    }else{
        for(int i=n-1;i>=0;i-=2) cout<<v[i]<<" ";
        for(int i=1;i<=n-1;i+=2) cout<<v[i]<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   
    char s;
    cin >> s;
    if(s == 'A'){
        cout << 'T' << endl;
    }else if(s == 'T'){
        cout << 'A' << endl;
    }else if(s == 'C'){
        cout << 'G' << endl;
    }else{
        cout << 'C' << endl;
    }
}



Measured memory_bytes: 256
from copy import deepcopy

n = int(input().strip())
x = list(map(int, input().split()))
y = deepcopy(x)
y.sort()
m1 = y[n // 2 - 1]
m2 = y[(n // 2)]

for e in x:
    if e <= m1:
        print(m2)
    else:
        print(m1)


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

long long N, K;

int main() {
	cin >> N >> K;
	long long S1 = N / K;
	long long S2 = 0; if (K % 2 == 0) { S2 = (N + K / 2) / K; }
	cout << S1 * S1 * S1 + S2 * S2 * S2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main(){
  string S;
  cin >> S;
  
  string news = "NEWS";
  string swen = "SWEN";
  
  int casei;
  rep(i,4){
    if(S[0]==news[i]){
    casei = i;
    }
  }
  
  auto judge2 = [&](string S){
    int casei;
    int flag = 0;
    rep(i,4){
       if(S[0]==news[i]){
          casei = i;
       }
    }
    rep(i,S.size()){
       if((S[i]!=news[casei])&&(S[i]!=swen[casei])){
           return false;
       }
      else if(S[i]==swen[casei]){
         flag=1;
      }
    }
    if(flag){return true;}
    else{return false;}
  };
  
  auto judge4 = [&](string S){
    vector<int> flag(4,0);

    rep(i,S.size()){
      rep(j,4){
         if(S[i]==news[j]){
            flag[j]=1;
         }
      }
    }
    return flag[0]*flag[1]*flag[2]*flag[3];
  };
  
  if(judge2(S)||judge4(S)){
    cout << "Yes" << endl;
    }
  else{
     cout << "No" << endl;
  }
    
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N, M;
    cin >> N;
    vector<int> T(N);
    for (int i=0; i<N; i++){
        cin >> T.at(i);
    }
    cin >> M;
    vector<int> P(M), X(M);
    for (int i=0; i<M; i++){
        cin >> P.at(i) >> X.at(i);
    }
    for (int i=0; i<M; i++) {
        int p = P.at(i)-1;
        int q = T.at(p);
        T.at(p) = X.at(i);
        int sum = 0;
        for (int j=0; j<N; j++){
            sum += T.at(j);
        }
        cout << sum << endl;
        T.at(p) =q;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#define lli long long int

lli bigger(const void *a, const void *b)
{
	if(*(lli *)a > *(lli *)b)
	{
		return -1;
	}
	else if (*(lli *)a == *(lli *)b)
	{
		return 0;
	}
	return 1;
}
int main(void)
{
	lli n;
	scanf("%lld", &n);

	lli a[n];
	lli index =0;
	while (index <n)
	{
		scanf("%lld",&a[index]);
		index++;
	}
	qsort((void *)a, (size_t)n, sizeof(a[0]), bigger);
	index = 0;
	while (index < n-1)
	{
		if(a[index] - a[index+1] == 0)
		{
			printf("NO\n");
			return (0);
		}
		index++;
	}

	printf("YES\n");
	return(0);
}



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

int main(void){
    int h,w;
    string tmp;
    cin>>h>>w;
    for(int i=0;i<h+2;i++){
        if(i==0||i==h+1){
            for(int j=0;j<w+2;j++) cout<<"#";
            cout<<endl;
        }else{
            cin>>tmp;
            cout<<"#"+tmp+"#"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int r;
    cin >> r;
    cout << 2*r*3.141592;
}

Measured memory_bytes: 3788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
        public static void main(String[] args) throws Exception {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st;
                int n = Integer.parseInt(br.readLine());

                int a[] = new int[n];
                st = new StringTokenizer(br.readLine());
                for(int i=0 ; i<n ; i++) {
                        a[i] = Integer.parseInt(st.nextToken());
                }

                int b[] = new int[n];
                st = new StringTokenizer(br.readLine());
                for(int i=0 ; i<n ; i++) {
                        b[i] = Integer.parseInt(st.nextToken());
                }

                int c[] = new int[n];
                st = new StringTokenizer(br.readLine());
                for(int i=0 ; i<n-1 ; i++) {
                        c[i] = Integer.parseInt(st.nextToken());
                }

                long sum = b[a[0]-1];
                int last = a[0];
                for(int i=1 ; i<n ; i++) {
                        int x = a[i];
                        if(x == last+1) {
                                sum += c[x-2];
                        }
                        sum += b[x-1];
                        last = x;
                }

                System.out.println(sum);
        }
}



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

using namespace std;

const int maxn = 1e5 + 5;
int n, k;
int x[maxn];

int cal(int l, int r) {
	if (x[r] <= 0) return -x[l];
	else if (x[l] >= 0) return x[r];
	return min(-2*x[l]+x[r], -x[l]+2*x[r]);
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> x[i];
	int ans = cal(0, k-1);
	for (int i = 0; k+i-1 < n; ++i)
		ans = min(ans, cal(i, k+i-1));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rint register int
#define inf 0x3f3f3f3f
#define MAXN 1000001
#define max(a, b)  (!((a) < (b)) ? (a) : (b))
#define min(a, b)  ((a) < (b) ? (a) : (b))
#pragma GCC optimize(2)
#pragma GCC diagnostic error "-std=c++14"
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
using namespace std;

int n,m;
char a[101][101];
int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(rint i=1;i<=m+2;i++)cout<<"#";
	cout<<endl;
	for(rint i=1;i<=n;i++){
		cout<<"#";
		for(rint j=1;j<=m;j++)cout<<a[i][j];
		cout<<"#\n";
	}
	for(rint i=1;i<=m+2;i++)cout<<"#";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, K;
int A[50][200010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;

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

    K = min(K, 49);
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= N; j++){
            A[i][max(1, j - A[i - 1][j])]++;
            A[i][min(j + A[i - 1][j] + 1, N + 1)]--;
        }

        for(int j = 1; j <= N; j++){
            A[i][j + 1] += A[i][j];
        }
    }

    for(int i = 1; i <= N; i++){
        cout << A[K][i];
        if(i != N) cout << " ";
        else cout << endl;
    }
    return 0;
}


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

int main() {
	int n;
	std::string s[3];
	std::cin >> n;

	for(auto&e:s)
		std::cin >> e;

	auto ans = 0;
	for (int i{}; i < n; ++i) {
		int lc = 0;
		for (int j{}; j < 3; ++j) {
			for (int k{}; k < 3; ++k) {
				if (j == k)
					continue;

//				std::cout << j << "," << k << " " << s[j][i] << " " << s[k][i] << "\n";
				lc += s[j][i] == s[k][i] ? 0 : 1;
			}
		}
		ans += lc == 0 ?
				0: lc == 4 ? 1 : 2;
	}
	std::cout << ans << "\n";
}

Measured memory_bytes: 256
//43
#include<iostream>

using namespace std;

int main(){
  int lot[31];
  for(int i=1;i<=30;i++){
    lot[i]=i;
  }
  int w,n;
  cin>>w>>n;
  for(int i=0;i<n;i++){
    int a,b;
    (cin>>a).ignore()>>b;
    swap(lot[a],lot[b]);
  }
  for(int i=1;i<=w;i++){
    cout<<lot[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
int main() {
  int n,z,w,a[2000],i;
  scanf("%d %d %d",&n,&z,&w);
  for (i = 0; i < n; i++) {
    scanf("%d",&a[i]);
  }
  if (abs(a[n-1]-w)<abs(a[n-2]-a[n-1])) {
    printf("%d\n",abs(a[n-2]-a[n-1]));
  } else {
    printf("%d\n",abs(a[n-1]-w));
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[100005];
bool vis[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)vis[i]=false;
	int nw=1,res=0;
	while(true)
	{
		if(nw==2)break;
		if(vis[nw])
		{
			res=-1;
			break;
		}
		vis[nw]=true;
		nw=a[nw];
		res++;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 768
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
ll dp[122][122],visit[122][122]; 
ll lol=0;
ll compute(ll a, ll b){
	if(visit[a][b])
		return dp[a][b];
	ll i,j;
	i=a;
	j=b;
	visit[i][j]=1;
	if(i==j){
		dp[i][j]=-1;
		return dp[i][j];
	}
	if(i<j){
		dp[i][j]=1000;
		return dp[i][j];
	}

	dp[a][b]=1000;
	ll haha;
	f(i,1,a+1){
		
		if(lol&(1LL<<i)){
			haha=-1;
		}
		else{
			haha=i;
		}
		dp[a][b]=min(dp[a][b],max(haha,compute(a%i,b)));
			//return dp[a][b];
		
	}
	//cout<<a<<" "<<b<<" "<<dp[a][b]<<endl;
	return dp[a][b];
}
ll p[123],q[123];
int main(){
    ll n;
    cin>>n;
    ll i,j;
    rep(i,n){
    	cin>>p[i];
    }
    rep(i,n){
    	cin>>q[i];
    }
    ll cnt=0;
    lol=0;
    //wow=(1LL<<51)-1;
    rep(i,n){
    	if(compute(p[i],q[i])<1000){
    		//cout<<compute(p[i],q[i])<<endl;
    		cnt++;
    	}
    }
    //return 0;
    //cout<<cnt<<endl;
    if(cnt!=n){
    	cout<<-1<<endl;
    	return 0;
    }

    ll ans=0,k;
    fd(i,51,0){
    	rep(j,51){
    		rep(k,51){
    			visit[j][k]=0;
    		}
    	}
    	lol=ans;
    	//cout<<lol<<endl;
    	ll mini=-1;
    	rep(j,n){

    		mini=max(mini,compute(p[j],q[j]));
    	}
    	//cout<<mini<<endl;
    	if(mini==-1){
    		cout<<ans<<endl;
    		return 0;
    	}
    	ans+=(1LL<<mini);
    	//cout<<ans<<endl;
    }

    
}



Measured memory_bytes: 384
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

int beki(int x, int p) {
    int ans = 1;
    while (p != 0) {
        ans *= x;
        p--;
    }
    return ans;
}

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

    int x;
    cin >> x;

    int ans = 1;
    FOR(i, 1, 100) {
        FOR(j, 2, 100) {
            int tmp = beki(i, j);
            if (tmp <= x) {
                ans = max(ans, tmp);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair<int, int> P;

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

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

    vector<int> p(n * n);
    for (int i = 0 ; i < n * n; i++) {
        cin >> p[i];
        p[i]--;
    }

    vector<vector<bool>> exist(n, vector<bool>(n, true));
    vector<vector<int>> s(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            s[i][j] = min(min(i, n - i - 1), min(j, n - j - 1));
        }
    }

    int ans = 0;
    for (int elm : p) {
        int i = elm / n;
        int j = elm % n;

        ans += s[i][j];
        exist[i][j] = false;

        queue<P> q;
        q.push({i, j});

        while (!q.empty()) {
            P val = q.front();
            q.pop();

            int x = val.first;
            int y = val.second;

            for (int k = 0; k < 4; k++) {
                int nx = x + dx[k];
                int ny = y + dy[k];

                if (nx < 0 || ny < 0) continue;
                if (nx >= n || ny >= n) continue;
                if (s[nx][ny] <= s[x][y] + (exist[x][y] == true)) continue;

                s[nx][ny] = s[x][y] + (exist[x][y] == true);
                q.push({nx, ny});
            }
        }
    }

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

Measured memory_bytes: 5376
n = int(input())
v = list(map(int,input().split()))
i = len(v)-1

for i in range(n-1):
    v.sort()
    new_num = (v[0] + v[1]) / 2
    v[0] = new_num
    v.sort
    v.remove(v[1])

print(new_num)

'''
    for j in range((n-1)-i):
        if j == 0:
            v[j] = new_num
        else:
            v.remove(v[len(v)-1])

'''


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

const int mn=105;
int p,pos[205],x,n;

int main()
{
	scanf("%d%d",&x,&n);
	for(int i=1;i<=n;++i) {scanf("%d",&p);pos[p+100]=1;}
	int tmp=200,ans=0;
	for(int i=-10;i<=101;++i) {
		if(pos[i+100]) continue;
		if(tmp>abs(x-i)) tmp=abs(x-i),ans=i;
	}
	cout<<ans;
}

Measured memory_bytes: 3764
n,Q=map(int,input().split())
s=input()

a=[0]*(n+1)
for i in range(2,n+1):
    if s[i-2]=='A' and s[i-1]=='C':
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]

for i in range(Q):
    l,r=map(int,input().split())
    print(a[r]-a[l])

Measured memory_bytes: 6164
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	vector<int> v;
	int main()
	{
		//#ifndef ONLINE_JUDGE
    	// for getting input from input.txt
    	//freopen("inputf.txt", "r", stdin);
    	// for writing output to output.txt
    	//freopen("outputf.txt", "w", stdout);
		//#endif
		// cin.ignore(); must be there when using getline(cin, s)
		
		int n;
		cin>>n;
		int temp;
		vector<int> v;
		v.push_back(0);
		for (int i = 0; i < n; ++i)
		{
			cin>>temp;
			v.push_back(temp);

		}
		int l[n+1],r[n+2];
		l[0]=0;r[n+1]=0;
		for(int i=1;i<=n+1;i++)
		{
			l[i]=__gcd(l[i-1],v[i-1]);
			r[n+1-i]=__gcd(r[n+2-i],v[n+1-i]);

		}
		int ans=1;
		for(int i=1;i<=n;i++)
		{
			//cout<<i<<" "<<l[i]<<" "<<r[i]<<endl;
			ans=max(ans,__gcd(l[i],r[i+1]));
		}
		cout<<ans;

	}

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

int main() {
  int x;
  int a; 
  int s, s1,s2,s3;
  
  cin >> x;

//    s = 0 ;
    s1 = 0;
    s2 = 0;
    s3 = 0;
    
    a = x / 100 ;
    if (a > 0) {
        s1 = 1 ;
//        s = 1;
        x = x - 100 ;
    }
    
    a = x / 10 ;
    
    if (a > 0) {
        s2 = 1 ;
//        s = s + 1
        x = x - 10 ;
    }
    
    a = x / 1 ;
    
    if (a > 0) {
//        s = s +1;
        s3 = 1 ;
    }
    
    s = s1 + s2 + s3;
    
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>

#define repAll(n) (n).begin(), (n).end()
#define repConAll(n) (n).cbegin(), (n).cend()

using namespace std;

namespace {

}

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

	cin >> N >> A >> B;

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

		int tmp = i;
		int sum = 0;
		for (int j = 0; j < 5 && tmp != 0 ; ++j){
			int curNum = tmp % 10;
			sum += curNum;
			tmp /= 10;
		}

		if (A <= sum && sum <= B){
//			cout << i << endl;
			sumAll += i;
		}
	}

	cout << sumAll << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] a = new int[n + 1];
    int[] b = new int[n];
    long ans = 0;

    for (int i = 0; i <= n; i++) {
      a[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      b[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      if (a[i] > b[i]) {
        a[i] -= b[i];
        ans += b[i];
        b[i] = 0;
      } else {
        b[i] -= a[i];
        ans += a[i];
        a[i] = 0;
        if (a[i + 1] > b[i]) {
          a[i + 1] -= b[i];
          ans += b[i];
          b[i] = 0;
        } else {
          b[i] -= a[i + 1];
          ans += a[i + 1];
          a[i + 1] = 0;
        }
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 60048
import itertools
import math
import bisect

n = int(input())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))

nl = []
a = 0
b = 0
for i in range(1,n+1) :
  nl.append(i)
  a += al[i-1]*10**(n-i)
  b += bl[i-1]*10**(n-i)

ans = [0 for i in range(math.factorial(n))]
index = -1
for num in itertools.permutations(nl):
  index += 1
  for i in range(1,n+1) :
      ans[index] += num[i-1]*10**(n-i)

print(abs(bisect.bisect_left(ans,a)-bisect.bisect_left(ans,b)))

Measured memory_bytes: 4736
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    large x = min({a,b,c,d,e}); // bottle-neck

    large group = (n + x - 1) / x;
    large t = (group - 1) + 5;


    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
#include<string.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int n, m, i, j, l, r, a, b;
    while (cin >> n>>m)
    {
        cin >> a >> b;
        for (i = 2;i <= m;i++)
        {
            cin >> l >> r;
            if (l > a)a = l;
            if (r < b)b = r;
        }
        b -= a;
        b++;
        if (b < 0)
            cout << 0 << '\n';
        else cout << b << '\n';
    }
}

Measured memory_bytes: 256
# -- coding: utf-8 --
n, a, b = map(int, input().split(' '))
os_a = a - 1
os_b = n - b
gap = b - a - 1
if os_a == 0 and gap == 0:
    print('Borys')
elif gap % 2 == 0:
    print('Borys')
else:
    print('Alice')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define inf 200000000
const int maxnodes=1005;
#define ll long long
#define N 300000
#define EPS 0.01
#define ld long double

int be[N];
int rt[N];
int subs[N],trick[N];
vector<int> g[N];
int t = 0;
void dfs(int s,int p)
{
    subs[s] = 1;
    be[s] = ++t;
    rt[t] = s;
    for(auto it : g[s])
    {
        if(it != p)
        {
            dfs(it,s);
            subs[s] += subs[it];
        }
    }
}

int32_t main()
{
    IOS;

    memset(trick,0,sizeof(trick));
    int n;
    cin >> n;
    int q;
    cin >> q;
    for(int i = 0;i < n - 1;i++)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,1);
    while(q--)
    {
        int p,x;
        cin >> p >> x;
        trick[be[p]] += x;
        trick[be[p] + subs[p]] -= x;
    }
    int c = 0;
    for(int i = 0;i < n + 1;i++)
    {
        c += trick[i];
        trick[i] = c;
    }
    vector<int> ans(n+1);
    for(int i = 1;i <= n;i++)
    {
        ans[rt[i]] = trick[i];
    }
    for(int i = 1;i <= n;i++)
        cout << ans[i] << " ";
}

Measured memory_bytes: 35968
import java.util.*;

class Main{

    static List<LinkedList<Integer>> kaito;
/*
    public static void kurikaesi(int x) {
        int[][] card = new int[x][2];


        for(int i=0; i<x; i++){
            Scanner sc = new Scanner(System.in);
            String line = sc.nextLine();
            String[] data = line.split(" ");
            card[i][0] = Integer.parseInt(data[0]);
            card[i][1] = Integer.parseInt(data[1]);
        }


        int goukei_A = 0, goukei_B = 0;

        for(int[] item : card){
            if(item[0] > item[1]){
                goukei_A += item[0] + item[1];
            }else if(item[0] < item[1]){
                goukei_B += item[0] + item[1];
            }else{
                goukei_A += item[0];
                goukei_B += item[0];
            }

        }

        LinkedList<Integer> kari = new LinkedList<Integer>();
        kari.add(goukei_A);
        kari.add(goukei_B);

        kaito.add(kari);
        

    }*/

    public static void main(String[] args) {
        kaito = new LinkedList<>();
        Scanner sc = new Scanner(System.in);

        while (true) {
            
            String line = sc.nextLine();
            int n = Integer.parseInt(line);

            if(n == 0){
                break;
            }else{

                int[][] card = new int[n][2];
                for(int i=0; i<n; i++){
                    String line1 = sc.nextLine();
                    String[] data = line1.split(" ");
                    card[i][0] = Integer.parseInt(data[0]);
                    card[i][1] = Integer.parseInt(data[1]);
                }
                int goukei_A = 0, goukei_B = 0;

                for(int[] item : card){
                    if(item[0] > item[1]){
                        goukei_A += item[0] + item[1];
                    }else if(item[0] < item[1]){
                        goukei_B += item[0] + item[1];
                    }else{
                        goukei_A += item[0];
                        goukei_B += item[0];
                    }

                }

                LinkedList<Integer> kari = new LinkedList<Integer>();
                kari.add(goukei_A);
                kari.add(goukei_B);

                kaito.add(kari);
                
            }

        }


        for(LinkedList<Integer> item : kaito){
            int c = 0;
            for(int it : item){
                System.out.print(it);
                if(c == 0){
                    System.out.print(" ");
                    c += 1;
                }
            }
            System.out.println();
        }

    }

}

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

string str, temp;
int k, x;
bool a[11], flag, flag2;
int main()
{
	cin >> str >> k;
	while(k--)
		cin >> x, a[x] = true;
	temp = str;
	for(int i = 0; i < str.size(); ++i)
	{
		if(str.size() > temp.size() || str[i] > temp[i] && !a[str[i] - '0'])
					flag = true;
		if(a[str[i] - '0'])
		{
			if(!flag && temp.size() == str.size())
			{
				for(int j = str[i] - '0'; j < 10; ++j)
				{
					if(!a[j])
					{
						flag2 = true;
						str[i] = j + '0';
						break;
					}
				}
				if(!flag2)
				{
					if(i != 0)
						str[i - 1] = ((str[i - 1] - '0') + 1) + '0';
					else
						str = '1' + str;
					i = max(i - 2, -1);
					str[i] = 0;
				}
				flag2 = false;
			}
			else
			{
				for(int j = 0; j < 10; ++j)
				{
					if(!a[j])
					{
						if(i == 0 && j == 0) continue;
						str[i] = j + '0';
						break;
					}
				}
			}
			if(str.size() > temp.size() || str[i] > temp[i] && !a[str[i] - '0'])
						flag = true;
		}
	}
	cout << str;
}


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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#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 LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) {
    cout << s << endl;
  }
  else {
    cout << "red" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
     int N,counter,D;
     cin>>N>>D;
     counter =0;
     for(int i=0;i<N;i++){
         long x,y;
         cin>>x>>y;
         if(D>=sqrt(x*x+y*y))counter++;
     }
     cout<<counter;

    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define read_file()                   \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout);
 
int32_t main(){
IOS;
int n; cin>>n;
int a[n],p[n],dp[n][n];
for(int i=0;i<n;i++) cin>>a[i];
p[0] = a[0];
for(int i=1;i<n;i++) p[i] = p[i-1] + a[i];
for(int i=0;i<n;i++) dp[i][i] = 0;
for(int i=0;i<n-1;i++) dp[i][i+1] = a[i] + a[i+1];
for(int k=3;k<=n;k++){
    for(int i=0;i<n-k+1;i++){
        int j = i+k-1;
        dp[i][j] =  LLONG_MAX;
        for(int l = i+1;l<=j;l++){
            dp[i][j] = min(dp[i][j] , dp[i][l-1] + dp[l][j] + p[j] - (i-1>=0 ? p[i-1] : 0));
        }
    }
}
cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 1536
using System;
using System.IO;

namespace contest
{
    class Program
    {
        static void Main(string[] args)
        {
            solve_abc125_a();
        }

        public static void solve_abc125_a()
        {
            string[] abt = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(abt[0]);
            int b = Convert.ToInt32(abt[1]);
            int c = Convert.ToInt32(abt[2]);

            int count = 0;
            int i = 1;
            while (i * a <= c)
            {
                count += b;
                i++;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int F[N][10], P[N][11], f[10];

int main() {
	int n;cin>>n;
	rep(i,n) rep(j,10) cin>>F[i][j];
	rep(i,n) rep(j,11) cin>>P[i][j];
	long long ans=-INFL;
	rep1(i,(1<<10)-1) {
		int i2=i;
		rep(j,10) {f[j]=i2%2;i2/=2;}
		long long ans_t=0;
		rep(j,n) {
			int c=0;
			rep(k,10) c+=f[k]*F[j][k];
			ans_t+=P[j][c];
		}
		ans=max(ans,ans_t);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
template <typename T, typename U>
T max(T x, U y)
{
    return x>y ? x : y;
}
template <typename T, typename U>
T min(T x, U y)
{
    return x<y ? x : y;
}
ll dp[101][100001];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,w;cin >> n >> w;
    ll a[n],b[n];
    ll d=0;
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];cin >> b[i];d+=b[i];
    }
    for (int i = 0; i <= n; ++i)
    {
    	for (int j = 0; j <= d; ++j)
    	{
    		dp[i][j]=1e18;
    	}
    }
    /*for (int i = 0; i <=n; ++i)
    {
    	for (int j = 0; j <=w; ++j)
    	{
    		trace(dp[i][j]);
    	}
    }*/
    ll ans =-1;
    for (int i = 0; i <= n; ++i)
    {
    	for (int j = 0; j <= d; ++j)
    	{
    		if(i==0 and j==0)dp[i][j]=0;
    		else if(i==0)dp[i][j]=1e18;
    		else if(j==0)dp[i][j]=0;
    		else if(b[i-1]<=j)dp[i][j]=min(dp[i-1][j],dp[i-1][j-b[i-1]]+a[i-1]);
    			else dp[i][j]=min(dp[i][j],dp[i-1][j]);
    		
    	}
    }
    
    	for (int j = 0; j <=d; ++j)
    	{
    		if(dp[n][j]<=w and ans<j)ans=j;
    	}
    
    cout << ans;
    }

Measured memory_bytes: 79232
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

    while (true) {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    }
  }

}

Measured memory_bytes: 32524