akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int a, b;
    cin >> a >> b;

    int mini = 10000000;
    for(int i = 1; i < 1251; i++) {
        //cout << floor(i*0.1) << " " <<  floor(i*0.08) << endl;
        if(floor(i*0.1) == b && floor(i*0.08) == a) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

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

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

    sort(all(v));

    int cl = v[(n-1)/2];
    int cr = v[n/2];

    rep(i, n){
        if(d[i] <= cl){
            cout << cr << endl;
        }
        else{
            cout << cl << endl;
        }
    }
}

Measured memory_bytes: 3712
#[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, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        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>().expect("Parse error")
    };
}
fn gcd_list(numbers: Vec<usize>) -> usize {
    fn gcd(a: usize, b: usize) -> usize {
        if b == 0 {
            a
        } else {
            gcd(b, a % b)
        }
    }
    if let Some((&head, tail)) = numbers.split_first() {
        // &b に注意
        tail.iter().fold(head, |a,&b| gcd(a, b))
    } else {
        panic!("Can't unwrap!");
    }
}
use std::cmp;

fn main() {
    input! {
        n: u64,
        xl: i64,
        x: [i64; n],
    }
    let mut x = x;
    if x.len() == 1 {println!("{}", i64::abs(x[0] - xl));return;}
    x.sort();
    let mut vv = Vec::new();
    let mut mi = i64::abs(x[0] - xl);
    for i in 1..n {
        mi = cmp::min(i64::abs(x[i as usize]- xl), mi);
        vv.push((x[i as usize] - x[(i-1) as usize]) as usize);
    }
    vv.push(mi as usize);
    println!("{}", gcd_list(vv));
}

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

int main(){
  string s,base="CODEFESTIVAL2016";
  cin>>s;
  int count=0;
  for(int i=0;i<16;i++){
    if(s.at(i)!=base.at(i)) count++;
  }
  cout<<count<<endl;
}

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

int main(){
  string S;
  cin >> S;
  int N;
  cin >> N;
  int ans = 0;
  int x = S.length();
  for(int i = 0; i < N; ++i){
    string T;
    cin >> T;
    int l = T.length();
    T += T;
    for(int i = 0; i < l; ++i){
      bool f = true;
      for(int j = 0; j < x; ++j){
        if(S[j] != T[i+j]){
          f = false;
          break;
        }
      }
      if(f){
        ++ans;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    string s;
    set<ll>s1,s2;
    cin>>s;
    ll i;
    fl(i,0,s.size())
    {
        if(s[i]=='R')
            s1.insert(i);
        else
            s2.insert(i);
    }
    ll arr[s.size()]={0};
    fl(i,0,s.size())
    {
        if(s[i]=='R')
        {
            auto it=s2.lower_bound(i);
            //cout<<*it-i<<endl;
            if(((*it)-i)%2==0)
                arr[*it]++;
            else
                arr[(*it)-1]++;
        }
        else
        {
            auto it=s1.lower_bound(i);
            it--;
           // cout<<i-*it<<endl;
            if((i-(*it))%2==0)
                arr[*it]++;
             else
                arr[(*it)+1]++;
        }
    }
    fl(i,0,s.size())
        cout<<arr[i]<<" ";
    cout<<endl;
    
}


Measured memory_bytes: 6912
//PDF解説に倣ってZ-algorithm
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  string s;
  cin>> n >> s;
  
  int ans=0;
  for (int i=0; i<n; i++){
    vector<int> v(n);
    v[i]=n-i;
    int j=i+1,k=0;
    while (j<n){
      while (j+k<n && s[i+k]==s[j+k]) k++;
      v[j]=k;
      if (k==0){
        j++;
        continue;
      }
      int l=1;
      while (l+v[i+l]<k){
        v[j+l]=v[i+l];
        l++;
      }
      j+=l; k-=l;
    }
    for (int j=i+1; j<n-ans; j++){
      if (v[j]<=j-i) ans=max(ans,v[j]);
    }
  }
      
  cout<< ans <<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	long long max,min;
	max=b*(n-1)+a;
	min=a*(n-1)+b;
	if(max<min)
	cout<<0<<endl;
	else
	cout<<max-min+1<<endl;
	return 0;
 } 

Measured memory_bytes: 3560
n = int(input())
ac = wa = tle = re = 0
for i in range(n):
  s = input()
  if s == "AC":
    ac += 1
  elif s == "WA":
    wa += 1
  elif s == "TLE":
    tle += 1
  elif s == "RE":
    re += 1
print("AC x", ac)
print("WA x", wa)
print("TLE x ", tle)
print("RE x", re)

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

const int DIM = 1e5 + 5;

int cnt1[DIM], frq[DIM], cnt2[DIM];

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        cnt1[x % m] ++;
        
        frq[x] ++;
        if( frq[x] % 2 == 0 )
            cnt2[x % m] ++;
    }
    
    int ans = cnt1[0] / 2;
    cnt1[0] = 0;
   
    if( m % 2 == 0 ) {
        ans += cnt1[m / 2] / 2;
        cnt1[m / 2] = 0;
    }
    
    for( int i = 1; i <= m / 2; i ++ ) {
        int aux = min( cnt1[i], cnt1[m - i] );
        
        ans += aux;
        cnt1[i] -= aux;
        cnt1[m - i] -= aux;
    }
    
    for( int i = 1; i < m; i ++ )
        ans += min( cnt1[i] / 2, cnt2[i] );
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;	
int main()
{  
	int n,k,s=0,minv=1000000;
	cin>>n;
	int x[n+1];
	int maxv=0;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
		if(x[i]>maxv)
			maxv=x[i];
	}
	for(int k=1;k<=maxv;k++)
	{
		s=0;
		for(int i=1;i<=n;i++)
		{
			s+=(x[i]-k)*(x[i]-k);
		}
		if(s<minv)
			minv=s;
	}
	cout<<minv;
	return 0;
} 

