akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;

int a[N];

int main()
{
      int n, ans = 0;
      cin >> n;
      for (int i = 1; i <= n; i ++) {
            cin >> a[i];
      }
      for (int i = 2; i < n; i ++) {
            int b = a[i - 1], c = a[i + 1];
            if (b > c) swap(b, c);
            if (b < a[i] && a[i] < c) ans ++;
      }
      cout << ans << endl;
      return 0;
}











Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int a = Integer.valueOf(arr01[0]);
        int b = Integer.valueOf(arr01[1]);
        int c = Integer.valueOf(arr01[2]);

        if (a == b && b == c && a == c) {
            System.out.println("No");
        } else if (a != b && b != c && c != a) {
            System.out.println("No");

        } else {
            System.out.println("Yes");

        }

    }
}


Measured memory_bytes: 21076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(ALL(a));
  if (a[0] != a[1]) cout << a[0] << endl;
  else cout << a[2] << endl;
}

Measured memory_bytes: 256
fn main() {
    let mut s = read::<String>();
    let qnum = read::<u32>();

    let mut rev = false;
    let mut qs = vec![];
    for _ in 0..qnum {
        let line = read_vec::<String>();
        if line[0] == "1" {
            rev = !rev;
        }
        qs.push(line);
    }

    //if rev {
    //        s = s.chars().rev().collect::<String>();
    //    }

    rev = false;
    for q in qs {
        let t: u32 = q[0].parse().ok().unwrap();
        if t == 1 {
            rev = !rev;
        } else {
            let f: u32 = q[1].parse().ok().unwrap();
            let c: char = q[2].clone().chars().collect::<Vec<_>>()[0];
            if f == 1 {
                if !rev {
                    s.insert(0, c);
                } else {
                    s.push(c);
                }
            } else {
                if !rev {
                    s.push(c);
                } else {
                    s.insert(0, c);
                }
            }
        }
    }
    if rev {
        s = s.chars().rev().collect::<String>();
    }
    println!("{}", s);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 33020
#include <iostream>
#include<string>
#include<vector>

using namespace std;

#define BITCOIN 380000.0

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

	vector<double> x;
	vector<string> u;

	for (int i = 0; i < n; i++) {
		double wkd;
		string wku;

		cin >> wkd >> wku;
		
		x.push_back(wkd);
		u.push_back(wku);

	}

	double ans = 0;

	for (int i = 0; i < n; i++) {
		if (u[i] == "JPY") {
			ans += x[i];
		}
		else {
			ans += x[i] * BITCOIN;
		}
	}
	
	cout << ans << endl;


	return 0;
}



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

using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0)
            alice += a[i];
        else
            bob += a[i];
    }
    cout << alice - bob << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int m,int n){
    if(m>n){swap(m,n);}
    if(m==0){return n;}
    else{return gcd(n%m,m);}
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,M,k,g;
    cin>>n>>k;
    cin>>a;
    g=a;
    M=a;
    for(int i=1;i<n;i++){
        cin>>a;
        g=gcd(g,a);
        M=max(M,a);
    }
    if(k%g==0&&k<=M){cout<<"POSSIBLE";}
    else{cout<<"IMPOSSIBLE";}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int x, y;
	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		if (x < y)
			swap(x, y);
		int i=0;
		for (; y != 0; i++) {
			x %= y;
			swap(x, y);
		}
		cout << x << ' ' << i << endl;
	}
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	
    	int t[] = new int[n+1];
    	int x[] = new int[n+1];
    	int y[] = new int[n+1];
    	
    	t[0] = 0 ;
    	x[0] = 0 ;
    	y[0] = 0 ;
    	
    	boolean result = true;
    	
    	for(int i = 1; i <= n; i++) {
    		t[i] = sc.nextInt();
    		x[i] = sc.nextInt();
    		y[i] = sc.nextInt();
    		
    		int tempx = Math.abs(x[i] - x[i-1]);
    		int tempy = Math.abs(y[i] - y[i-1]);
    		int tempt = Math.abs(t[i] - t[i-1]);
    		
    		if ((tempx + tempy)> tempt) {
    			result = false;
    			break;
    		}
    		
    		if ((tempx +tempy) %2 != tempt %2) {
    			result = false;
    			break;
    		}
    	}
    	
    	sc.close();
    	
    	if (result) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
    }
}


