akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int  dp[3005][3005];  //globally declare so that we can use this in any where
int topdownlcs(string s1,string s2,int n ,int m)
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s1[i-1]==s2[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
            {
                int v1= dp[i-1][j];
                int v2= dp[i][j-1];
                dp[i][j]=max(v1,v2);
            }
        }
    }
    return dp[n][m];
}

void printlcs(string s1,string s2,int n,int m)
{
    string ans;
     int i=n,j=m;
     while(i>0 && j>0)
     {
        if(s1[i-1]==s2[j-1])
        {
            ans.push_back(s1[i-1]);
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
            {
               j--;
            }
        }
     }
     reverse(ans.begin(),ans.end()); //for reversing the result 
     cout<<ans<<endl;
}

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.length();
    int m=s2.length();
    memset(dp,0,sizeof(dp)); // for implement topdown approach
    topdownlcs(s1,s2,n,m);
    printlcs(s1,s2,n,m);
    return 0;
}

Measured memory_bytes: 38900
def root(x):
  while p[x]>=0:x=p[x]
  return x
def unite(a,b):
  a,b=root(a),root(b)
  if a!=b:
    if p[a]>p[b]:a,b=b,a
    p[a]+=p[b]
    p[b]=a
n,m,*t=map(int,open(0).read().split())
p=[-1]*n
c=[0]*n
for a,b in zip(*[iter(t)]*2):
  a-=1
  b-=1
  unite(a,b)
  c[a]+=1
  c[b]+=1
a=root(0),root(1)
f=p[a[0]]<p[a[1]]
t=[0,0]
for i in range(n):
  j=root(i)
  if j==a[f]:
    t[f]+=c[i]
  else:
    t[f^1]+=c[i]
    unite(a[f^1],j)
r=0
for i in(0,1):
  n=-p[root(i)]
  r+=n*(n-1)-t[i]>>1
print(r)

Measured memory_bytes: 83028
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

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

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

#define N 7500000
bool t[N];
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(m, n);
    if(!(m | n))break;

    rep(i, N)t[i] = false;
    for(i = m;n;++i)if(!t[i]){
      for(j = i;j < N;j+=i)t[j] = true;
      --n;
    }
    for(i = m;;++i)if(!t[i]){printf("%d\n", i);break;}

  }
  return 0;
}

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