Measured memory_bytes: 256
<>;
$_=<>;
$x=y/R//*y/G//*y/B//;
for$i(1..(@_=/./g)){
	for($i..@_-$i){
		$x-=($_[$_-$i]^$_[$_]^$_[$_+$i])=~W
	}
}
print$x


Measured memory_bytes: 5260
#include <iostream>
#include <string>
using namespace std;
int main()
{
string S,T;
int i=0,j;
char x;
cin >> S >> T;
j=S.size()-1;
for(int k=j ; k>=0 ; k-- ){
    x=S[j];
    S.insert(i,1,x);
    S.erase(j+1);
    if(S==T){
        cout<<"Yes";
        return 0;
    }
}
cout <<"No";
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<string> v(N) ;{
    for (int i = 0; i < N; i++) {
  cin >> v.at(i);
    }
  }
  
  sort(v.begin() ,v.end());
  
  int a=1;
  
  for (int i= 1 ; i<N; i++) {
    if(v.at(i) != v.at(i-1)){ a++;
                            }
  }
  cout << a<< endl;
}

Measured memory_bytes: 9596
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() { // 日本語文字列のテスト
    int w = readint;
    int n = readint;

    auto xs = new int[w + 1];
    for (int i = 0; i < xs.length; i++)
        xs[i] = i;

    for (int i = 0; i < n; i++) {
        auto ab = readln.chomp.split(",").to!(int[]);
        int a = ab[0], b = ab[1];
        swap(xs[a], xs[b]);
    }

    foreach (x; xs[1 .. $])
        writeln(x);
}

Measured memory_bytes: 2360
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
string a,b; cin >> a >> b;
int c; c = stoi(a+b);
bool ans = false;
rep(i,400){
	if(c == i * i){
		ans = true;
	}
}
if(ans)	cout <<"Yes" << endl;
else cout << "No" << endl;
}

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; 
using P = pair<int,int>;

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 long long INF = 1LL << 60;


int main(void){
	int n;cin >> n;
  	int M=0,sum=0;
  	for(int i=0;i<n;i++){
    	int a;
     	cin >> a;
      	sum += a; 
 		M = max(M,a);
    } 
  if(sum-M > M) cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}



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

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    vector<int> nums(3);
    for (int i=0; i<3; i++) {
        cin >> nums[i];
    }
    swap(nums[0], nums[1]);
    swap(nums[0], nums[2]);
    for (int i=0; i<3; i++) {
        cout << nums[i] << " \n"[i==2];
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

ll cnt[10000001];
int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    memset(cnt,0,sizeof(cnt));
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; j+=i) {
            cnt[j]++;
        }
    }
    for (ll i = 1; i <= n; ++i) {
        ans += i*cnt[i];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 81764
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

def gcd(a: int, b: int):
    while b:
        a, b = b, a%b
    return a

def lcm(a: int, b:int):
    return a*b // gcd(a,b)

def solve(A: int, B: int):
    print(lcm(A,B))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//-----------------------
// author : xyqkoala
// time : 2020-08-29
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n;cin>>n;
	vector<int> nums(n);
	for(int i=0;i<n;i++) cin>>nums[i];
	// LL sum = 0;
	// LL tcnt = 0;
	// for(auto item:nums){
	// 	sum = (sum+item)%MOD;
	// 	tcnt = (tcnt+((1ll*item*item)%MOD))%MOD;
	// }
	// sum = (1ll*sum*sum)%MOD;
	// LL res = sum-tcnt;
	// res = (res+MOD)%MOD;
	// res = res/2;
	// cout<<res<<endl;
	vector<LL> sif(n+1,0);
	for(int i=0;i<n;i++) sif[i+1] = sif[i]+nums[i];
	LL res = 0;
	for(int i=(n-2);i>=0;i--){
		LL temp = 1ll * (sif[n]-sif[i+1]);
		temp = temp%MOD;
		temp = (temp*nums[i])%MOD;
		res = (res+temp)%MOD;
	}
	cout<<res<<endl;
}



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