Measured memory_bytes: 90528
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(){
    string s,t;
    int a,b;
    string u;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if (u.compare(s)==0) {
        cout<<(a-1)<<" "<<b<<endl;
    }else{
        cout<<a<<" "<<(b-1)<<endl;
    }
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

vector<int> e[201];

signed main(){
  int n,k;
  
  cin>>n>>k;
  int m=0;

  for(int i=1;i<=n;i*=2){
    for(int j=1;j<=n;j++){
      if(i!=j&&(i&j))e[i].push_back(j);
    }
    m+=e[i].size();
  }

  
  cout<<m<<endl;
  
  for(int i=1;i<=n;i++){
    for(int j=0;j<e[i].size();j++)cout<<i<<" " <<e[i][j]<<endl;
  }

  
  while(k--){
    string s;
    int ans=0;
    bool f=1;
  
    for(int i=1;f&&i<=n;i*=2){
      cout<<i<<endl;
      cin>>s;
      if(s=="Yes")f=0;
      else if(s=="Near")ans|=i;
    }
    if(f)cout<<ans<<endl,cin>>s;
    
  }
  
  return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 3e3;

double dp[nax][nax], head[nax], tail[nax], ans;
ll n;

// https://www.youtube.com/watch?v=ilCNQJtZSHs

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

	cin >> n;
	for (ll i = 1; i <= n; i++){
		cin >> head[i];
		tail[i] = 1 - head[i];
	}
	// Base Case 
	dp[0][0] = 1;
	for (ll i = 1; i <= n; i++){
		for (ll j = 0; j <= i; j++){
			if (j == 0){
				dp[i][j] = dp[i-1][j] * tail[i];
			}
			else{
				dp[i][j] = dp[i-1][j-1] * head[i] + dp[i-1][j] * tail[i];
			}
		}
	}

	for (ll i = 1; i <= n; i++){
		if (i > n - i){
			ans += dp[n][i];
		}
	}
	cout << fixed << setprecision(10) << ans << '\n';
}
  

Measured memory_bytes: 68992
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	s := nextLine()
	var builder bytes.Buffer
	for i := 0; i < len(s); i++ {
		builder.WriteString("x")
	}

	fmt.Println(builder.String())
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, M;
  cin >> N >> M;
  vi32 cost(M);
  vector<vi32> adds(N);
  vector<vi32> rems(N);
  rep(i, M) {
    int l, r, c;
    cin >> l >> r >> c;
    l--, r--;
    adds[l].emplace_back(i);
    rems[r].emplace_back(i);
    cost[i] = c;
  }
  vi64 dist(M);
  i64 ans = 0;
  set<pair<i64, int>> se;
  rep(i, N) {
    if (i != 0) {
      if (se.size() == 0) {
        cout << -1 << endl;
        return;
      }
      ans = se.begin()->first;
    }
    each(j, adds[i]) {
      se.emplace(ans + cost[j], j);
      dist[j] = ans + cost[j];
    }
    each(j, rems[i]) {
      se.erase(make_pair(dist[j], j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 12288
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N,vector<int>(N,0));
    vector<int> v(N);
    for(int i=0;i<N;i++){
        v[i] = i;
    }
    function<void(vector<int>,int)> rec = [&](vector<int> G,int depth){
        int n = G.size();
        if(n==1) return ;
        vector<int> v1,v2;
        for(int i=0;i<n;i++){
            if(i<n/2) v1.push_back(G[i]);
            else v2.push_back(G[i]);
        }
        rec(v1,depth+1);
        rec(v2,depth+1);
        for(auto x:v1) for(auto y:v2){
            A[x][y] = depth;
            A[y][x] = depth;
        }
    };
    rec(v,1);
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++) cout << A[i][j] << (j!=N-1? " ":"\n");
    }
}

Measured memory_bytes: 1536
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
const string YES = "YES";
const string NO = "NO";
// clang-format on

void solve(long long N, std::vector<long long> A) {
  vector<bool> a(INF);
  rep(i, N) {
    if (a[A[i]]) {
      ANS(NO);
      return;
    }
    a[A[i]] = true;
  }
  ANS(YES);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 132864
n, x = map(int, input().split())
def patty(L):
# レベルLバーガーにパティがいくらあるか
    p = 1
    for i in range(L):
        p = 2 * p + 1
    return (p)
def vol(L):
# レベルLバーガーが何層か
    m = 1
    for i in range(L):
        m  = m * 2 + 3
    return (m)
def eated(L, X):
# レベルLバーガーを下からX層に何枚パティがあるか
    if L == 0:
        return 1
    m = vol(L)
    if X == 1 or X == 0:
        #print("下から１枚")
        return 0
    elif X == (m + 1) / 2:
        #print("ちょうど真ん中")
        #print(str(L-1) + "バーガーのパティ＋１枚")
        return patty(L-1) + 1
    elif X < (m + 1) / 2:
        #print("下半分")
        #print(str(L-1) + "バーガーを考える")
        return eated(L-1, X-1)
    else:
        #print("上半分")
        #print(str(L) + "バーガーのパティを上から" + str(X) + "枚食べたと考える")
        return patty(L) - eated(L, m - X)
print(eated(n, x))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
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; }

const ll INF = 1LL<<60;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        int x;
        cin >> x;
        a[x - 1] = i + 1;
    }

    rep(i, n) {
        cout << a[i] << " ";
    }

    return 0;

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define X first
#define Y second
#define in(a,b,c) (b<=a&&a<c)

