akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	string s, t;
	cin >> s >> t;
	int flag = 0;
	rep(i, s.size()) {
		int temp = 1;
		rep(j, s.size()) {
			int num = i + j;
			if (num >= s.size())num -= s.size();
			if (s[num] != t[j])temp = 0;
		}
		if (temp == 1)flag = 1;
	}
	if (flag == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


	return 0;
}


Measured memory_bytes: 256
n,d = gets.strip.split(' ').map(&:to_i)
x = readlines.map {|line| line.strip.split(' ').map(&:to_f) }

result = 0
n.times do |i|
  (i+1..n-1).to_a.each do |j|
    next if i==j
    dis = Math.sqrt( x[i].zip(x[j]).map {|y, z| (y-z)**2 }.inject(:+) )
    result+=1 if dis.floor - dis == 0.0
  end
end

p result



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

using namespace std;

int main(){
    string s; cin >> s;
    long long ans = 0;
    vector<long long>bv(s.size(),0);
    for(int i = 0; i < s.size();i++){
        if(i){
            bv[i] += bv[i-1] + (s[i] == 'B');
        } else {
            bv[i] = (s[i] == 'B');
        }
    }
    int idx = 0;
    for(auto c : s){
        if(c == 'W')ans += bv[idx];
        idx++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  vector<int> btn(n);
  int k=1;
  for(int i=0;i<n;i++){
    cin>>btn[i];
  }  
  for(int j=0;j<n+1;j++){
    if(btn[k-1]==2){
      cout<<j+1<<endl; break;
    }else k=btn[k-1];
    
    if(j==n)cout<<-1<<endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll i,j;
    ll k,x;
    cin>>k>>x;
    ll m=max(x-k+1,(ll)-1000000);
    ll M=min(x+k-1,(ll)1000000);

    for(i=m;i<=M;i++) {
        if(i==m) cout<<i;
        else cout<<" "<<i;
    }
    cout<<endl;



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007 
using namespace std;
const int mxN=200000;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h,w,n;
cin>>h>>w>>n;
int ans=n/max(h,w);
if(n%max(h,w)!=0)
{
ans++;
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident $($r:tt)*) => {
        let mut $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident $($r:tt)*) => {
        let $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().unwrap()
    };
}

use std::cmp::max;

fn main() {
    input! {n, k: isize, mut a: [isize; n], mut f: [isize; n]};
    a.sort();
    f.sort_by_key(|&x| -x);
    let g = a.iter().zip(f.iter()).map(|(x, y)| x * y).max().unwrap();
    let mut l = -1;
    let mut r = g;
    while r - l > 1 {
        let x = l + (r - l) / 2;
        let mut k0 = 0;
        for (a0, f0) in a.iter().zip(f.iter()) {
            k0 += max(
                0,
                a0 - x / f0
            );
        }
        if k0 > k {
            l = x;
        } else {
            r = x;
        }
    }
    println!("{}", r);
}

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

long long int gcd(long long int a,long long int b){
  if(a%b==0) return b;
  return gcd(b,a%b);
}

int main(){
  long long int x,y;
  cin>>x>>y;
  if(x<y) swap(x,y);
  cout<<gcd(x,y)<<endl;
  return 0;
}



Measured memory_bytes: 3100
#include <cstdio>
#include <queue>

int count[26];

int main()
{
  int h, w;
  char s[101];
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i)
  {
    scanf("%s", s);
    for (int j = 0; j < w; ++j)
    {
      count[s[j] - 'a']++;
    }
  }
  std::priority_queue<int> q;
  for (int i = 0; i < 26; ++i)
  {
    if (count[i] == 0) continue;
    q.emplace(count[i]);
  }
  int m4 = (h / 2) * (w / 2);
  int m2 = (h & 1) * (w / 2) + (w & 1) * (h / 2);
  int m1 = h & w & 1;
  while (m4 > 0)
  {
    int a = q.top(); q.pop();
    if (a < 4)
    {
      puts("No");
      return 0;
    }
    q.emplace(a - 4);
    m4--;
  }
  while (m2 > 0)
  {
    int a = q.top(); q.pop();
    if (a < 2)
    {
      puts("No");
      return 0;
    }
    q.emplace(a - 2);
    m2--;
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
import itertools
n, m, x = map(int, input().split())
ca = []
for _ in range(n): ca.append(list(map(int, input().split())))
ans = 10 ** 19
t = False
for i in range(1, n+1):
    for idx in itertools.combinations(range(n), i):
        l = [0]*m
        c = 0
        for j in idx:
            for k, v in enumerate(ca[j][1:]):
                l[k] += v
            c += ca[j][0]
        if min(l) >= x:
            ans = min(ans, c)
            t = True
if t: print(ans)
else: print(-1)

Measured memory_bytes: 9228
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, A, B, i, pass=0, countb=0;
    string S;

    cin >> N >> A >> B >> S;

    for(i=0; i<N; i++){
        if(S[i]=='a'){
            if(pass < A+B){
                cout << "Yes" << endl;
                pass++;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if(S[i]=='b'){
            countb++;

            if(pass<A+B && countb<=B){
                cout << "Yes" << endl;
                pass++;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if(S[i]=='c'){
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 896
n, x, m = map(int, input().split())
mod_value = [-1 for i in range(2*m)] #余りの値を頭から格納
mod_check = [False for i in range(m)] #余りが現れたか否か
value = x
i = 0
head = 0
while i < n:
    if not mod_check[value]:
        mod_value[i] = value
        mod_check[value] = True
        i += 1
        value = (value**2)%m
    else:
        head = mod_value.index(value)
        break
if i == n:
    print(sum(mod_value[:n]))
else:
    block_size = i - head
    block_num = (n-head)//block_size
    print(sum(mod_value[:head]) + sum(mod_value[head:i])*block_num + sum(mod_value[head:head+(n-head)%block_size]))

Measured memory_bytes: 13120
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

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

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

  int bestd = -1, best = 0;
  // <d,idx>
  rep(i,n-1){
    cout << "? 1 " << i+2 << endl;
    int d;
    cin>>d;
    if(d > bestd){
      bestd = d;
      best = i+2;
    }
  }

  vector<int> ans(n,0);
  ans[0] = best;
  repl(i,1,n+1) if(i!=best){
    cout << "? " << best << " " << i << endl;
    int d;
    cin>>d;
    assert(ans[d]==0);
    ans[d] = i;
  }

  cout << "!";
  rep(i,n) cout << " " << ans[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 3640
H,W = map(int, input().split())

a = list()
for i in range(H):
	a.append(input())

for _ in range(W+2): print('#', end='')
print()

for i in range(H):
	print('#', end='')
	print(a[i], end='')
	print('#')
	
for _ in range(W+2): print('#', end='')
print()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int a, b;
    cin >> a >> b;

    cout << 6 - (a+b) << endl;

    return 0;
}


Measured memory_bytes: 256
/* ex9_1
   moka223711 */

#include <stdio.h> 
#define SIZE 15

typedef struct stack{ // 文字列を格納するスタック
    int size;
    int count; // スタックに格納されたデータ数を表す変数
    char data[SIZE]; // スタックにデータを格納するための配列
    char *top; // スタックの先頭アドレスを表すポインタ
}stack;

void initialize_stack(stack *stk); // スタックを初期化するための関数
void print_stack(stack *stk); // スタックに格納されているデータを出力するための関数
void push(stack *stk, char input); // スタックの先頭にデータを格納するための関数
void pop(stack *stk); // スタックの先頭からデータを取り出すための関数

int main(void){
    stack stk;
    char input; // 入力を受け取るための変数
    initialize_stack(&stk); // スタックを初期化
    while((input = getchar()) != EOF){ // 入力ファイルの終端に達するまで文字を受け取る
        if(input != 'B')push(&stk, input); // 入力された文字が'0'か'1'だったときはスタックの先頭に文字を格納する
        else if(stk.count > 0)pop(&stk); // 入力された文字が'B'でありスタックの要素が空でなければ先頭から文字を削除する
    }
    print_stack(&stk); // スタックに格納されているデータを出力
    return 0;
}

// スタックを初期化するための関数
void initialize_stack(stack *stk){
    stk->count = 0; // スタックに格納されているデータの総数は0
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]); // スタックの先頭アドレスをstk->topに格納する
}

void print_stack(stack *stk){
    int i;
    for(i = 0; i < stk->count; i++) // 格納されているデータをすべて出力していく
        printf("%c", stk->data[stk->size-i-1]);
    printf("\n");// 最後に改行を出力して終了
}

// スタックの先頭にデータを格納するための関数
void push(stack *stk, char input){
    stk->top--; // スタックの先頭のアドレスを一つずらす
    *(stk->top) = input; // スタックの先頭に文字を格納する
    stk->count++; // スタックのデータの総数のカウントを一つ増やす
}

void pop(stack *stk){
    stk->top++; // スタックの先頭アドレスを一つずらす
    stk->count--; // スタックのデータの総数のカウントを一つ減らす
}


Measured memory_bytes: 1444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);
		int[] s  = {0,0,0,0};
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int k = in.nextInt();
		int full = 0;

		if(a == k) {
			full = a;
		}else if(a > k) {
			full = k;
		}else {
			full = a;
			if(b <= k-a) {
				full -= k-a-b;
			}
		}
		System.out.println(full);

	}

}


Measured memory_bytes: 35768
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
int dp[100005][3];
int main(){
    int n;
    scanf("%d",&n);
    int a[100005],b[100005],c[100005];
    for(int i=1;i<=n;i++){
        scanf("%d %d %d",&a[i],&b[i],&c[i]);
    }
    for(int i=1;i<=n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    printf("%d\n",max(dp[n][0],max(dp[n][1],dp[n][2])));
}


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

using namespace std;

int main(int argc, char const *argv[]) {

        //  情報の数　棟　　　階　　　何番目　　何人
        int Inf_num, ridge, floor, num_sp, person;
        int uni[4][3][10] = {0};
        cin >> Inf_num; //情報の件数を入力
        for(int i = 0; i < Inf_num; i++) {
                cin  >> ridge >> floor >> num_sp >> person;
                uni[ridge-1][floor-1][num_sp-1] += person;
                //０以下にならない。
                if(uni[ridge-1][floor-1][num_sp-1] < 0) uni[ridge-1][floor-1][num_sp-1] = 0;
        }
        for(int i = 0; i < 4; i++) {
                for(int j = 0; j < 3; j++) {
                        for(int k = 0; k < 10; k++) {
                                cout << ' ' << uni[i][j][k];
                        }
                        cout << '\n';
                }
                if(i == 3) break;
                cout << "####################\n";
        }

        return 0;
}



Measured memory_bytes: 3092
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n , i, sw = 0 , nx = 0,ny = 0 , diff;
  scanf("%d",&n);
  int t[n],x[n],y[n];
  for(i = 0; i < n; i++){
    scanf("%d %d %d" , &t[i], &x[i] ,&y[i]);
  }
  if(x[0]+y[0] > t[0] || (x[0]+y[0] < t[0] && (t[0]-x[0]-y[0])% 2!= 0)){
    sw = 1; //printf("one");
  }else{
    nx = x[0]; ny = y[0];
  }
  if(sw == 0){
  for(i = 1; i < n ; i++){
    diff = abs(x[i] - nx) + abs(y[i] - ny);
    if(diff > t[i] - t[i-1] || (diff < t[i] - t[i-1]&& (t[i] - t[i-1] - diff) %2 != 0)){
      sw = 1; //printf("two%d",i);
      break;
    }
    else{
      nx = x[i]; ny = y[i];
    }
  }
  }
  if(sw == 0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n;
vector<Int> a;
using P = pair<Int, Int>;
vector<P> v;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	for(auto &i:a) cin >> i;
	Int mi = 1e9, ma = -1e9, imi = -1, ima = -1;
	for(size_t i=0; i<a.size(); ++i){
		if(a[i] > ma){
			ma = a[i];
			ima = i;
		}
	}
	for(size_t i=0; i<a.size(); ++i){
		if(i != ima && a[i] < mi){
			mi = a[i];
			imi = i;
		}
	}
	for(size_t i=0; i<a.size(); ++i){
		if(a[i] >= 0 && i != imi && i != ima){
			v.push_back(P(a[imi], a[i]));
			a[imi] -= a[i];
		}
	}
	for(size_t i=0; i<a.size(); ++i){
		if((a[i] < 0 || i == imi) && i != ima){
			v.push_back(P(a[ima], a[i]));
			a[ima] -= a[i];
		}
	}
	cout << a[ima] << "\n";
	for(auto i:v) cout << i.first << " " << i.second << "\n";
}

Measured memory_bytes: 4336
from bisect import bisect_right

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=lambda x: x[1], reverse=True)

res = 0
fin = 0
for b, c in bc:
    count = bisect_right(a, c, lo=fin, hi=min(fin+b, len(a))) - fin
    fin += count
    res += count * c
for i in range(fin, len(a)):
    res += a[i]

print(res)


Measured memory_bytes: 34636
<?php
for($i=0;$i<=4;$i++){
$a[] = trim(fgets(STDIN));
}
$ans=0;
foreach($a as $value) {
    if ($value % 10 == 0) {
        $b[] = 0;
    } else {
        $b[] = 10 - $value % 10;

}
$ans+= $value;
}
sort($b);
$b[4]=0;
foreach($b as $value){
    $ans += $value;
}
echo $ans;

Measured memory_bytes: 4728
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
  var anser = '';
    if(a > b){
      for(var i=0; i<a; i++){
        anser += String(b);
      }
      }else if(a <= b){
      for(var i=0; i<b; i++){
        anser += String(a);
      }
       }
    console.log(anser);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const double PI = 3.141592653589793238462643383;

int main() {
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double kaku,hs,ms;
  hs = h*30+m*0.5;
  ms = m*6;
  if (hs > ms) kaku = hs-ms;
  else kaku = ms-hs;
  // if (kaku > 180) {
  //   kaku = 360.0 - kaku;
  // }
  double ans;
  double aabb = double(a*a+b*b);
  ans = aabb - 2*a*b*cos(kaku * PI / 180.0);
  ans = sqrt(ans);
  printf("%.20f\n", ans);
  // cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>

// 60min
int main(void){
  int h = 0, w = 0;
  char a[101][101];

  scanf("%d%d", &h, &w);

  for(int i = 0; i < h; i++){
    char tmp;
    scanf("%c", &tmp);
    for(int j = 0; j < w; j++){
      scanf("%c", &a[i][j]);
    }
  }
  while(1){
//    fprintf(stderr, "enter while()\n");
    int cnt = 0;
    // 全て白い行があるか
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
//        printf("i = %d j = %d a[i][j] = %c\n", i, j, a[i][j]);
        if(a[i][j] == '#'){
//          printf("break->\n");
          break;
        }else if(j == w - 1){
//          printf("aaaa\n");
          // 全て白い行だったので取り除く
          for(int k = i + 1; k < h; k++){
            for(int l = 0; l < w; l++){
             a[k - 1][l] =a[k][l];
            }
          }
          cnt++;
          h--;
        }
//        printf("ffffff2\n");
      }
//      printf("ffffff1\n");
    }

    // 全て白い列があるか
    for(int i = 0; i < w; i++){
      for(int j = 0; j < h; j++){
        if(a[j][i] == '#'){
          break;
        }else if(j == h - 1){
          // 全て白い列だったので取り除く
          for(int k = i + 1; k < w; k++){
            for(int l = 0; l < h; l++){
             a[l][k - 1] = a[l][k];
            }
          }
          cnt++;
          w--;
        }
      }
    }
//    fprintf(stderr, "last while()\n");

    if(cnt < 1){
      break;
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      printf("%c", a[i][j]);
    }
    printf("\n");
  }
  

  return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 100000 + 100;
struct Node {
    int pos;
    int dis;
    Node() {}
    Node(int p, int d) {
        pos = p;
        dis = d;
    }
};
int n, m, u, v, d;
bool flag;
int num[maxn], fa[maxn];
bool vis[maxn];
vector<Node> G[maxn];
queue<Node> que;

void Init() {
    flag = true;
    memset(vis, 0, sizeof(bool) * (n + 1));
    for(int i = 1; i <= n; ++i) {
        G[i].clear();
    }
    for(int i = 1; i <= n; ++i) {
        fa[i] = i;
    }
}

int Find(int x) {
    return (x == fa[x]? x: fa[x] = Find(fa[x]));
}

void unit(int x, int y) {
    int xx = Find(x);
    int yy = Find(y);
    fa[xx] = yy;
}

bool bfs(int x) {
    num[x] = 0;
    vis[x] = true;
    while(!que.empty()) {
        que.pop();
    }
    que.push(Node(x, 0));
    while(!que.empty()) {
        Node tmp = que.front();
        que.pop();
        int len = G[tmp.pos].size();
        for(int i = 0; i < len; ++i) {
            int pos = G[tmp.pos][i].pos;
            int d = G[tmp.pos][i].dis;
            if(!vis[pos]) {
                vis[pos] = true;
                num[pos] = tmp.dis + d;
                que.push(Node(pos, num[pos]));
            } else if(num[pos] != tmp.dis + d) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%d%d", &n, &m) != EOF) {
        Init();
        for(int i = 0; i < m; ++i) {
            scanf("%d%d%d", &u, &v, &d);
            G[u].push_back(Node(v, d));
            G[v].push_back(Node(u, -d));
            unit(v, u);
        }
        for(int i = 1; i <= n; ++i) {
            if(!vis[Find(i)]) {
                if(!bfs(Find(i))) {
                    flag = false;
                    break;
                }
            }
        }
        if(flag) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
#include <iomanip>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
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; }

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

	int n;
	cin >> n;
	vector<ld> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	vector<vector<ld>> dp(n + 1, vector<ld>(n + 1,(ld)0));

	dp[0][0] = 1;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i + 1; j++) {
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
			if (j >= 1) {
				dp[i + 1][j] += dp[i][j - 1] * p[i];
			}
		}
	}

	ld ans = 0;
	for (int i = (n + 1) / 2; i <= n; i++) {
		ans += dp[n][i];
	}
	cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 141056
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
#define MOD 1000000007
typedef int ll;
using namespace std;
int  n,i,j,k,z,m,q,r,timer,v,tot,x,y,xx, yy,INF, sz;
int a[100500], cnt[100500];
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 1; i <= n - 1; i++) {
        if (a[i - 1] + a[i] >= k) {
            cout << "Possible" << endl;
            for (int j = 0; j < i - 1; j++)
                cout << j+1 << endl;
            for (int j = n-2; j > i - 1; j--)
                cout << j+1 << endl;
            cout << i << endl;
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define INF 1e16
#define mod 1e9+7


int main() {
  ll a,b;
  cin>>a>>b;
  if(a<6){
    co(0);
  }
  if(a>5&&a<13){
    co(b/2);
  }
  if(a>12){
    co(b);
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
int main(){
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  Vector c(n,0),s(n,0),f(n,0);
  rep(i,n-1)cin >> c[i] >> s[i] >> f[i];
  rep(i,n){
    int t = 0;
    repl(j,i,n-2){
      if(t < s[j])t = s[j];
      else if(t % f[j] == 0);
      else t += f[j] - t % f[j];
      t += c[j];
    }
    cout << t << endl;
  }
}


Measured memory_bytes: 256
def gcd(a,b):
    if b<a:
        x=b 
        y=a
    else:
        x=a
        y=b
    #x>y
    while x%y!=0:
        newy=x%y
        x=y
        y=newy
    return y
def lcm(a,b):
    return(a*b//gcd(a,b))
N=int(input())
curlcm=1
for _ in range(N):
    curlcm=lcm(curlcm,int(input()))
print(curlcm)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N];

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i+1<=n;i+=2) {
		if (a[i]+a[i+1]>=0) break;
		a[i]=-a[i]; a[i+1]=-a[i+1];
	}
	long long ans=0;
	for (int i=1;i<=n;i++) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String);
    for i in 0..16 {
        let mut tmp = "".to_string();
        for j in 0..4 {
            if (i >> j) % 2 == 1 {
                tmp.push('A');
            }
            match j {
                0 => tmp += "KIH",
                1 => tmp.push('B'),
                2 => tmp.push('R'),
                _ => (),
            }
        }
        if s == tmp {
            println!("YES");
            return;
        }
    }
    println!("NO");

}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define int long long
using namespace std;

main()
{
    int n;
    string s;
    cin >> n >> s;
    int cur = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            cur++;
        } else {
            cur--;
        }
        ans = max(ans, cur);
    }
    cout << ans;
}


Measured memory_bytes: 764
/**
*    author:  Dooloper
*    created: 03.05.2020 20:39:41
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>


using namespace std;
typedef unsigned long long ll;

int main() {
    cin.tie(0);
    int N;cin>>N;
    int K;cin>>K;
    vector<int> human(N,0);
    for(int i = 0 ;i < K; i++){
        int d;cin>>d;
        for(int j = 0; j < d; j++){
            int keep;cin>>keep;
            human.at(keep-1) = 1;
        }
    }
    int cnt = 0;
    for(int i:human){
        if(i ==0)cnt++;
    }

    cout<<cnt<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		sc.nextLine();
		for (int i = 0; i < n; i++)
		{
			int point = 0;
			int outCount = 0;
			boolean base[] = new boolean[3];
			while (outCount < 3)
			{
				String event = sc.nextLine();
				
				if (event.equals("HIT"))
				{
					if (base[2])
					{
						point++;
					}
					base[2] = base[1];
					base[1] = base[0];
					base[0] = true;
				}
				else if (event.equals("HOMERUN"))
				{
					for (int j = 0; j < 3; j++)
					{
						if (base[j])
						{
							point++;
							base[j] = false;
						}
					}
					point++;
				}
				else if (event.equals("OUT"))
				{
					outCount++;
				}
			}
			System.out.println(Integer.toString(point));
		}
	}
}

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
string ans[N], s;
vector < pair < int, int > > g[N];

string convert(int x) {
	string res = "";
	while (x) {
		res += (x % 10) + '0';
		x /= 10;
	}
	while (res.size() < 6) res += '0';
	reverse(every(res));
	return res;
}

int main () {
	cin >> n >> m;
	for (int i = 1; i <= m; i ++) {
		int p, x;
		cin >> p >> x;
		g[p].pb(mp(x, i));
	} 
	for (int i = 1; i <= n; i ++) {
		int cur = 0;
		sort(every(g[i]));
		for (auto it : g[i]) {
			cur ++;
			ans[it.S] = convert(i) + convert(cur);
		}
	}
	for (int i = 1; i <= m; i ++)
		cout << ans[i] << '\n';
	return Accepted;
}

// B...a

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

using namespace std;

int H, W, N;
int A[10005];

int M[100][100];

void solve(){
  int cur = 1;
  for(int i=0; i!=H; ++i){
    if(i%2){
      for(int j=0; j!=W; ++j){
        M[i][j] = cur;    
        --A[cur];
        if(A[cur] == 0) ++cur;
      }
    }
    else{
      for(int j=W-1; j>=0; --j){
        M[i][j] = cur;
        --A[cur];
        if(A[cur] == 0) ++cur;
      }
    }

  }
}

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

    cin >> H >> W;
    cin >> N;
    for(int i=1; i<=N; ++i)
      cin >> A[i];
      
    solve();
    
    for(int i=0; i!=H; ++i){
      for(int j=0; j!=W; ++j){
        cout << M[i][j] << " ";
      }
      cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 384
n, X = map(int, input().split())
x = list(map(abs, [i-X for i in list(map(int, input().split()))]))
x.sort()
if x[0] == 0:
    del x[0]
    n -= 1
def gcd(a, b):
    while True:
        c = a%b
        if c == 0:
            break
        a = b
        b = c
    return b

if n == 1:
    ans = x[0]
else:
    for i in range(1, n):
        x[i] = gcd(x[i], x[i - 1])
    ans = x[-1]
print(ans)

Measured memory_bytes: 20060
#include <bits/stdc++.h>
using namespace std;
int main(){

    int A, B, C;
    cin >> A >> B >> C;
    if(A == B){
        if(B == C) cout << "No\n";
        else cout << "Yes\n";
    }
    else if(B == C || C == A) cout << "Yes\n";
    else cout << "No\n";
        
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        long[] a = new long[n];

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

        long min = Long.MAX_VALUE;
        long x = 0;
        for (int i = 0; i < n-1; i++) {
            x += a[i];
            min = Math.min(Math.abs(sum - x * 2), min);
        }

        System.out.println(min);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 46548
#include<stdio.h>
#include<stdlib.h>

int main(){
  int N,i,j,A[100],count=0,temp;

  scanf("%d",&N);
  //constraint
  if(N<1 || N>100){
    exit(1);
  }

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    //constraint
    if(A[i]<0 || A[i]>100){
      exit(8);
    }
  }
  
  //bubble sort
  for(i=0;i<N-1;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;

	count++;
      }
    }
  }

  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);

  printf("%d\n",count);

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> sum(N);
  for(x:vec){
    cin >> x;
  }
  sum.at(0)=0;
  sum.at(1)=abs(vec.at(1)-vec.at(0));
  for(int i=2;i<N;i++){
    sum.at(i)= min((sum.at(i-1)+abs(vec.at(i)-vec.at(i-1))),
                    (sum.at(i-2)+abs(vec.at(i)-vec.at(i-2))));
  }
  cout << sum.at(N-1)<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;
const ll INF = pow(2,31)-1;

int N;
vector<ll> value;

void update(int i, int x){
    i += N - 1;
    value[i] = x;
    while (i > 0){
        i = (i-1)/2;
        value[i] = min(value[i*2+1],value[i*2+2]);
    }
}
int query(int a, int b, int k, int l, int r){
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return value[k];
    else{
        int c1 = query(a, b, 2*k+1, l, (l+r)/2);
        int c2 = query(a, b, 2*k+2, (l+r)/2, r);
        return min(c1, c2);
    }
}

int main() {
    int n, q, x, y, c;
    cin >> n >> q;
    N = 1;
    while (N < n) N*=2;
    value = vector<ll>(2*N-1,INF);
    REP(i,q){
        cin >> c;
        if (c == 0){
            cin >> x >> y;
            update(x, y);
        }else{
            cin >> x >> y;
            cout << query(x, y+1, 0, 0, N) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    cout << count(s.begin(), s.end(), '1') << endl;
}

Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.*;

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

	public Main() {
		while(in.hasNext())new AOJ1019().doIt();
	}

	class AOJ1019{

		boolean solve(){
			int[] blood = new int[k];
			for(int i=0;i<k;i++)blood[i] = in.nextInt();
//			System.out.println(Arrays.toString(blood));
			int person[][] = new int[n][k];
			for(int i=0;i<n;i++)for(int s=0;s<k;s++)person[i][s] = in.nextInt();
			boolean sw = true;
			for(int i=0;i<k;i++){
				int sum = 0;
				for(int s=0;s<n;s++)sum+=person[s][i];
//				System.out.println(i+" "+sum+" "+blood[i]);
				if(sum>blood[i])return false;
			}
			return true;
		}
		
		int n,k;
		
		void doIt(){
			n = in.nextInt();
			k = in.nextInt();
			if(n+k==0)return;
			System.out.println(solve()? "Yes":"No");
		}
	}
}

Measured memory_bytes: 96876
#include<iostream>
using namespace std;
 
int main(){
  bool cards[4][14];
  int n, rank;
  char suit;
 
  for ( int s = 0; s < 4; s++ )
    for ( int r = 1; r <= 13; r++ )
     cards[s][r] = 0;
 
  cin >> n;
  for ( int i = 0; i < n; i++ ){
   cin >> suit >> rank;
   if ( suit == 'S') cards[0][rank] = 1;
   if ( suit == 'H') cards[1][rank] = 1;
   if ( suit == 'C') cards[2][rank] = 1;
   if ( suit == 'D') cards[3][rank] = 1;
}
  for ( int s = 0; s < 4; s++ ){
   for ( int r = 1; r <= 13; r++ ){
     if ( cards[s][r] ) continue;
     if ( s == 0 ) suit = 'S';
     if ( s == 1 ) suit = 'H';
     if ( s == 2 ) suit = 'C';
     if ( s == 3 ) suit = 'D';
     cout << suit << " " << r << endl;
   }
 }
 
return 0;
}


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

int main(){
    int k;
    string s;
    cin >> k >> s;
    size_t n = s.length();
    if (n<=k){
        cout << s << endl;
    }else{
        for (int i = 0; i < k; ++i){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

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

int main(void){
    long long A, B, V, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if(T*(V-W) >= abs(A-B)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    int so1,so2,so3,so4;
    so1=x+r;
    so2=x-r;
    so3=y+r;
    so4=y-r;
    if(H>=so3&&0<=so4){
        if(W>=so1&&0<=so2){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>
#include<stdlib.h>

#define NIL NULL


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

typedef struct node * Node;

Node root;

void preorder(Node);
void inorder(Node);
void insert(int);

int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for(i=0;i<n;i++)
    {
      scanf("%s", com);
      if ( com[0] == 'i' )
	{
	  scanf("%d", &x);
	  insert(x);
	}
      
      else if ( com[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    }

  return 0;
}

void insert(int k)
{
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  
  while(x!=NIL)
    {
      y=x;
      if(z->key<x->key) x=x->left;
      else x=x->right;
    }
  z->parent=y;
  if(y==NIL) root=z;
  else if( z->key < y->key ) y->left = z;
  else y->right = z;

}

void inorder(Node x)
{
  if(x!=NIL)
    {
      inorder(x->left);
      printf(" %d",x->key);
      inorder(x->right);
    }
}

void preorder(Node x)
{
  if(x!=NIL)
    {
      printf(" %d",x->key);
      preorder(x->left);
      preorder(x->right);
    }
}

Measured memory_bytes: 24040