int main(){
  char stat[55];
  strcpy(stat,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");

while(1){
  int i,N,K,ansst[105],cst,cnt=0,key[105];
  cin>>N;
  if(N==0)return 0;
  for(i=0;i<N;i++){
    scanf("%d",&key[i]);
  }
  char ss[105];
  scanf("%s",ss);
  K=strlen(ss);
  for(i=0;i<K;i++){
    if(ss[i]>='a'&&ss[i]<='z'){
      cst=ss[i]-'a';
    }else{
      cst=ss[i]-'A'+26;
    }
    ansst[i]=(cst-key[cnt]+52)%52;
    cnt=(cnt+1)%N;
  }
  for(i=0;i<K;i++){
    printf("%c",stat[ansst[i]]);
  }
  printf("\n");
}
}


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

struct node {
    int key;
    struct node *prev, *next;
};

typedef struct node Node;

void init();

void insertNode( int key );

void deleteNode( Node *t );

void deleteFirst();

void deleteLast();

void deleteKey( int key );

Node* listSearch( int key );

Node *nil;

void printList();

int main()
{
    int i;
    int N;
    Node *n;

    scanf("%d", &N);
    init();

    for ( i = 0; i < N; i++ ) {
	char s[100];
	int d;
	scanf("%s", s);
	if ( !strcmp( s, "insert" ) ) {
	    scanf("%d", &d);
	    insertNode( d );
	}
	else if ( !strcmp( s, "delete") ) {
	    scanf("%d", &d);
	    deleteKey( d );
	}
	else if ( !strcmp( s, "deleteFirst" ) ) {
	    deleteFirst();
	}
	else if ( !strcmp( s, "deleteLast" ) ) {
	    deleteLast();
	}
    }
    
    printList();

    return 0;
}


void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}



void insertNode( int key )
{
    Node *n = (Node *)malloc(sizeof(Node));
    n->key = key;
    // ???????????´??????????´??????????
    nil->next->prev = n;
    n->next = nil->next;
    nil->next = n;
    n->prev = nil;
}

void deleteNode( Node *t )
{
    if ( t == nil ) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst()
{
    deleteNode( nil->next );
}

void deleteLast()
{
    deleteNode( nil->prev );
}

void deleteKey( int key )
{
    deleteNode( listSearch( key ) );
}

Node* listSearch( int key )
{
    Node *cur = nil->next;
    while ( cur != nil && cur->key != key ) {
	cur = cur->next;
    }
    
    return cur;
}


void printList()
{
    int i;
    Node *cur = nil->next;
    for ( i = 0; ; i++ ) {
	if ( cur == nil ) {
	    break;
	}
	if ( i != 0 ) {
	    printf(" ");
	}
	printf("%d", cur->key);
	cur = cur->next;
    }
    printf("\n");
}

Measured memory_bytes: 32220
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <random>

#define ff first
#define ss second

using namespace std;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

#define MOD 998244353LL

pii operator+(pii a, pii b)
{
    return {a.ff+b.ff,a.ss+b.ss};
}

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    ll n,x,m;
    cin>>n>>x>>m;
    ll now=x;
    vector<ll> sum={now};
    vector<int> idx(100000,-1);
    idx[now]=0;
    ll answer=now;
    n-=1;
    while(n--){
        now=((now%m)*(now%m))%m;
        if(idx[now]!=-1){
            answer+=now;
            ll tmp=sum.back();
            ll siz=(int)sum.size()-idx[now];
            if(idx[now]!=0) tmp-=sum[idx[now]-1];
            answer+=tmp*(n/siz);
            answer+=sum[idx[now]+n%siz];
            answer-=sum[idx[now]];
            break;
        }
        else{
            idx[now]=sum.size();
            sum.push_back(sum.back()+now);
            answer+=now;
        }
    }
    cout<<answer;

    return 0;
}


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

int main(){
  string S;
  int R = 0, B = 0;
  cin >> S;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == '0'){
      R++;
    }
    else{
      B++;
    }
  }
  cout << 2 * min(R , B) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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


signed main(void) {

	double a, b, x;
	cin >> a >> b >> x;

	double men = x / a;


	double l = 0, r = 90;


	while (r - l > 0.00000001) {
		double mid = (l + r) / 2;

		double rad = (mid / 180) * PI;
		double tri = tan(rad) * a *a / 2;
		double x2;
		if (tri > men) {
			x2 = sqrt(tan(rad) * 2 * men);
		}
		else {
			x2 = tan(rad) * a;
			double rest = men - tri;
			x2 += rest / a;
		}

		if (x2 > b) {
			r = mid;
		}
		else
			l = mid;
	}
	printf("%.8f\n",l);

	return 0;
}