using namespace std;

using P=pair<int, int>;

const P dir[4] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int m[20][20];
int res;
int W, H;

void dfs(int depth, int ys, int xs) {
	if(depth>=res) return;
	for(P D:dir) {
		int x = xs+D.X;
		int y = ys+D.Y;
		if(m[y][x] == 1) continue;
		while(in(y, 0, H)&&in(x, 0, W)&&m[y][x] != 1) {
			if(m[y][x] == 3) {
				res = depth;
				return;
			}
			else {
				x += D.X; y += D.Y;
			}
		}
		if(in(y, 0, H)&&in(x, 0, W)&&m[y][x] == 1) {
			m[y][x] = 0;
			dfs(depth+1, y-D.Y, x-D.X);
			m[y][x] = 1;
		}
	}
}

int main() {
	while(cin >> W >> H && W && H) {
		P S;
		res = 11;

		rep(i,H) rep(j,W) {
			cin >> m[i][j];
			if(m[i][j] == 2) S = pair<int, int>(j, i);
		}

		dfs(1, S.Y, S.X);

		if(res==11)
			cout << -1 << endl;
		else
			cout << res << endl;

	}
	return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int h, a;
    cin >> h >> a;

    int ans = ceil(h /(1.0 * a) );
    cout << ans << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(N, M);
  vector<int> imos(N + 1);
  FOR(i, M) {
    GI2(L, R);
    imos[L - 1]++;
    imos[R]--;
  }
  int ans = 0;
  FOR(i, N) {
    imos[i] = (i > 0 ? imos[i - 1] : 0) + imos[i];
    if (imos[i] == M)
      ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>

using ll = long long;

using namespace std;

int main() {
    while (true) {
        int h, w; cin >> h >> w;
        if (h == 0) break;
        h++;
        bool done = false;
        for (int x = (h-1) * (h-1) + w * w; true; x++, h = 1) {
            for ( ; h <= 100 && h * h < x; h++) {
                w = sqrt(x - h * h);
                if (w <= h) break;
                if (x == h * h + w * w) {
                    done = true;
                    break;
                }
            }
            if (done) break;
        }
        cout << h << ' ' << w << '\n';
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main() {
  int a;
  string b;
  cin >> a >> b;
  size_t size = b.length();
  if (a >= size) {
    cout << b;
  } else {
    cout << b.erase(a) << "...";
  }
}

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

typedef long long ll;
typedef double d;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)
#define be(a) a.begin(),a.end()
#define sz(x) x.size()
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
    int n,l;
    cin>>n>>l;
    string s[n],t;
    lo(i,0,n)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    lo(i,0,n)
    t+=s[i];
    cout<<t;
    nl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    long long a,v;
    cin >> a >> v;
    long long b,w;
    cin >> b >> w;
    long long t;
    cin >> t;
    long long d = abs(a-b);
    long long d2 = (v-w)*t;
    cout << (d <= d2 ? "YES" : "NO") << endl;
    return 0;
}

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

int main(){
  int n; cin >> n;
  unordered_map<int, int> mp;
  for(int i =0 ; i < n; i++){
    int a; cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for(auto v: mp){
    ans += v.second % 2;
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 1024
int a[N];

int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, n) scanf("%d", a+i);
	int sm = 0;
	REP(i, n) sm += a[i];
	int cnt = 0;
	REP(i, n) {
		if(a[i] * 4 * m >= sm) {
			cnt++;
		}
	}
	if(cnt >= m) printf("Yes\n");
	else printf("No\n");
}


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}


int main() {
    string S;
    cin >> S;

    if(S[1] == 'B') cout << "ARC";
    else cout << "ABC";
    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf", ans);
    //cout << ans;
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int S[20];
int A[200];
int n;


int solve(int i,int m){
    if (m==0) return 1;
    if(i >= n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-S[i]);
    return res;
}

int main(){
    int q,x;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&A[i]);
        x=solve(0,A[i]);
    if(x==1) printf("yes\n");
    if(x==0) printf("no\n");
    }
    return 0;
}



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

int main(){
  int H, N;
  cin >> H >> N;
  int sum=0;
  for(int i=0; i<N; i++){
    int A; cin >> A;
    sum+=A;
  }
  if(sum>=H){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n,a=map(int,input().split())
l=list(input())
if l[a-1]=='A':
  l[a-1]='a'
if l[a-1]=='B':
  l[a-1]='b'
if l[a-1]=='C':
  l[a-1]='c'
k=''.join(l)
print(k)

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	string s;
	cin >> s;
	int a = 0;
	LL ans = 0;
	for(int i = 0; i < SZ(s); i++)
	{
		if(s[i] == 'A')
		{
			a++;
		}
		else if(s[i] == 'B')
		{
			if(i + 1 < SZ(s) && s[i + 1] == 'C')
			{
				ans += a;
				i++;
			}
			else
			{
				a = 0;
			}
		}
		else
		{
			a = 0;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		String S = scan.next();
		
		if(S.length() <= K) {
			System.out.println(S);
		}else {
			String S2 = S.substring(0,K);
			System.out.println(S2+"...");
		}

	}

}

Measured memory_bytes: 38580
#include<stdio.h>
int main(void)
{
	int i, a, b,s[7];
	for (i = 0; i < 7; i++) {
		scanf("%d %d", &a, &b);
		s[i] = a - b;
	}
	for (i = 0; i < 7; i++) {
		printf("%d\n", s[i]);
	}
	return 0;
}

Measured memory_bytes: 600
import sys,bisect
input = sys.stdin.readline

n,k = map(int,input().split())
h = list(map(int,input().split()))
hs = [0]+sorted(h)

if k==0:
    res = h[0]
    for i in range(1,n):
        res += max(0,h[i]-h[i-1])
    print(res)
    exit()

#dp[i][j][l]: Hiまででj回使い最後がl番目の小ささの時の最小値
dp = [[[10**12]*(n+1) for i in range(k+1)] for j in range(n)]

kk = bisect.bisect_left(hs,h[0])
dp[0][0][kk] = h[0]
dp[0][1][0] = 0

for i in range(1,n):
    kk = bisect.bisect_left(hs,h[i])
    #Hi used in this turn
    for j in range(k+1):
        tmp = 10**12
        for l in range(n):
            tmp = min(tmp,dp[i-1][j][l]+max(0,hs[kk]-hs[l]))
        dp[i][j][kk] = tmp

    #not used
    for j in range(1,k+1):
        for l in range(n):
            dp[i][j][l] = min(dp[i][j][l],dp[i-1][j-1][l])

res = 10**12
for j in range(k+1):
    for l in range(n):
        res = min(res,dp[-1][j][l])
print(res)
        


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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> height(N);
    for (ll i = 0; i < N; i++) {
      cin >> height.at(i);
    }
    vector<vector<ll>> road(M, vector<ll>(2));
    for (ll i = 0; i < M; i++) {
      cin >> road.at(i).at(0) >> road.at(i).at(1);
    }

    vector<ll> ma(N, 0);
    for(ll i = 0; i < M; i++) {
        ma.at(road.at(i).at(0) - 1) = max(ma.at(road.at(i).at(0) - 1), height.at(road.at(i).at(1) - 1));
        ma.at(road.at(i).at(1) - 1) = max(ma.at(road.at(i).at(1) - 1), height.at(road.at(i).at(0) - 1));
    }

    ll ans = 0;
    for(ll i = 0; i < N; i++) {
        if(height.at(i) > ma.at(i)) {
            ans++;
        }
    }
    cout << ans <<endl;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; -i)
#define INF (1 << 30)

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

string s;
vector<vector<int> > field;
int dp[101][101] = {0};

int main() {
	while(getline(cin, s)){
		replace(s.begin(), s.end(), ',', ' ');
		int n;
		stringstream ss;
		ss << s;
		vector<int> v;
		while(ss >> n) v.push_back(n);
		field.push_back(v);
	}
	dp[0][0] = field[0][0];
	FOR(i, 1, field.size()) rep(j, field[i].size()) {
		if(i <= field.size() / 2) {
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1]) + field[i][j];
		}
		else {
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j + 1]) + field[i][j];
		}
	}
	printf("%d\n", dp[field.size() - 1][0]);
	return 0;
}

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