int main(){
    long A, B, C, K;
    cin >> A >> B >> C >> K;

    if(A >= K){
        cout << K << endl;
    }else if(A + B >= K){
        cout << A << endl;
    }else{
        cout << A - (K - A - B) << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=2e5+5;
int n,val[N],nx[20][2];

namespace utils{
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
	}
	for(int i=0; i<20; ++i){
		nx[i][0]=nx[i][1]=n+1;
	}
	lint ans=0;
	for(int i=n; i>=1; --i){
		int r=n;
		for(int j=0; j<20; ++j){
			if(val[i]>>j&1) nx[j][1]=nx[j][0],nx[j][0]=i;
			apn(r,nx[j][1]-1);
		}
		ans+=r-i+1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4528
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    a,b = LI()
    A[i] = a
    B[i] = b

A.sort()
B.sort()

if N % 2 == 1:
    min_mid = A[(N - 1) // 2]
else:
    min_mid = (A[N //2 - 1] + A[N//2]) / 2

if N % 2 == 1:
    max_mid = B[(N - 1) // 2]
else:
    max_mid = (B[N //2 - 1] + B[N//2]) / 2 

if N % 2 == 0:
    print(int((max_mid - min_mid) / 0.5 + 1))
else:
    print(math.ceil(max_mid) - math.floor(min_mid) + 1)




Measured memory_bytes: 27284
//
// Created by ?????°?????? on 2016/04/08.
//

#include <iostream>
using namespace std;
const int MAX = 10000;
const int NIL = -1;

struct node{
    int parent;
    int right;
    int left;
};

node T[MAX];

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

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

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

int main(){
    int n,root,v,l,r;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    for (int i = 0; i < n ; ++i) {
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        //what is T[l]'s parent?
        if(l != NIL ) T[l].parent = v;
        if(r != NIL ) T[r].parent = v;
    }

    //isRoot
    for (int i = 0; i < n ; ++i) {
        if(T[i].parent == NIL) root = i;
    }

    //preParse
    cout << "Preorder" << endl;
    preParse(root);
    cout << endl;

    //inParse
    cout << "Inorder" << endl;
    inParse(root);
    cout << endl;

    //postParse
    cout << "Postorder" << endl;
    postParse(root);
    cout << endl;

    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


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

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  string ans = "ai1333";
  cin >> N;
  while(N){
    ans += "3";
    N -= 100;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3172
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, SubAssign, Range};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet, HashMap};
use std::fmt::{Display, Formatter, Error};
use std::hash::{Hash, Hasher};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

fn to_button(c: char) -> i32 {
    (c.to_digit(20).unwrap() as i32 - 10) as i32
}
fn abs(value: i32) -> i32 {
    if value < 0 {
        -value
    }else {
        value
    }
}
fn main() {
    for _ in 0 .. 1000 {
        let word = read_line!().trim().to_string();
        let suspect: Vec<char> = word.chars().collect::<Vec<_>>();
        let mut is = true;
        for i in 1 .. suspect.len() {
            let current = to_button(suspect[i]);
            let prev = to_button(suspect[i-1]);
            if (abs(current % 3 - prev % 3) == 1 && current / 3 == prev / 3) || (abs(current / 3 - prev / 3) == 1 && current % 3 == prev % 3) {

            }else {
                is = false;
                break
            }
        }
        if is {
            println!("{}", word);
        }
    }
}



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

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  bool flag = false;
  for(int i=a; i<=b; i++){
    if(i%k==0) flag = true;
  }
  if(flag)cout << "OK" << endl;
  else{
    cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    bool f = (x*2 == w) && (y*2 == h);
    cout << fixed << setprecision(20) << (double)w * h / 2 << " " << (f ? 1 : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    double l; cin>>l;

    double ans = (l / 3) * (l / 3) * (l / 3);

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x,vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout <<#x<<" "<< x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a,b,c) min(a,min(b,c))
#define max(a,b,c) max(a,max(b,c))
vector<pll> v[100000+1];
bool color[100000+1];
void dfs(int u,int p=-1)
{
    for(auto x:v[u])
    {
        if(x.first!=p)
        {
            if(x.se%2==0)
            color[x.fi]=color[u];
            else
            color[x.fi]=!color[u];
            dfs(x.fi,u);
        }
    }
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	color[1]=1;
	ll tempn=n;
	n--;
	while(n--)
	{
	    ll a,b,w;
	    cin>>a>>b>>w;
	    v[a].pb({b,w});
	    v[b].pb({a,w});
	}
	dfs(1);
	swap(tempn,n);
	for(int i=1;i<=n;i++)
	cout<<color[i]<<"\n";
	
}
	

Measured memory_bytes: 9600
#include <stdio.h>

int main(){
	int n;
	int p[22];
	int i,cont=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",p+i);
	}
	for(i=1;i<n-1;i++){
		if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])){
			cont++;
		}
	}
	printf("%d\n",cont);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define N 200020
char s[N];
int n;
int main(){
    cin>>n;
    scanf("%s", s + 1);
    int r = 0, n = strlen(s + 1);
    for(int i = 1; i <= n; i++){
        if(s[i] == 'R') ++r;
    }
    int w = 0;
    for(int i = 1; i <= r; i++){
        if(s[i] == 'W') ++w;
    }
    cout<<w<<endl;



    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
int arr[mxN];
ll sumx[mxN];
int rsum[mxN];
ll sumxmod[mxN];
int lsummod[mxN];
int n;
vector<int> divs[mxN];
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    ll d;
    cin>>n>>d;
    d= d*d;
    int ans = 0;
    ll a, b;
    owo(i, 0, n) {
        cin>>a>>b;
        if(a*a + b*b<=d)ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 5984
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<double,double>P;

ll gcd(ll a,ll b)
{
    if(a!=0 && b==0)
    {
        return a;
    }
    if(a%b==0)
    {
        return b;
    }
    else
    {
        return(gcd(b,a%b));
    }
    
}

ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<lcm(a,b);

}

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

using namespace std;
typedef long long ll;
typedef __int128 i128;

void in(i128 &a)
{
    a=0;
    bool s=0;
    char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-') s=1;
		c=getchar();
	}
    while(isdigit(c))
    {
        a=10*a+(c-'0');
		c=getchar();
    }
    if(s) a=-a;
}

void out(i128 a)
{
    if(a<0)
	{
		putchar('-');
		a=-a;
    }
	if(a>=10) out(a/10);
	putchar((a%10)+'0');
}

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        i128 n,a,b,c,d;
        in(n); in(a); in(b); in(c); in(d);
        priority_queue<array<i128,2>,vector<array<i128,2>>,greater<array<i128,2>>> q;
        i128 res=(1ll<<62);
        map<i128,i128> dist;
        auto add=[&](i128 cost,i128 x)->void
        {
            if(dist.find(x)==dist.end()||dist[x]>cost)
            {
                dist[x]=cost;
                q.push({cost,x});
            }
        };
        add(0,n);
        vector<array<i128,2>> v={{2,a},{3,b},{5,c}};
        while(!q.empty())
        {
            auto [now,x]=q.top();
            q.pop();
            if(x<0||dist[x]<now) continue;
            for(auto [k,z]:v)
            {
                if((x%k)==0) add(now+z,x/k);
                else
                {
                    add(now+z+(x%k)*d,(x-x%k)/k);
                    add(now+z+(k-x%k)*d,(x+k-x%k)/k);
                }
            }
            res=min(res,now+x*d);
        }
        out(res);
        putchar('\n');
    }
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
// #define INF (1LL << 62)

// #define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
  REP(i, 5) {
    ll a;
    cin >> a;
    if (a == 0) {
      PRINT(i+1);
      break;
    }
  }
  return 0;
} 


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
numList = []
result = []

user = int(input())
user2 = list(map(int, input().split()))
count = 0

for i in range(user - 2):
    for j in range(user - i - 1):
        jIndex = j + i + 1
        for k in range(user - jIndex - 1):
            kIndex = k + jIndex + 1
            if user2[i] != user2[jIndex] and user2[i] != user2[kIndex] and user2[jIndex] != user2[kIndex]:
                dum = []
                dum.append(user2[i])
                dum.append(user2[jIndex])
                dum.append(user2[kIndex])
                dum.sort()

                if dum[2] < dum[1] + dum[0]:
                    count += 1
print(count)

Measured memory_bytes: 9220
n=int(input())
a=list(map(int,input().split()))
d=abs(a[0])+abs(a[-1])
for i in range(n-1):
    d+=abs(a[i+1]-a[i])
#print(d)
print(d-abs(a[0])-abs(a[1]-a[0])+abs(a[1]))
for i in range(n-2):
    print(d-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i]-a[i+2]))
print(d-abs(a[-1])-abs(a[-2]-a[-1])+abs(a[-2]))

Measured memory_bytes: 14164
N = int(input())
A = list(map(int, input().split()))
def solve(N,A):
    ans = 1
    lis = [A[0]]
    for i in range(1,N):
        if len(lis)==1 or diff==0:
            diff = A[i]-A[i-1]
        elif (A[i]-A[i-1])*diff<0:
            ans += 1
            lis = []
        lis.append(A[i])
        a = A[i]
    return ans
print(solve(N,A))

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

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

  int x = n;
  int fx = 0;
  while (x > 0) {
    fx += x % 10;
    x /= 10;
  }

  if (n % fx == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int even = n * (n - 1) / 2;
        int odd = m * (m - 1) / 2;
        System.out.println(even + odd);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdint>
#include <utility>
#include <iomanip>
#include <cstring>
using namespace std;

typedef long long ll;

#define make_path(u,v,w) make_pair(make_pair(u,v),w)
typedef pair<pair<int,int>,int> path_t;
int root = 1000000;

vector<path_t> path;
int n;
ll dist[100005];

void dfs(int c_node,ll c_dist) {
    if(dist[c_node] != -1) return;
    dist[c_node] = c_dist;
    auto s = lower_bound(path.begin(),path.end(),make_path(c_node,0,0));
    auto t = upper_bound(path.begin(),path.end(),make_path(c_node,200000,0));
    for(auto itr = s;itr != t;itr++) {
        dfs(itr->first.second,c_dist+itr->second);
    }
}

int main() {
    for(int i = 0;i < 100005;i++) dist[i] = -1;
    cin >> n;
    for(int i = 0;i < n-1;i++) {
        int u,v,w;
        cin >> u >> v >> w;
        root = min(root,min(u,v));
        path.push_back(make_path(u,v,w));
        path.push_back(make_path(v,u,w));
    }
    sort(path.begin(),path.end());
    dfs(root,0);
    for(int i = root;dist[i] != -1;i++) {
        cout << dist[i] % 2 << endl;
    }
}

Measured memory_bytes: 5108
#include <stdio.h>

int main() {

  int a, b;
  int d, r;
  double f;

  scanf("%d %d", &a, &b);

  d = a/b;
  r = a%b;
  f = (double)a/b;
  
  printf("%d %d %.5lf\n", d, r, f);

  return 0;
}

Measured memory_bytes: 640
def exhaustive(index, end, target, table):
    if end == target:
        return True
    if end > target or index == n:
        return False
    if end + sum(table[index:]) < target:
        return False
    return exhaustive(index+1, end, target, table) or exhaustive(index+1, end+table[index], target, table)

if __name__ == "__main__":
    n = int(input())
    table = list(map(int, input().split()))
    q = int(input())
    m = list(map(int, input().split()))
    for i in m:
        if exhaustive(0, 0, i, table):
            print("yes")
        else:
            print("no")


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

using namespace std;

int main()
{
	long long n,m,ans;
	vector<long long> s;
	cin >> n >> m;

	if (n > m)
		for (long long i = 0; i < n; i++)
			s.push_back(m);
	else
		for (long long i = 0; i < m; i++)
			s.push_back(n);
	
	for(long long i = 0;i < s.size();i++)
	cout << s[i];
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
class UnionFind {
    vector<ll> par, h, sz;
public:
    UnionFind(ll size) : par(size, 0), h(size, 0), sz(size, 1) {
        rep(i, size) par[i] = i;
    }
    void unite(ll u, ll v) {
        u = root(u), v = root(v);
        if (u == v) return;
        if (h[u] < h[v]) {
            par[u] = v;
            sz[v] += sz[u];
        }
        else {
            par[v] = u;
            sz[u] += sz[v];
        }
        if (h[u] == h[v]) ++h[u];
    }
    ll size(ll v) {
        return sz[root(v)];
    }
    bool isUnited(ll u, ll v) {
        return root(u) == root(v);
    }
    ll root(ll v) {
        if (par[v] == v) return v;
        return par[v] = root(par[v]);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m; cin >> n >> m;
    UnionFind uf(n);
    vector<ll> c(n); cin >> c;
    rep(i, m) {
        ll a, b; cin >> a >> b;
        uf.unite(a, b);
    }
    map<ll, ll> conv;
    rep(i, n) conv[uf.root(i)];
    ll groups = conv.size();
    vector<vector<ll>> g(groups);
    vector<priority_queue<ll, vector<ll>, greater<ll>>> cost(groups);
    ll k = 0;
    each(p, conv) p.second = k++;
    rep(i, n) cost[conv[uf.root(i)]].push(c[i]);
    ll need = 2 * (groups - 1);
    if (need > n) {
        cout << "Impossible" << endl;
    }
    else if (groups == 1) {
        cout << 0 << endl;
    }
    else {
        ll ans = 0;
        rep(i, groups) {
            assert(cost[i].size() >= 1);
            ans += cost[i].top();
            cost[i].pop();
            --need;
        }
        vector<ll> cc;
        rep(i, groups) {
            while (cost[i].size() > 0) {
                cc.pb(cost[i].top());
                cost[i].pop();
            }
        }
        sort(all(cc));
        assert(cc.size() >= need);
        rep(i, need) ans += cc[i];
        cout << ans << endl;
    }
}


Measured memory_bytes: 18304
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                count+=1
print(count)

Measured memory_bytes: 3060
#line 1 "hoge.cpp"
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 3 "../../library/debug.hpp"

// https://codeforces.com/blog/entry/68809
void debug_print(int x) {cerr << x;}
void debug_print(long x) {cerr << x;}
void debug_print(long long x) {cerr << x;}
void debug_print(unsigned x) {cerr << x;}
void debug_print(unsigned long x) {cerr << x;}
void debug_print(unsigned long long x) {cerr << x;}
void debug_print(float x) {cerr << x;}
void debug_print(double x) {cerr << x;}
void debug_print(long double x) {cerr << x;}
void debug_print(char x) {cerr << '\'' << x << '\'';}
void debug_print(const char *x) {cerr << '\"' << x << '\"';}
void debug_print(const string &x) {cerr << '\"' << x << '\"';}
void debug_print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void debug_print(const pair<T, V> &x) {cerr << '{'; debug_print(x.first); cerr << ','; debug_print(x.second); cerr << '}';}
template<typename T> void debug_print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), debug_print(i); cerr << "}";}

void debug_print_() {cerr << "]\n";}
template <typename T, typename... V>
void debug_print_(T t, V... v) {debug_print(t); if (sizeof...(v)) cerr << ", "; debug_print_(v...);}

#ifdef LOCAL
  #define debug(x...) cerr << "[" << #x << "] = ["; debug_print_(x)
#else
  #define debug(x...)
#endif
#line 3 "e.cpp"

int main() {
  ll n;
  cin >> n;
  vl a(n);
  cin >> a;

  map<ll, ll> cnt;
  rep(i, n) {
    cnt[a[i]-i]++;
  }

  debug(cnt);

  ll ans = 0;
  rep(i, n) {
    ans += cnt[-a[i]-i];
  }

  cout << ans << el;
}


Measured memory_bytes: 27436
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

	string x0;
	string x1;

	for (int i = 0; i < s.length(); i++)
	{
		x0 += (i % 2 == 0 ? "0" : "1");
		x1 += (i % 2 == 0 ? "1" : "0");
	}

	int a = 0, b = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s.at(i) != x0.at(i))
		{
			a++;
		}
		if (s.at(i) != x1.at(i))
		{
			b++;
		}
	}


	cout << min(a, b) << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
       
    string sa[4]={"maerd","remaerd","esare","resare"};
    
    while(s.empty() == false)
    {
        int ssize = s.size();
        for(int as = 0; as<4;++as)
        {
            int flag = 1;
            for(int i = 0; i<sa[as].size();++i)
            {
                if(sa[as][i] != s[i])
                {
                    flag=0;
                    break;     
                }
            }

            if(flag == 1)
            {
                for(int i = 0; i<sa[as].size();++i)
                {
                    s.erase(s.begin());
                }
            }
        }

        if(ssize == s.size())
        {
            break;    
        }
    }
    
    if(s.empty() == true)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;    
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;
#define int long long


struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n,-1){}

    int root(int x){
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y){
        int rx = root(x), ry = root(y);
        if(rx == ry) return false;
        if(size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

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

    int size(int x){
        return -par[root(x)];
    }
};

signed main(){
    int n, m, a, b;
    cin >> n >> m;
    vector<int> A, B;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        A.push_back(a);
        B.push_back(b);
    }

    vector<ll> res;
    UnionFind cg(n);
    ll cur = 1LL * n*(n-1) / 2;

    for (int i = m-1; i>=0; i--) {
        res.push_back(cur);
        a = A[i]; b = B[i];
        if(cg.isSame(a, b)) continue;
        ll na = cg.size(a), nb = cg.size(b);
        cur -= na * nb;
        cg.unite(a,b);
    }

    reverse(res.begin(), res.end());
    for (int i = 0; i < m; i++) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 4588
a,b = map(int,input().split())
s = list(input())
ans = 'Yes'
if len(s) != a+b+1:
    ans = 'No'
else:
    for i in range(a+b+1):
        if i == a and s[i] != '-':
            ans = 'No'
            break
        if (not s[i].isdigit()) and i != a:
            ans ='No'
            break
print (ans)


Measured memory_bytes: 2940
s=list(input())
acgt=['A','C','G','T']

ans=0
for i in range(len(s)):
  for j in range(i+1,len(s)+1):
    cnt=0
    for tmp in s[i:j]:
      if tmp not in acgt:
        break
      cnt+=1
    ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 3060
from decimal import Decimal
import math
a,b,n = map(str,input().split())

a = Decimal(a)
b = Decimal(b)
n = int(n)
ans = 0
kouho = [min(b-1,n)]
for x in kouho:
    tmp = math.floor((a*x)/b) - a*math.floor(x/b)
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 10068
using System;
using System.Collections;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var ht = new Hashtable();
        for (var i = 0; i < n; i++)
        {
            var s = Console.ReadLine();
            var arr = s.ToCharArray();
            Array.Sort(arr);
            var str = string.Join("", arr);

            if (ht.ContainsKey(str))
            {
                ht[str] = long.Parse(ht[str].ToString()) + 1;
            }
            else
            {
                ht.Add(str, 0);
            }
        }

        long ret = 0;
        foreach (var v in ht.Keys)
        {
            var num = long.Parse(ht[v].ToString());
            for (var i = 1; i <= num; i++)
            {
                ret += i;
            }
        }

        Console.Write(ret);
    }
}

Measured memory_bytes: 31160
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define looplt(i,x) for(i=0; i<x; ++i)
#define bsrch(v,x) binary_search(v.begin(), v.end(), x)
#define vecl vector <long long int>
#define pb(x) push_back(x)
const long long int MAX_INT =  10e+10;

typedef long long int ll;

void pvec(vector <ll> &inp)
{
    ll n;
    looplt(n, inp.size()) cout << inp[n] << " ";
    cout << endl;
}

void parr(ll inp[], ll size)
{
    ll n;
    looplt(n, size) cout << inp[n] << " ";
    cout << endl;

}

ll pw(ll a, ll b)
{
    if(b == 0)
        return (1);
    
    ll ans = 1;
    for(ll i=0; i<b; ++i) 
        ans *= a;

    return (ans);
}

bool arrsearch(ll arr[], ll size, ll val)
{
    for(ll i=0; i<size; ++i){
        if(arr[i] == val)
            return true;
    }
    return false;
}

int main()
{   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll t=1, n, i, j, k, x;
    //cin >> t;
    looplt(i, t){
        string s, st;
        cin >> s >> st;
        ll ans=INT_MAX, c=0;
        bool flag=false;
        k=0;
        x=0;
        
        for(k=0; k<s.length()-st.length()+1; ++k){
            ll temp = k;
            while(x < st.length()){
                if(st[x] != s[temp])
                    c++;
                x++;
                temp++;
            }
            ans = min(ans, c);
            x=0;
            c=0;
        }
        
        cout << ans << "\n";
    }
}   



Measured memory_bytes: 3616
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        while (n > 0) {
            n /= k;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
#define Accepted return 0;
int main()
{
    string s;
    int ans,i;
    ans=0;
    cin>>s;
    for(i=0;i<6;i++)
        if (s[i]=='1') ans++;
    cout<<ans<<endl;
    Accepted
}


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


int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) cout << a-1 << endl;
  else cout << a << endl;
  return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
int main(){
  char m[9][5]={{'.',',','!','?',' '},
		{'a','b','c','1','1'},
		{'d','e','f','1','1'},
		{'g','h','i','1','1'},
		{'j','k','l','1','1'},
		{'m','n','o','1','1'},
		{'p','q','r','s','1'},
		{'t','u','v','1','1'},
		{'w','x','y','z','1'}};
  int a,count=0,c,d;
  char b[1025];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b);
    c=strlen(b);
    for(int j=0;j<c;j++){
      if(b[j]!='0')count++;
      else
	if(b[j-1]!=0 && count){
	  d=b[j-1]-'0';
	  if(d==1)
	    cout<<m[d-1][(count-1)%5];
	  else if(d==7 || d==9)
	    cout<<m[d-1][(count-1)%4];
	  else
	    cout<<m[d-1][(count-1)%3];
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
int main(){
int n,b,i,j;
int cards[4][13]={0};
char a;
scanf("%d\n",&n);

for(i=0;i<n;i++){
scanf("%c %d\n",&a,&b);

if(a=='S'){ cards[0][b-1]=b;
}else if(a=='H')
{cards[1][b-1]=b;}else if(a=='C'){cards[2][b-1]=b;}else{

cards[3][b-1]=b;}
}

for(i=0;i<4;i++){
for(j=0;j<13;j++){
if(cards[i][j]==0){
if(i==0){
printf("S %d\n",j+1);
}else if(i==1){

printf("H %d\n",j+1);

}else if(i==2){

printf("C %d\n",j+1);

}else{

printf("D %d\n",j+1);
}
}
}
}

return 0;

}







Measured memory_bytes: 2104
k = int(input())
s = input()
l = len(s)
MOD = 10 ** 9 + 7


def comb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


p = MOD
N = 10 ** 6 * 2 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

# Sn の位置をx = l-1,l,..,l+k-1まで全て動かす
# pow(25,x-l-1,MOD)* x-1Cl-1 * pow(26,l+k-1-x,MOD) をかければOK
ans = 0
for x in range(l - 1, l + k):
    ans += pow(25, x - l + 1, MOD) * comb(x, l - 1, MOD) * pow(26, l + k - 1 - x, MOD)
    ans %= MOD
print(ans)
"""
# dp[i][j]:k+l の長さの文字列の中で、長さi で、sのj番目の文字列まじで含む文字列の個数とする
# dp[i][j] = dp[i-1][j-1] + dp[i-1][j] * 25 となる
# これだと10**12でTLEなので、まとめる
# 答えたいのは、dp[k+l][l]で初期化はdp[1][1] = 1 dp[1][0] = 25
# l までいったら遷移の仕方が変わって*26を続けるだけで良いようになる
dp = [[0] * (l + 1) for _ in range(k + l + 1)]
dp[0][0] = 1
for i in range(1, k + l + 1):
    for j in range(l + 1):
        if j == l:
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j] * 26
        else:
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j] * 25
        dp[i][j] %= MOD
print(dp[k + l][l])
"""


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

double dist(double a, double b){ return sqrt(a*a + b*b);
}

struct UFO{
    double x;
    double y;
    double r;
    double v;
    double cos;
    double sin;
    int disabled;
    int signx;
    int signy;
    UFO(){}
    ~UFO(){}
    UFO(int a, int b, int c, int d){
        x = a;
        y = b;
        r = c;
        v = d;
        disabled = 0;
        signx = x;
        signy = y;
        cos = x / dist(x, y);
        sin = y / dist(x, y);
    }
    UFO(const UFO& z){
        x = z.x; y = z.y; r = z.r; v = z.v;
        disabled = z.disabled;
        signx = z.signx;
        signy = z.signy;
        cos = z.cos;
        sin = z.sin;
    }
    bool operator<(const UFO& z) const {
        if( disabled - z.disabled ) return disabled < z.disabled;
        if( dist(x, y)-dist(z.x, z.y) ) return dist(x, y) < dist(z.x, z.y);
        return r < z.r;
    }
    void step(){
        double t1, t2;
        t1 = x - v * cos;
        t2 = y - v * sin;
        if( t1 * signx <= 0 ){ x = 0; }
        else{ x = t1; }
        if( t2 * signy <= 0 ){ y = 0; }
        else{ y = t2; }
    }
};

typedef vector<UFO> VU;

int main(){
    int N;
    double R;
    for(;cin >> R >> N, R||N;){
        VU u;
        for(int i = 0; i < N; i++){
            double a, b, c, d;
            cin >> a >> b >> c >> d;
            u.push_back( UFO(a, b, c, d) );
        }
        int ans = 0, count = 0;
        while(true){
            for(int i = 0; i < u.size(); i++){
                if( u[i].disabled ) continue;
                u[i].step();
                if( dist(u[i].x, u[i].y) <= R ){
                    u[i].disabled = 1;
                    ans++;
                }
            }
            sort(u.begin(), u.end());
            if( u[0].disabled ) break;
            double a = -u[0].y, b = u[0].x;
            for(VU::iterator it = u.begin(); it != u.end(); it++){
                if( it->disabled ) continue;
                if( dist(it->x-u[0].x, it->y-u[0].y) <= it->r ){
                    it->disabled = 1;
                }
                if( u[0].x*it->x+u[0].y*it->y >= 0 &&
                    abs(a*it->x+b*it->y)/dist(a, b) <= it->r ){
                    it->disabled = 1;
                }
            }
            sort(u.begin(), u.end());
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1256
import math
def sosu(x):
    if x == 1:
        return False

    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False
    return True

x = []
n = int(input())
for i in range(n):
    k = int(input())
    if sosu(k):
        x.append(k)
print(len(x))


Measured memory_bytes: 5684
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    unsigned long long int k;
    cin>> n>> k;
    int a[n];
    map<int ,int> m;
    vector<int> v;
    for (int i = 0; i < n; ++i)
    {
       cin>>a[i];
    }
    
    int i=1;
    while(m.count(i)==0)
    {
       // cout<< i <<" ";
        m[i]=0;
        v.push_back(i);
        i=a[i-1];
    }
    int rep=i;
    if (k<v.size())
    {
        cout << v[k] ;
    }
    else
    {
        k-=v.size();
        int ind=0;
        for (int i = 0; i < v.size(); ++i)
        {
            if (v[i]==rep)
            {
                ind = i;
                break;
            }
        }
        
        cout<< v[ind+k%(unsigned long long int)(v.size()-ind)];
    }
    return 0;
}

Measured memory_bytes: 13764
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
	cout << (n+1)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  rep(i, n) rep(j, n)
    cin >> a[i][j];
  vector<vector<ll>> dp(n+1, vector<ll>(1<<n));
  dp[0][0] = 1;
  rep(j, 1<<n) {
    int i = __builtin_popcount(j);
    rep(k, n) {
      if ((~j)>>k&1 && a[i][k]) {
        (dp[i+1][j|1<<k] += dp[i][j]) %= MOD;
        }
    }
  }
  cout << dp[n][(1<<n)-1] << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int x;
	int N;
	string S;
	int maxValue;

	x = 0;

	cin >> N;
	cin	>> S;

	maxValue = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') {
			x += 1;
		}
		else {
			x -= 1;
		}
		
		if (maxValue > x) {
			maxValue = maxValue;
		}
		else {
			maxValue = x;
		}
	}

	cout << maxValue << endl;

}

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>

namespace adaptor = boost::adaptors;

int64_t N, X[110];

int64_t calc_loss(int64_t p)
{
	int64_t loss = 0;
	for (int64_t i = 0; i < N; i++)
	{
		loss += pow((X[i] - p), 2);
	}

	return loss;
}

void solve()
{
    std::cin >> N;
	for (int i = 0; i < N; i++)
	{
		std::cin >> X[i];
	}

	int64_t min_loss = pow(10, 7);

	for (int64_t p = 1; p <= 100; p++)
	{
		int64_t loss = calc_loss(p);
		if (loss < min_loss) min_loss = loss;
	}

	std::cout << min_loss << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 3652
N, *AS = $stdin.read.split.map(&:to_i)
def n_2(a)
  return 0 if a.odd?
  30.downto(1) do |i|
    k = 2**i
    next if k > a
    if a % k == 0
      return i
    end
  end
  return 0
end
#AS.each do |a|
#  p a: a, n_2: n_2(a)
#end
p AS.map{|a| n_2(a)}.inject(:+)

Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,a,b; string s;
    cin>>n>>a>>b>>s;
    int cnt1=0,cnt2=0;
    rep(i,n){
        if(s[i]=='a'&&cnt1<a+b){
            cout<<"Yes"<<endl;
            cnt1++;
        }
        else if(s[i]=='b'&&cnt1<a+b&&cnt2<b){
            cout<<"Yes"<<endl;
            cnt1++; cnt2++;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896