Measured memory_bytes: 384
a, b, k = map(int, input().split())

flg = 1

for i in range(k):
    if flg == 1:
        if a % 2 == 0:
            b += a // 2
            a /= 2
        else:
            a -= 1
            b += a // 2
            a /= 2
    elif flg == -1:
        if b % 2 == 0:
            a += b // 2
            b /= 2
        else:
            b -= 1
            a += b // 2
            b /= 2
    flg *= -1

print(int(a), int(b))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b,c;
  while(cin>>a>>b>>c,a!=-1||b!=-1||c!=-1){
    if(a==-1||b==-1)cout<<"F"<<endl;
    else if(a+b>=80)cout<<"A"<<endl;
    else if(a+b>=65)cout<<"B"<<endl;
    else if(a+b>=50)cout<<"C"<<endl;
    else if(a+b>=30){
      if(c>=50)cout<<"C"<<endl;
      else cout<<"D"<<endl;
    }else cout<<"F"<<endl;
  }
}

Measured memory_bytes: 1156
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ppb pop_back
typedef long long ll;
const int N=200000;
int n;//节点个数 
int a[N+1];//颜色 
vector<int> nei[N+1];//邻接表 
int sz[N+1]/*子树大小*/,cc_sz[N+1]/*CC大小（非根）*/,cc_sz1[N+1]/*CC大小（根，下标为颜色）*/;
int fa[N+1];//父亲 
vector<int> stk/*总递归栈*/,stk_c[N+1]/*颜色们的递归栈*/;
void dfs(int x=1){//求CC们的大小 
//	cout<<x<<"\n";
	sz[x]=1;
	stk_c[a[x]].pb(stk.size());
	stk.pb(x);//压栈 
	for(int i=0;i<nei[x].size();i++){
		int y=nei[x][i];
		if(y==fa[x])continue;
		fa[y]=x;
		dfs(y);
		sz[x]+=sz[y];
	}
	stk.ppb();
	stk_c[a[x]].ppb();//准备回溯，弹出 
	if(stk_c[a[x]].size()>1)cc_sz[stk[stk_c[a[x]].back()+1]]-=sz[x];//贡献（非根） 
	else/*特判*/ cc_sz1[a[x]]-=sz[x];//贡献（根） 
}
ll ans[N+1];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		nei[x].pb(y);nei[y].pb(x);
	}
	stk.pb(0);
	for(int i=1;i<=n;i++)stk_c[i].pb(0);
	dfs();
	for(int i=1;i<=n;i++)cc_sz[i]+=sz[i],cc_sz1[i]+=n;
//	for(int i=1;i<=n;i++)cout<<cc_sz[i]<<" ";puts("");
//	for(int i=1;i<=n;i++)cout<<cc_sz1[i]<<" ";puts("");
	for(int i=1;i<=n;i++)ans[i]=1ll*n*(n+1)/2;
	for(int i=2;i<=n;i++)ans[a[fa[i]]]-=1ll*cc_sz[i]*(cc_sz[i]+1)/2;
	for(int i=1;i<=n;i++)ans[i]-=1ll*cc_sz1[i]*(cc_sz1[i]+1)/2;//减去反面答案 
	for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";
	return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;



int main(){
	int n,a;
	cin >> n;
	V<ll> b;
	map<int, int> m;
	REP(i,n) {
		cin >> a;
		b.push_back(a);
		m[-a-i] += 1;
	}
	ll ans = 0;
	REP(i,n) {
		ans += m[b[i]-i];
	}

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



Measured memory_bytes: 21748
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
	//ABC059
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] a = new int[n];
		long ans1 = 0;
		long ans2 = 0;
		
		for(int i = 0; i < n; i++){
			a[i] = in.nextInt();
		}
		
		//+-+-
		long sum = 0;
		for(int i = 0; i < n; i++){
			sum += a[i];
			if(i % 2 == 0 && sum <= 0){
				long diff = Math.abs(sum) + 1;
				sum += diff;
				ans1 += diff;
			}else if(i % 2 == 1 && sum >= 0){
				long diff = - Math.abs(sum) - 1;
				sum += diff;
				ans1 += Math.abs(diff);
			}
		}
		
		//System.out.println(ans1);
		
		//-+-+
		sum = 0;
		for(int i = 0; i < n; i++){
			sum += a[i];
			if(i % 2 == 1 && sum <= 0){
				long diff = Math.abs(sum) + 1;
				sum += diff;
				ans2 += diff;
			}else if(i % 2 == 0 && sum >= 0){
				long diff = - Math.abs(sum) - 1;
				sum += diff;
				ans2 += Math.abs(diff);
			}
		}
		
		//System.out.println(ans2);
		System.out.println(Math.min(ans1, ans2));
	}
}