int main() {
  int S[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2,
	       2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  cin >> K;

  cout << S[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	s := make([]int, n)
	for i := range s {
		s[i] = scanInt()
	}

	q := scanInt()
	cnt := 0
	for i := 0; i < q; i++ {
		x := scanInt()
		index := sort.SearchInts(s, x)
		if index != n && s[index] == x {
			cnt++
		}
	}
	fmt.Println(cnt)
}



Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
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; }
typedef long long ll;
const long long INF =1LL<<60;


int main() {
	int n;
  	cin>>n;
  
    ll h[100010];
   ll dp[100010];  
  
  
  	rep(i,n)cin>>h[i];
  
  	for (int i = 0; i < 100010; ++i) dp[i]=INF;

  dp[0]=0;
  
  for(int i=1;i<n;i++){
  	chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  
  cout<<dp[n-1]<<endl;
	
}

Measured memory_bytes: 5192
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int N;
long A[100001];
long T[100001];

long dp[100001];

long mod = 1e9 + 7;
int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> T[i];

    int x = A[0];
    rep(i,N) {
        if (A[i] <= x) {
            dp[i] = A[i];
        }
        else {
            dp[i] = 1;
            x = A[i];
        }
    }
    dp[0] = 1;

    x = T[N-1];
    for (int i = N-1; i>=1; i--) {
        if (T[i] <= x) {
            dp[i] = min(dp[i], T[i]);
        }
        else {
            dp[i] = 1;
            x = T[i];
        }
    }
    dp[N-1] = 1;

    int mxA =0;
    int mxT =0;
    

    long ret = 1;
    rep(i,N) {
        if (mxA < A[i]) mxA = A[i];
        if (mxT < T[i]) mxT = T[i];
        ret = (ret * dp[i]) % mod;
    }
    bool flag = false;
    rep(i,N) { 
        if (mxA == mxT && A[i] == mxA && T[i] == mxT){
            flag = true;
            break;
        }
    }
    if (!flag) ret = 0;
    cout << ret << endl;

    return 0;
}




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

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

		String str[] = br.readLine().split(" ");

		System.out.println(str[1] + str[0]);
	}
}


Measured memory_bytes: 37116
#include<iostream>
#include<cmath>
using namespace std;
int main(void){
    int n,m,x;
    cin>>n>>m>>x;
    int a[100]={0};
    for(int i(0);i<m;i++){
        cin>>a[i];
    }
    int cost_0(0);
    int cost_n(0);
    for(int i(0);i<m;i++){
        if(a[i]<x)cost_0++;
        else if(a[i]>x)cost_n++;
    }
    cout<<min(cost_0,cost_n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(void){
    int i,n;
    double ans;
    cin >> n;
    ans=100.000;
    for(i=0;i<n;i++){
        ans*=1.05;
        ans=(int)(ans+0.999);
        ans=(double)ans;
    }
    ans*=1000;
    printf("%d\n",(int)ans);
    return 0;
}

Measured memory_bytes: 3168
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            string input = Console.ReadLine();
            string[] array = input.Split(' ');

            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);

            for (int x = a; x <= b; x++)
            {
                if (c % x == 0)
                {
                    count++;
                }
            }
            Console.WriteLine(count);   
        }
    }
}

Measured memory_bytes: 9184
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
//N = number of atoms

int main()
{
  int i,j,k,l;
  char S[256];
  scanf("%s",S);

  int N = strlen(S);
  
  k = 0;
  for(i=0;i<(N/2);i++){
    j = N-1-i;
    if( S[i] == S[j] ){
      k++;
    }
  }
  if( k == N/2 ){
    k = 0;
    for(i=0;i<((N)/4);i++){
      j = (N-1)/2-1-i;
      if( S[i] == S[j] ){
        k++;
      }
    }
    if( k == N/4 ){
      k = 0;
      l = -1;
      for(i=(((N+3)/2)-1);i<(((N+3)/2)-1)+N/4;i++){
        l++;
        j = N-1-l;       
        if( S[i] == S[j] ){
          k++;
        }
      }
      if( k == N/4 ){
        printf("Yes\n");
      }
      else{
        printf("No\n");
      }
    }
    else{
      printf("No\n");
    }
  }
  else{
    printf("No\n");
  }
  
  
  return 0; 
  
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int A, B, C, X;
	int i, j, k;
	int count = 0;

	scanf("%d %d %d %d", &A, &B, &C, &X);

	for (i = 0; i <= A; i++)
	{
		for (j = 0; j <= B; j++)
		{
			for (k = 0; k <= C; k++)
			{
				if ((500*i) + (100*j) + (50*k) == X)
					count++;
			}
		}
	}

	printf("%d", count);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node { int p, l, r;};
Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL) return;
    cout << " " << u;
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if(u==NIL) return;
    inParse(T[u].l);
    cout << " " << u;
    inParse(T[u].r);
}