Measured memory_bytes: 50788
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    long long N;

    cin >> N;
    vector<vector<long long>> v2v(N, vector<long long>{});
    for (long long i = 0; i < N - 1; i++)
    {
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        v2v[a].push_back(b);
        v2v[b].push_back(a);
    }

    vector<long long> r(N, -1);
    r[0] = 0;
    queue<long long> q;
    q.push(0);
    while (q.size() > 0)
    {
        long long t = q.front();
        q.pop();

        if (t == N - 1)
            break;

        for (auto x : v2v[t])
        {
            if (r[x] == -1)
            {
                r[x] = t;
                q.push(x);
            }
        }
    }

    vector<long long> path;
    long long c = N - 1;
    while (true)
    {
        if (c == 0)
            break;

        path.push_back(c);
        c = r[c];
    }

    vector<long long> r2(N, -1);
    queue<long long> q2;
    long long count = 0;
    r2[0] = 0;
    r2[path[(path.size() + 1) / 2 - 1]] = -2;
    q2.push(0);
    while (q2.size() > 0)
    {
        long long t = q2.front();
        q2.pop();

        if (t == N - 1)
            break;

        count++;

        for (auto x : v2v[t])
        {
            if (r2[x] == -1 && r2[x] != -2)
            {
                r2[x] = t;
                q2.push(x);
            }
        }
    }

    if (N - count == count)
        cout << "Snuke" << endl;
    else if (N - count < count)
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;
}

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

void solve() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    // n日泊まる
    // 最初のk泊まではx円
    // k+1泊目以降はy円

    int a = n - k;
    if (a <= 0) {
        cout << x * n << endl;
    } else {
        cout << x * k + a * y << endl;
    }
}

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



Measured memory_bytes: 256
#include <string.h> 
#include <iostream> 
using namespace std;
 
int main(){
   int k;
    cin>>k;
    string s;
  cin>>s;
   int p=s.size();
    if(p<=k){
      cout<<s<<endl;
     }
    else{
      cout<<s.substr(0,k)<<"..."<<endl;
    }
  return 0;
}

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

int main(){
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if (N<=K){
    cout << X*N << endl;
  }
  if(N>K){
    cout << X*K+Y*(N-K) << endl;
  }
}
    

Measured memory_bytes: 256
#coding:utf-8


w = gets.chomp.to_i
n = gets.chomp.to_i
list = Array.new
wire = Array.new

w.times{|i|
	wire << i+1
}


n.times{|i|
	str = gets.chomp.split(',').map(&:to_i)
	list << str
	a,b = str[0], str[1]

	

	wire[a-1],wire[b-1] = wire[b-1],wire[a-1]

}

puts wire

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

int main() {
    int A, B; cin >> A >> B;
    string ans[100];
    cout << "100 100" << '\n';
    for(int i = 0; i < 100; ++i) {
        if(i < 50) ans[i] = string(100, '#');
        else ans[i] = string(100, '.');
    }

    // want to increase . & # independently
    int addA = 1, addB = 1;
    int x = 1, y = 1;
    // white
    while(addA < A) {
        ans[y][x] = '.';
        ++addA;
        x += 2;
        if(x >= 100) {
            x = 1, y += 2;
        }
    }

    // black
    x = 1, y = 99;
    while(addB < B) {
        ans[y][x] = '#';
        ++addB;
        x += 2;
        if(x >= 100) {
            x = 1, y -= 2;
        }
    }

    for(int i=0; i < 100; ++i) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())

print(0)
sys.stdout.flush()
s = input()

if s == "Vacant":
    exit()

low = 1
high = n-1
tmp = 0
cnt = 1

while low+1 < high:
    mid = (low + high) //2
    
    print(mid)
    sys.stdout.flush()
    t = input()
    cnt += 1
    
    if mid % 2 == 0:
        if t[0] == s[0]:
            low = mid
        elif t[0] == "V":
            exit()
        else:
            high = mid
    else:
        if t[0] == s[0]:
            high = mid
        elif t[0] == "V":
            exit()
        else:
            low = mid

print(high)
sys.stdout.flush()
s = input()
if s[0] == "V":
    exit()
else:
    print(low)
    sys.stdout.flush()
    s = input()
    exit()

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

const int mod=998244353,N=1000010,iv2=(mod+1>>1);
int jc[N],inv[N],n,m,ans,mi[N];

int C(int a,int b)
{
	if (a<b||b<0) return 0;
	return 1ll*jc[a]*inv[b]%mod*inv[a-b]%mod;
}

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int calc(int n,int m)
{
	int ans=C(n+m,n)-C(n+m,n-1);
	return (ans<0?ans+mod:ans);
}

int getfi(int n)
{
	if (n==0) return 0;
	return (1ll*jc[2*n-1]*inv[n-1]%mod*inv[n-1]%mod+mi[n-1])*iv2%mod;
}