void postParse(int u){
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    cout << " " << u;
}

int main(){
    int v,l,r,root;
    cin >> n;
    for(int i=0; i<n; i++)
        T[i].p = NIL;
    for(int i=0; i<n; i++){
        cin >> v >> l >> r;
        T[v].l = l;
        T[v].r = r;
        if(l!=NIL) T[l].p = v;
        if(r!=NIL) T[r].p = v;
    }
    
    for(int i=0; i<n; i++)
        if(T[i].p==NIL)
            root = i;
    
    cout << "Preorder" << endl;
    preParse(root);
    cout << endl;
    cout << "Inorder" << endl;
    inParse(root);
    cout << endl;
    cout << "Postorder" << endl;
    postParse(root);
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3068
#include<iostream>

int main( void )
{
	int n, count;

	while( std::cin >> n ){
		count = 0;

		for( int a = 0; a < 10; a++ ){
			for( int b = 0; b < 10; b++ ){
				for( int c = 0; c < 10; c++ ){
					for( int d = 0; d < 10; d++ ){
						if( n == a + b + c + d ){
							count++;
							break;
						}
					}
				}
			}
		}

		std::cout << count << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
n = int(input())

ans = 0
for i in range(1,n + 1):
    cnt = 0
    if i % 2 == 1:
        for j in range(1,i + 1):
            if i % j == 0:
                cnt += 1
        if cnt == 8:
            ans += 1

print(ans) 

Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
	  int N;
      int ans =0;
      cin >> N;
      vector<int> vec(N);
      for(int i=0; i<N;i++) cin >>vec.at(i);
      sort(vec.begin(), vec.end());
      reverse(vec.begin(), vec.end());
      if (N%2==0){
        for (int j=0; j<N; j+=2){
          ans += vec.at(j)-vec.at(j+1);
        }
        cout << ans << endl;
      }
      else {
        for (int k=0; k<N-1; k+=2){
          ans += vec.at(k)-vec.at(k+1);
        }
        ans += vec.at(N-1);
        cout << ans << endl;
      }
          
    }

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ma=60;
    vector cnt(ma,vector<ll>(ma,0));
    rep(i,n){
        string s;
        cin>>s;
        bool flag=false;
        string ns,nt;
        rep(j,s.size()){
            if(s[j]=='.'){
                flag=true;
            }else{
                if(flag){
                    nt+=s[j];
                }else{
                    ns+=s[j];
                }
            }
        }
        s=ns+nt;
        rep(_,9-nt.size()) s+='0';
        ll x=stoll(s),a=0,b=0;
        while(x%2==0){
            a++;
            x/=2;
        }
        while(x%5==0){
            b++;
            x/=5;
        }
        cnt[a][b]++;
    }
    ll ans=0;
    rep(i,ma)rep(j,ma)rep(k,ma)rep(l,ma){
        if(Pi(i,j)>Pi(k,l)) continue;
        if(i+k>=18 && j+l>=18){
            if(i==k && j==l){
                ans+=cnt[i][j]*(cnt[i][j]-1)/2;
            }else{
                ans+=cnt[i][j]*cnt[k][l];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int i = 0;
    int ans = 0;
    while(1){
        ans += i;
        if(ans >= n){
            break;
        }
        i++;
    } 
    cout << i;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
# coding: utf-8
# Your code here!


S=input()
x=0
count=0

if S[0]!="A":
    print("WA")
    exit()
elif len(S)==4:
    if S[2]!="C":
        print("WA")
        exit()
    elif S[1].islower() and S[3].islower():
        print("AC")
        exit()
    else:
        print("WA")
        exit()
else:
    for i in range(2,len(S)-1):
        if S[i]=="C":
            count+=1
            x=i
    
    if count!=1:
        print("WA")
        exit()
    elif count==1:
        for i in range(1,len(S)):
            if x!=i:
                if S[i].isupper():
                    print("WA")
                    exit()
        print("AC")
        exit()
            

Measured memory_bytes: 3192
fun main (args : Array<String>) {
    var a = readLine()!!.toInt()
    var b = readLine()!!.toInt()
    var c = readLine()!!.toInt()
    var x = readLine()!!.toInt()

    var cnt = 0

    for (i in 0 until a + 1)
        for (j in 0 until b + 1)
            for (k in 0 until c + 1)
                if (500 * i + 100 * j + 50 * k == x)
                    cnt += 1

    println("%d".format(cnt))
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    int h, w, k;
    cin >> h >> w >> k;

    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si, --sj, --ti, --tj;

    const int inf = 1e9;
    vector< string > field(h);
    int d[h][w];
    rep (i, h)
    {
        cin >> field[i];
        rep (j, w)
        {
            d[i][j] = (field[i][j] == '@' ? -1 : inf);
        }
    }


    queue<P> q;
    q.emplace(si, sj);
    d[si][sj] = 0;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    while (!q.empty())
    {
        auto from = q.front(); q.pop();
        int fi = from.first;
        int fj = from.second;
        rep (i, 4)
        {
            int ni = fi;
            int nj = fj;
            int dyy = dy[i];
            int dxx = dx[i];
            rep (j, k)
            {
                ni += dyy;
                nj += dxx;
                if (!(IN(0, h, ni) && IN(0, w, nj))) break;
                if (d[ni][nj] < d[fi][fj] + 1) break;
                if (d[ni][nj] != inf) continue;
                d[ni][nj] = d[fi][fj] + 1;
                q.emplace(ni, nj);
            }
        }
    }

    int ans = d[ti][tj];
    if (ans == inf) cout << "-1\n";
    else cout << ans << "\n";

    return 0;
}



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

Measured memory_bytes: 23892
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();
    System.out.println(""+s1.charAt(0)+s2.charAt(1)+s3.charAt(2));
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
typedef vector<vector<Weight>> Graph;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

ll popcount(ll a) {
  ll ret = 0;
	while (a > 0) {
		if (a & 1) ret++;
		a >>= 1;
	}
	return ret;
}

ll f(ll a) {
  ll cnt = 1;
	while (a > 0) {
	  a = a % popcount(a);
		cnt++;
	}
	return cnt;
}

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

  ll n; cin >> n;
	string s; cin >> s;
	ll popcnt = 0;
	ll x = 0;
	rep (i,n) {
		if (s[i] == '1') { 
		  popcnt++;
		}
	}

	if (n == 1 && s == "1") {
		cout << 0 << endl;
		return 0;
	}

	ll xmodp = 0, xmodm = 0;
	vector<ll> pow2p(n+1), pow2m(n + 1);
	pow2p[0] = 1;
	pow2m[0] = 1;
	rrep(i, n) {
		if (s[i] == '1') {
		  xmodp += pow2p[n-i-1];
			xmodm += pow2m[n-i-1];
			xmodp %= popcnt+1;
			if (popcnt - 1 > 0)xmodm %= popcnt-1;
		}
		pow2p[n - i] = pow2p[n - i - 1] * 2 % (popcnt + 1);
		if (popcnt - 1 > 0) pow2m[n - i] = pow2m[n - i - 1] * 2 % (popcnt - 1);
	}

	if (popcnt == 1) {
		rep(i, n) {
			if (s[i] == '1') {
				cout << 0 << endl;
			}
			else {
				cout << f(xmodp + pow2p[n - i - 1] >= popcnt+1 ? xmodp + pow2p[n - i - 1] - (popcnt + 1) : xmodp + pow2p[n - i - 1]) << endl;
			}
		}
	  return 0;
	}

	rep(i, n) {
		if (s[i] == '1') {
			cout << f(xmodm - pow2m[n-i-1] < 0 ? xmodm - pow2m[n - i - 1] + popcnt-1 : xmodm - pow2m[n - i - 1]) << endl;
		}
		else {
			cout  << f(xmodp + pow2p[n - i - 1] >= popcnt+1 ? xmodp + pow2p[n - i - 1] - (popcnt+1) : xmodp + pow2p[n - i - 1]) << endl;
		}
	}

	

}

Measured memory_bytes: 6788