int getfo(int n)
{
	if (n<=1) return 0;
	return 1ll*jc[2*n-3]*inv[n-2]%mod*inv[n-2]%mod;
}

int getgi(int n) {return C(2*n-2,n-1);}
int getgo(int n) {return 1ll*(C(2*n-2,n-1)+(n==1))*iv2%mod;}

int solve(int n,int m)
{
	n++,m++;
	int ans=0;
	if (m>=n)
	{
		for (int i=1; i<=n; i++)
			ans=(ans+1ll*getgo(i)*calc(n-i,m-i)%mod*(n-i+m-i+1)+1ll*getfo(i)*calc(n-i,m-i))%mod;
	} else
	{
		for (int i=1; i<=m; i++)
			ans=(ans+1ll*getfi(i)*calc(m-i,n-i-1))%mod;
	}
	return ans;
}

int main()
{
	jc[0]=mi[0]=1;
	for (int i=1; i<N; i++) mi[i]=4ll*mi[i-1]%mod;
	for (int i=1; i<N; i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[N-1]=quickmi(jc[N-1],mod-2);
	for (int i=N-1; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	scanf("%d%d",&n,&m);
	if (n==0||m==0) return printf("%d\n",n+m),0;
	int ans=solve(m,n-1)+solve(n,m-1);
	if (ans>=mod) ans-=mod;
	for (int i=1; i<=n&&i<=m; i++) 
		ans=(ans+1ll*C(i+i-1,i-1)*C(n-i+m-i,n-i))%mod;
	ans=1ll*ans*quickmi(C(n+m,m),mod-2)%mod;
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int,int> > pq;
int dis[100005];
int k;
int main() {
    scanf("%d",&k);
    for(int i=0;i<k;i++) dis[i]=1000000007;
    for(int i=1;i<=9;i++) {
        dis[i%k]=min(dis[i%k],i);
        pq.push(make_pair(-dis[i%k],i));
    }
    while (!pq.empty()) {
        pair<int,int> p=pq.top();pq.pop();
        int x=p.first,y=p.second;
        if (-x!=dis[y]) continue;
        for(int i=0;i<=9;i++) {
            int nw=(y*10+i)%k;
            if (dis[nw]>dis[y]+i) {
                dis[nw]=dis[y]+i;
                pq.push(make_pair(-dis[nw],nw));
            }
        }
    }
    printf("%d\n",dis[0]);
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

struct Student
{
	ll index;
	ll value;
	bool operator < (const Student& s) const
	{
		return value < s.value;
	}
};

int main(void)
{
	ll n; cin >> n;
	vector<Student> a(n);
	rep(i, 0, size(a))
	{
		cin >> a[i].value;
		a[i].index = i + 1;
	}

	sort(all(a));
	each(e, a)
		cout << e.index << " ";

	return 0;
}



Measured memory_bytes: 2432
import scala.io.StdIn._

object Main extends App {
  val Seq(n, m, x) = readLine().split(" ").map(_.toInt).toSeq
  val a            = readLine().split(" ").map(_.toInt).toSeq

  val large = a.count(_ > x)
  val small = a.length - large
  println(math.min(large, small))
}


Measured memory_bytes: 54792
import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))

N = int(input())
h = inpl()

INF = 10e11

# 最小化問題なのでINFに初期化
dp = [ INF for _ in range(100010) ]

# 初期状態
dp[0] = 0

# ループ
for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])

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

int main (){
  int N, A, x, count;
  cin >> N;
  for (int i = 0; i < N ;i++){
    cin >> A;
    x = 1;
    for (int j = 0; ;j++){
      x *= 2;
      if (A % x != 0){
        if (count >= j || i == 0){
          count = j;
        }
        break;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100,mod=1e9+7;
ll nxt[N];
ll b[N][3];
ll d[N][3];
ll a[N];
ll dp[N];
ll par[N];
int32_t main(){
    string s;
    cin >> s;
    ll n=s.size();
    for (int i=0;i<s.size();i++){
        a[i+1]=s[i]-'a'+1;
    }
    ll p1=0;
    for (int i=1;i<n;i++) if (a[i]==a[i+1]) p1=1;
    if (!p1) kill(1);
    nxt[n]=n+1;
    for (int i=n-1;i;i--){
        if (a[i+1]==a[i]) nxt[i]=i+1;
        else nxt[i]=nxt[i+1];
    }
    b[n+1][0]=n+1;
    b[n+1][1]=n+1;
    b[n+1][2]=n+1;
    b[n+2][0]=n+2;
    b[n+2][1]=n+2;
    b[n+2][2]=n+2;
    d[n+1][0]=n+1;
    d[n+1][1]=n+1;
    d[n+1][2]=n+1;
    d[n+2][0]=n+2;
    d[n+2][1]=n+2;
    d[n+2][2]=n+2;
    for (int i=n;i;i--){
        if (a[i]==1){
            b[i][1]=i;
            ll z=nxt[i];
            z--;
            ll y=(z-i+2)/2+((z-i+1)/2)*2;
            y%=3;
            if (y==2){
                b[i][2]=d[z+1][0];
            }
            if (y==0){
                b[i][2]=b[z+1][2];
            }
            if (y==1){
                b[i][2]=b[z+1][1];
            }
        }
        else if (a[i]==2){
            b[i][2]=i;
            ll z=nxt[i];
            z--;
            ll y=((z-i+2)/2)*2+(z-i+1)/2;
            y%=3;
            if (y==1){
                b[i][1]=d[z+1][0];
            }
            if (y==0){
                b[i][1]=b[z+1][1];
            }
            if (y==2){
                b[i][1]=b[z+1][2];
            }
        }
        for (int j=0;j<3;j++){
            if (j==a[i]){
                d[i][j]=i;
                continue;
            }
            ll z=j+a[i];
            z%=3;
            d[i][j]=d[i+1][z];
        }
        for (int j=0;j<3;j++){
            if (b[i][j]>n || b[i][j]==0) b[i][j]=n+1;
            if (d[i][j]>n || d[i][j]==0) d[i][j]=n+1;
        }

    }
    for (int i=n;i;i--) par[i]=a[i]+par[i+1],par[i]%=3;
    //dp[n+1]=1;
   // dp[n]=1;
    for (int i=n;i;i--){
     //   cout << i << " " << par[i] << " " << nxt[i] << " " << b[i][1] << " " << b[i][2] << endl;
        if (par[i]) dp[i]++;
        dp[i]+=dp[b[i][1]+1];
        dp[i]+=dp[b[i][2]+1];
        dp[i]%=mod;
    }
    cout << dp[1] << endl;

}






Measured memory_bytes: 11568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl;
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	ll n,k;
	cin>>n>>k;
	ll dp[n+1];
	dp[0]=0;
	vll v(n);
	rep(i,0,n){
	cin>>v[i];
	v[i]--;
	dp[i+1]=(dp[i]+v[i]+k);
	dp[i+1]%=k;
	}
	map<ll,ll> m;
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		if(i-k>=0) m[dp[i-k]]--;
		ans+=m[dp[i]];
		m[dp[i]]++;
	}
	cout<<ans;
}



Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if(a * b % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

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

int A[2000];

 int search(int n,int A[],int i,int m){
  
  if(m==0) return 1;

  else if(i>=n) return 0;
  
  return (search(n, A, i + 1, m) || search(n, A, i + 1, m - A[i]));
}


extern void solve(int n,int A[],int q,int M[]){
  int i;
  for(i=0;i<q;i++){
    if(search(n,A,0,M[i])==1)
      printf("yes\n");
    else
      printf("no\n");
  }
  }

int main(){
  int n,*M,i,q;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
   M=(int*)malloc(sizeof(q));
 for(i=0;i<q;i++){
    scanf("%d",&M[i]);
  }

  solve(n,A,q,M);
 
 return 0;
}



Measured memory_bytes: 2104
function Main(input) {
	tmp = input.split(" ");
	
	var a = parseInt(tmp[0]);
	var b = parseInt(tmp[1]);
	var c = parseInt(tmp[2]);
	
	if(c>a && c<b || c<a && c>b){
		console.log("Yes");
	}else{
		console.log("No");
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22080
n = int(input())
l = []
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        l.append(1)
    else:
        l.append(0)
cur = 0
ans = 0
for i in range(n):
    if l[i] == 1:
        cur += 1
    else:
        ans = max(ans, cur)
        cur = 0
ans = max(ans, cur)
print("Yes" if ans >= 3 else "No")

Measured memory_bytes: 9196
X = input().split()
formulas = []
formulas.append(''.join(X[0]+X[1]+"+"+X[2]))
formulas.append(''.join(X[1]+X[2]+"+"+X[0]))
formulas.append(''.join(X[2]+X[0]+"+"+X[1]))
print(max([eval(x) for x in formulas]))

Measured memory_bytes: 3188
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

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

        int N = sc.nextInt();
        long A = sc.nextLong();
        long B = sc.nextLong();
        int[] X = new int[N];

        for(int i=0; i<N; i++){
            X[i] = sc.nextInt();
        }
        long ans = 0;
        for(int i=1; i<N; i++){
            if((X[i]-X[i-1])*A<=B){
                ans += (X[i] - X[i - 1]) * A;
            }
            else{
                ans += B;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50940
#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 r;
    cin>>r;
    double a=3.141592;
    cout<<fixed<<setprecision(3)<<(double)r*2*a<<endl;
}


Measured memory_bytes: 3788
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
s = input()
#開業されたN個要素を受け付ける
#list = [input() for i in range(N)]

print(s[0]+str(len(s)-2)+s[-1])


Measured memory_bytes: 38384
import bisect
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = float("inf")
for i in range(N - K + 1):
    l = x[i]
    r = x[i + K - 1]
    ans = min(ans,min(abs(r)+abs(r-l),abs(l)+abs(l-r)))
print(ans)

Measured memory_bytes: 14480
#include<bits/stdc++.h>
#define ll   long long int   
#define pb push_back
using namespace std;
const int M=1e9 + 7;

int main()
{   
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int r;cin>>r;
    ll ans=3*r*r;
    cout<<ans<<endl;
	return 0;
}
 
 
 
 
 
 
 
 
 

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> ans(n);
    for(int i=0;i<n;i++){
        ans.at(i)=0;
    }
    int a,b;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        ans.at(a-1)++;
        ans.at(b-1)++;
    }
    for(int i=0;i<n;i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin

def main():

    input = stdin.readline

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

    ans = 0

    ans += comb(N,2)
    ans += comb(M,2)

    print(ans)


def comb(n,k):
    min_k = min(k,n-k)

    if n < 2:
        return 0

    n_kaijyo = 1
    k_kaijyo = 1
    for i in range(min_k):
        n_kaijyo = n_kaijyo * (n - i)
        k_kaijyo = k_kaijyo * (i + 1)

    result = int(n_kaijyo / k_kaijyo)
    return result
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;
		
const int INF = INT_MAX / 3;
int N, M, L, K, S, G;
vector<vector<int>> d;

void warshall_floyd() {
	for(int k = 0; k < N; ++k)
		for(int i = 0; i < N; ++i)
			for(int j = 0; j < N; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	return;
}

int main() {
	while(cin >> N >> M >> L >> K >> S >> G && N) {
		d.assign(N,vector<int>(N, INF));
		vector<bool> isFreezing(N, false);
		
		int idx;
		isFreezing[S] = true;
		isFreezing[G] = true;
		for(int i = 0; i < L; ++i) {
			cin >> idx;		
			isFreezing[idx] = true;
		}

		int from, to, distance;
		for(int i = 0; i < K; ++i) {
			cin >> from >> to >> distance;
			d[from][to] = distance;
			d[to][from] = distance;
		}
	
		// ???????????????????????????????????¢????±??????? 
		warshall_floyd();

		// ????§????????????????????????? 
		for(int i = 0; i < N; ++i) {
			for(int j = 0; j < N; ++j) {
				if(!isFreezing[i] || !isFreezing[j]) { //??????????¨??????§???????????´??????????????????
					d[i][j] = INF;
				}
				if(d[i][j] > M) { // ??????????¨????????????¢?????¶?????????(M)??\?????????????????????
					d[i][j] = INF;
				}
			}
		}
		
		// ??????????¨???????????????????????±???????
		warshall_floyd();

		// ????¶?????????¶??????????????£????????????????????????
		if(d[S][G] == INF) {
			cout << "Help!" << endl;
		} else {
			int loss_time = 0;
			if(d[S][G] > M) loss_time = d[S][G] - M;
			cout << d[S][G] + loss_time << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1268
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};




int main(){
  string S;
  cin >> S;
  set<char> s;
  bool l = 1;
  rep(i, S.size()){
    if(s.count(S[i])){
      l = 0;
    }else{
      s.insert(S[i]);
    }
  }
  if(l){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
}


Measured memory_bytes: 256
N,K = list(map(int, input().split()))
costs = list(map(int, input().split()))

dp = [0]*N

dp[0] = 0

for j in range(1,N,1):
  dev_costs = []
  k = 1
  while j-k >= 0:
    dev_cost = dp[j-k] + abs(costs[j]-costs[j-k])
    dev_costs.append(dev_cost)
    if k ==  K:
      break
    k += 1
    
  dp[j] = min(dev_costs)
    
print(dp[-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int dp[1010][20010];
int inf = 1e9;
int main(){
    rep(i,1010){
        rep(j,20010){
            dp[i][j] = inf; 
        }
    }
    dp[0][0] = 0;
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n); 
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,n){
        rep(j,20010){

            if(j+a[i]<20010){
                dp[i][j + a[i]] = min(dp[i][j + a[i]], dp[i][j] + b[i]);
            }
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    int ans = inf;
    for(int i = h;i<20010;i++){
        ans = min(ans,dp[n-1][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79232
while True:
    h, w = map(int, input().split())
    if h==0 and w==0:
        break
    for i in range(w):
        print('#', end='')
    print('')
    for j in range(h-2):
        print('#', end='')
        for i in range(w-2):
            print('.', end='')
        print('#')
    for i in range(w):
        print('#', end='')
    print('')
    print('')



Measured memory_bytes: 6996