akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
//#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back

int n;
vector<int>l;
void solve()
{
    cin>>n;
    l.resize(n);
    forn(i, n) cin>>l[i];
    sort(l.begin(), l.end());
    int r =0 ;
    forn(i, sz(l)) forn(j, i) forn(k, j)
    {
        if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
        if (l[i] < l[j] + l[k]) 
        {
            ++r;
        }
    }
    cout << r<<'\n';
}

signed main(void)
{
    int T = 1;
    cout << fixed;
    cout.precision(3);
    ios_base::sync_with_stdio(0); cin.tie(0);

    //cin>>T;
    while (T--) solve();
    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int>cnt(m);
  for(int i=0; i<n; i++){
    int k;
    cin >> k;
    for(int j=0; j<k; j++){
      int a;
      cin >> a;
      cnt[a-1]++;
    }
  }
  int ret=0;
  for(int i=0; i<m; i++){
    if(cnt[i]==n)ret++;
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    while(1){
        
        int i, num, sum=0;
        char number[1001];
        
        scanf("%s", number);
        if(number[0]=='0') break;
        
        for(i=0; number[i]!='\0'; i++){
            num = number[i] - '0';
            sum += num;
        }
        printf("%d\n", sum);
    }
    
    return 0;
}

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

int main() {
	int n;cin>>n;
	vector<pair<string,int>> vp(n);
	for(int i=0;i<n;++i){
		string s;
		int t;
		cin >>s>>t;
		vp[n-1-i] = make_pair(s,t);
	}
	string x;cin>>x;
	int out = 0;
	for(int i=0;i<n;++i){
		if(vp[i].first!=x){
			out += vp[i].second;
		} else {
			break;
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include <utility>
#include<vector>
using namespace std;

typedef pair<long long int, long long int> ui;
ui uil[333333];
long long int n;
long long int res=0;
long long int s,h,e;


bool cha(long long int nn){
  long long int sine;
  long long int tamp;
  ui temp,tempp;
  long long int ho=0;
  long long int kmin=100009;
  //  priority_queue<ui,vector<ui>,greater<ui> >q;
  priority_queue<ui,vector<ui>,greater<ui> >tq;
  //  for(long long int i=0;i<n;i++) q.push(uil[i]);

  for(sine=0;sine<nn;sine++){
    temp=uil[sine];
    temp.second*=-1;
    ho+=temp.first;
    if(temp.second<kmin)kmin=temp.second;

    tamp=temp.first;
    temp.first=temp.second;
    temp.second=tamp;

    temp.second*=-1;
    tq.push(temp);
  }

  for(;sine<n;sine++){
    if(!(ho>kmin*nn))return true;

    temp=tq.top();
    tq.pop();
    ho-=temp.second*-1;

    temp=uil[sine];
    temp.second*=-1;
    ho+=temp.first;

    tamp=temp.first;
    temp.first=temp.second;
    temp.second=tamp;

    temp.second*=-1;
    tq.push(temp);

    temp=tq.top();
    kmin=temp.first;
  }
  if(!(ho>kmin*nn))return true;
  return false;
}


int main(void){
  scanf("%d",&n);
  for(long long int i=0;i<n;i++){
    scanf("%d %d",&uil[i].first,&uil[i].second);
    uil[i].second*=-1;
  }
  sort(uil,uil+n); 
  s=1;
  e=n;
  while(s<=e){
    h=(s+e)/2;
    if(cha(h)){
      res=(res<h)?h:res;
      s=h+1;
    }
    else{
      e=h-1;
    }
  }
  printf("%d\n",res);
}

Measured memory_bytes: 0
data = input().split(" ")
x = int(data[0])
y = int(data[1])
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
if x in g1 and y in g1:
	print("Yes")
elif x in g2 and y in g2:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut dv = vec![0i64; n];
    for i in 0..n - 1 {
        dv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    dv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            ans += dv[i] * dv[j];
        }
    }
    println!("{}", ans);
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  set<int> s;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &v[i]);
  }
  for (int i = 0; i < N; ++i) {
    if (s.count(v[i]) == 0) {
      s.insert(v[i]);
    }
    else {
      s.erase(v[i]);
    }
  }
  int ans = s.size();
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 5248
#include <cstdio>
#include <vector>
#include <utility>

int main() {
  int a[5] = {};
  for (int i = 0; i < 6; ++i) {
    int j;
    scanf("%d", &j);
    ++a[j];
    if (a[j] >= 3)
      return !printf("NO\n");
  }

  puts("YES");
}


Measured memory_bytes: 128
#include<cstdio>

#include<iostream>

using namespace std;

const int N=2e5+5,mod=1e9+7;

typedef long long ll;

int n,f[N];

char s[N];

int main()

{

    scanf("%d",&n);

    scanf("%s",s+1);

    for(int i=2;i<=2*n;i++)

    {

       if(s[i]==s[i-1])

            f[i]=f[i-1]^1;

       else f[i]=f[i-1];

    }

    bool flag=true;

    ll ans=1;

    int t=0;

    for(int i=1;i<=2*n;i++)

    {

        if(f[i]==0)

            t++;

        else 

        {

            if(!t) flag=false;

            ans=ans*t%mod;t--;

        }

        if(t==1&&f[i]==0&&s[i]=='W')

            flag=false;

    }

    if(t) flag=false;

    for(int i=1;i<=n;i++)

        ans=ans*i%mod;

    if(!flag) ans=0;

    printf("%lld",ans);

}

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

int main() {
	string S; cin >> S;
	int a=0, b=0;
	for(int i=0; i<S.size(); ++i){
	    if(S[i]=='0') ++a;
	    else ++b;
	}
	cout << min(a, b)*2 << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<long long> a(n + 1), b(n);
	for (int i = 0; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	long long gekiha;
	long long gekiha2;
	long long ans = 0;

	for (int i = 0; i < n; i++) {
		gekiha = min(a[i], b[i]);
		gekiha2 = min(a[i + 1], b[i] - gekiha);
		a[i + 1] = a[i + 1] - gekiha2;
		ans += gekiha + gekiha2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp;
use std::io;

fn main() {
    let input = input_number();
    let n = input[0] as usize;
    let k = input[1] as usize;
    let his = input_number();
    let mut dp = vec![i64::max_value(); n];

    dp[0] = 0;
    for i in 0..n {
        for j in 1..k + 1 {
            if i + j >= n {
                continue;
            }
            dp[i + j] = cmp::min(dp[i + j], dp[i] + (his[i] - his[i + j]).abs());
        }
    }

    println!("{}", dp.last().unwrap());
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (char, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: char = iter.next().unwrap().chars().nth(0).unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    (c, n)
}


Measured memory_bytes: 6396
#include <set>
#include <string>
#include <iostream>

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::set<std::string> dic;
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        std::string command, str;
        std::cin >> command >> str;
        if(command[0] == 'i'){
            dic.insert(str);
        }else
        if(command[0] == 'f'){
            std::cout << (dic.find(str) != dic.end() ? "yes" : "no") << std::endl;
        }
    }
    return 0;
 }

Measured memory_bytes: 29044
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(){
  ll n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  if('a' < s[k-1] && s[k-1] < 'b'){
    s[k-1] -= 32;
  }else{
    s[k-1] += 32;
  }
  cout << s;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if(abs(a-b)%2==0) printf("Alice");
    else printf("Borys");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int N;
ll a[400];
ll dp[401][401];
ll ac[401];
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N) ac[i+1] = ac[i] + a[i];
	for(int len=2;len<=N;len++){
		rep(l,N-len+1){
			int r = l+len;
			dp[l][r] = 1e18;
			for(int m=l+1;m<r;m++){
				chmin(dp[l][r],dp[l][m]+dp[m][r]+ac[r]-ac[l]);
			}
		}
	}
	cout<<dp[0][N]<<endl;
}

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

int a, b, c, x, y;
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> a >> b >> c >> x >> y;
	if (2 * c >= (a + b))
		return cout << x * a + y * b,0;
	int res = min(x, y) * 2 * c;
	if (x < y) {
		if (2 * c < b) {
			res += (y - min(x, y)) * 2 * c;
		}
		else
			res += (y - min(x, y)) * b;
	}
	else {
		if (2 * c < a) {
			res += (x - min(x, y)) * 2 * c;
		}
		else
			res += (x - min(x, y)) * a;
	}
	cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[100009],f[100009];
main()
{
    p[1]=1;

    for (int i=2; i<=100000; i++)
    {
        for (int j=2*i; j<=100000; j+=i)
            p[j]=1;
    }
    p[2]=0;
    for (int i=1; i<=100000; i++)
    {
        if(p[i]==0 && p[(i+1)/2]==0 && i!=2)
            {
                f[i]=f[i-1]+1;
            }
        else f[i]=f[i-1];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<f[r]-f[l-1]<<endl;
    }
}

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

#define LL long long

using namespace std;

int main(void){

    int N, red = 0, blue = 0;

    cin >> N;

    for (int i = 0; i < N; i++){
        char tmp;
        cin >> tmp;
        if(tmp == 'R'){
            red++;
        }else{
            blue++;
        }
    }

    if(red > blue){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
    string t;
    cin >> t;
    for(int i = 1; i < t.size(); i++) {
        if(t.at(i) == '?') {
            if(t.at(i-1) ==  'P') t.at(i) = 'D';
            else t.at(i) = 'D';
        }
    }
    if(t.at(0) == '?') t.at(0) = 'D';
    cout << t << endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int ans1 = 100 * a, ans2 = 0;
    double md = 0;
    for(int i = 0; 100 * a * i <= f; i++)
    {
        for(int j = 0; 100 * (a * i + b * j) <= f; j++)
        {
            if(i == 0 && j == 0) continue;
            int water = 100 * (a * i + b * j);
            for(int k = 0; c * k <= f - water; k++)
            {
                for(int l = 0; d * l <= f - water - c * k; l++)
                {
                    int sugar = c * k + d * l;
                    if((double)sugar / water > (double)e / 100) continue;
                    if((double)sugar / (water + sugar) > md)
                    {
                        ans1 = water + sugar;
                        ans2 = sugar;
                        md = (double)sugar / (water + sugar);
                    }
                }
            }
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}



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

main(){
 vector<int> x(3);
  for(int i=0;i<3;i++){
    cin>> x[i];
  }
  sort(x.begin(), x.end());
  cout<< x[0]+x[1]<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String[] args) {
		//宣言
		int n=0;
		int x[]= new int[300];
		int j;
		sc = new Scanner(System.in);
		int min;
		int count=0;
		//入力
		n= sc.nextInt();
		for(int i=0;i<n;i++) {
			x[i]=sc.nextInt();
		}
		//出力
		/*for(int i=0;i<n;i++) {
			System.out.print(x[i]+" ");
		}
		System.out.print("\n");
		*/
		for(int i=0;i<n;i++) {
			min=i;
			for(j=i;j<n;j++) {
				if(x[min]>x[j]) {
					min=j;
				}
			}
			if(min!=i) {//minが変化したらカウント
				int w = x[min];
				x[min]=x[i];
				x[i]=w;
				count++;
			}
		}
		for(int i=0;i<n;i++) {
			if(i>=0 &&i<n-1) {
				System.out.print(x[i]+" ");
			}else if(i==n-1) {
				System.out.println(x[i]);
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26392
#include<stdio.h>

int main(void){
    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        d=b;
        b=a;
        a=d;
    }if(b>c){
        d=c;
        c=b;
        b=d;
    }if(a>b){
        d=a;
        a=b;
        b=d;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
n = int(input())
s_array = [input() for x in range(n)]
last_a = 0
reversible = 0
start_b = 0
flag = False
for s in s_array:
    if s[-1] == "A" and s[0] != "B":
        last_a += 1
    elif s[0] == "B" and s[-1] != "A":
        start_b += 1
    elif s[0] == "B" and s[-1] == "A":
        reversible += 1
    else:
        flag = True
res = 0
for s in s_array:
    res += s.count("AB")

if start_b > last_a or flag:
    tmp = 0
else:
    tmp = 1

if n == 1:
    print(res)
elif reversible == 0:
    print(res + min(last_a, start_b))
elif last_a == 0 and start_b == 0:
    print(res + reversible - 1)
elif last_a == 0 or start_b == 0:
    print(res + min(last_a, start_b) + reversible)
else:
    print(res + min(last_a, start_b) + reversible)

# a = []
# b = []
# other = []
# for s in s_array:
#     if s[0] == "B":
#         b.append(s)
#     elif s[-1] == "A":
#         a.append(s)
#     else:
#         other.append(s)
# res = ""
# print(a, b, other)
# for i in a:
#     res += i
#     for j in b:
#         res += j
#         continue
# for i in other:
#     res += i
# a_flag = False
# cnt = 0
# print(res)
# for i in res:
#     if i == "B" and a_flag:
#         cnt += 1
#     if i == "A":
#         a_flag = True
#     else:
#         a_flag = False
# print(cnt)


Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N,D1[101], D2[101];
	cin >> N;
	long long count = 0;
	bool flag = false;

	for (long long i = 0; i < N; i++)
	{
		cin >> D1[i];
		cin >> D2[i];
		if (D1[i] == D2[i])
		{
			count++;
			if (count >= 3)
			{
				flag = true;
			}
		}
		else
		{
			count = 0;
		}
	}

	string s;
	//cin >> s;

	//int A[5]
	//sort(A, A + 5);

	if (flag == true)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 3624
# coding: utf-8

S = input()

res = 0
now_mojisu = 0
agct = ["A", "C", "G", "T"]

for i in S:
    if i in agct:
        now_mojisu += 1
    else:
        now_mojisu = 0
    res = max(res, now_mojisu)

print(res)


Measured memory_bytes: 9020
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			
			String [] S = new String[N];
			Map<String,Long>map = new HashMap<String,Long>();
			for(int i = 0;i<N;i++) {
				S[i] = scan.next();
				char a = S[i].charAt(0);
				
				if(a=='M'||a=='A'||a=='R'||a=='C'||a=='H') {
					if(map.containsKey(S[i].substring(0, 1))){
						map.put(S[i].substring(0, 1), map.get(S[i].substring(0, 1))+1);
						}else {
							map.put(S[i].substring(0, 1), (long)1);
						}
				}
			}
			
			long []shu = new long[map.size()];
			ArrayList<Long>as = new ArrayList<Long>(map.values());
			int k = 0;
			for(String key:map.keySet()) {
				shu[k] = map.get(key);
				k++;
			}
			
			long goukei = 0;
			
			if(map.size()<3) {
				System.out.println(0);
				
			}else{
				
				for(int i = 0;i<map.size()-2;i++) {
					for(int j = i+1;j<map.size()-1;j++) {
						for(int z=j+1;z<map.size();z++) {
							
							goukei+=as.get(i)*as.get(j)*as.get(z);
							//System.out.println(shu[i]*shu[j]*shu[z]);
						}
					}
				}
				
				System.out.println(goukei);
				
			}
			
			
			
				
			
		}
		
		
	}
		

}


Measured memory_bytes: 51492
#include "iostream"
#include "string"
#include "vector"

using namespace std;

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = 0;
ll a = 0, b = 0, c = 0, n = 0, sum = 0;
ll A[500000] = {}, B[500000] = {}, ruiseki[500000] = {}, dp[100][10] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = false, check2 = false;

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;
}

int main() {
	
	//Code Line
	cin >> n;
	for (int i = 0; i < n; i++)cin >> A[i];
	for (int i = 0; i < n-1
		; i++) {
		if (A[i + 1] <= A[i])sum++;
		if (sum > Min) {
			Min = sum;
		}
		if (A[i + 1] > A[i])sum = 0;
	}
	cout << Min << endl;

	return 0;
}




Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    cin>>N;
    vector<int> h(N);
    rep(i,N) cin>>h[i];
    vector<int> dp(N,1e9);
    dp[0]=0;
    for(int i=1; i<N; i++){
        if(i==1){
            dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i]);
            continue;
        }
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),min(dp[i-2]+abs(h[i-2]-h[i]),dp[i]));
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[60][60];
int dp[52][52][52][52];
int v[52][52][52][52];
int r[600];
int w[600];
int sz;
int H,W;
int solve(int a,int b,int c,int d){
	if(a>c||b>d)return 0;
	if(a<0||b<0||c>=H||d>=W)return 0;
	if(str[a][b]=='#'||str[c][d]=='#')return 0;
	if(~dp[a][b][c][d])return dp[a][b][c][d];
	if(!v[a][b][c][d])return 0;
	if(a==c&&b==d)return dp[a][b][c][d]=0;
	int ret=0;
	if('a'<=str[a][b]&&str[a][b]<='z'&&str[a][b]-32==str[c][d]){
	//	printf("%c %c\n",str[a][b],str[c][d]);
		if(v[a][b][c][d])ret=1;
		for(int i=0;i<sz;i++){
			for(int j=0;j<sz;j++){
				if(i==j)continue;
				if(v[a][b][r[i]][w[i]]&&(a!=r[i]||b!=w[i])&&
				v[r[j]][w[j]][c][d]&&(c!=r[j]||d!=w[j])&&v[r[i]][w[i]][r[j]][w[j]]){
			//		if(solve(r[i],w[i],r[j],w[j])+1==3)printf("%d %d %d %d: %d %d %d %d\n",a,b,c,d,r[i],w[i],r[j],w[j]);
					ret=max(ret,solve(r[i],w[i],r[j],w[j])+1);
				}
			}
		}
	}
	for(int i=0;i<sz;i++){
		if(v[a][b][r[i]][w[i]]&&(a!=r[i]||b!=w[i])){
				ret=max(ret,solve(r[i],w[i],c,d));
		}
		if(v[r[i]][w[i]][c][d]&&(c!=r[i]||d!=w[i])){
			ret=max(ret,solve(a,b,r[i],w[i]));
		}
	}
	for(int i=0;i<sz;i++){
		if(v[a][b][r[i]][w[i]]&&v[r[i]][w[i]][c][d]&&(a!=r[i]||b!=w[i])&&(c!=r[i]||d!=w[i])){
			ret=max(ret,solve(a,b,r[i],w[i])+solve(r[i],w[i]+1,c,d));
			ret=max(ret,solve(a,b,r[i],w[i])+solve(r[i]+1,w[i],c,d));
		}
	}
//	if(ret>1)printf("%d %d %d %d: %d\n",a,b,c,d,ret);
	return dp[a][b][c][d]=ret;
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		H=a;W=b;
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)
			for(int k=0;k<a;k++)for(int l=0;l<b;l++){
				dp[i][j][k][l]=-1;
				v[i][j][k][l]=0;
			}
		sz=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if(str[i][j]!='.'&&str[i][j]!='#'){
					r[sz]=i;w[sz++]=j;
				}
			}
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]=='#')continue;
			v[i][j][i][j]=1;
			for(int k=0;k<a;k++)for(int l=0;l<b;l++){
				if(str[k][l]=='#')continue;
				if(k&&v[i][j][k-1][l])v[i][j][k][l]=1;
				if(l&&v[i][j][k][l-1])v[i][j][k][l]=1;
			}
		}
		int ret=solve(0,0,a-1,b-1);
		if(!v[0][0][a-1][b-1])printf("-1\n");
		else printf("%d\n",ret);
	}
}

Measured memory_bytes: 56988
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef priority_queue<int,vector<int>,greater<int> > Q;

int p;
string s;
map<string,Q> m;

int main(){
	while(cin>>s>>p){
		m[s].push(p);
	}
	map<string,Q>::iterator ite;
	for(ite=m.begin();ite!=m.end();ite++){
		cout<<ite->first<<endl;
		Q q=ite->second;
		bool f=0;
		while(!q.empty()){
			p=q.top();q.pop();
			if(f)cout<<" ";
			cout<<p;
			f=1;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 0
D = {}
q = int(input())
for i in range(q):
    L = input().split()
    if L[0] == '0':
        key, x = L[1], L[2]
        D[key] = x
    elif L[0] == '1':
        key = L[1]
        if key in D.keys():
            print(D[key])
        else:
            print(0)
    else:
        key = L[1]
        if key in D.keys():
            del D[key]



Measured memory_bytes: 41628
from functools import reduce
n, m = map(int, input().split())
s = [[int(e) for e in input().split()[1:]] for _ in range(m)]
p = [int(e) for e in input().split()]
t = [reduce(lambda x, y: x | (1 << (y - 1)), e, 0) for e in s]
result = 0
for i in range(2 ** n):
  for j in range(m):
    if (bin(i & t[j]).count('1') & 1) != p[j]:
      break
  else:
    result += 1
print(result)


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


using namespace std;

bool graph[8][8];

int dfs(int v, int N, bool visited[8]) {
  bool all_visited = true;
  for (int i = 0; i < N; i++) {
    if (visited[i] == false) {
      all_visited = false;
    }
  }

  if (all_visited) {
    return 1;
  }

  int ret = 0;

  for (int i = 0; i < N; i++) {
    if (graph[v][i] == false)
      continue;
    if (visited[i])
      continue;
    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }
  return ret;
}

int main() {
  int N, M;
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
  }

  bool visited[8];
  for (int i = 0; i < N; i++) {
    visited[i] = false;
  }

  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
  
}

Measured memory_bytes: 3544
N = int(input())
D = list(map(int, input().split()))
max_D = max(D)

tree_list = [0] * (max_D+1)
for idx, d in enumerate(D):
    tree_list[d] += 1
count = 1
for idx, tree in enumerate(tree_list):
    if idx == 0:
        count *= 1
    else:
        if tree == 0:
            count = 0
        else:
            count *= tree_list[idx - 1]**tree

if tree_list[0] != 1 or D[0] != 0:
    print(0)
    quit()
else:
    print(int(count%998244353))

Measured memory_bytes: 14020
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  bool ok = false;
  for(int i=1;i<1000;i++){
    if(1<=b && b<=9){
      if(10*a+b==i*i){
        ok = true;
      }
    }
    if(10<=b && b<=99){
      if(100*a+b==i*i){
        ok = true;
      }
    }
    if(b==100){
      if(1000*a+b==i*i){
        ok = true;
      }
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == n) {
        cout << "Yes" << '\n';
        return 0;
      }
    }
  }
  cout << "No" << '\n';
  return 0;
}

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

var pw = PrintWriter(System.out)
const val YES = "Yes"
const val NO = "No"
fun solve(a: Long, b: Long, c: Long, d: Long){
    if (Math.abs(a - c) <= d){ println(YES) }
    else if(Math.abs(a-b) <= d && Math.abs(b-c) <= d){ println(YES) }
    else{ println(NO) }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val a = sc.next().toLong()
    val b = sc.next().toLong()
    val c = sc.next().toLong()
    val d = sc.next().toLong()
    solve(a, b, c, d)
}



Measured memory_bytes: 31512
N, A, B, C = list(map(int, input().split()))
L = [int(input()) for _ in range(N)]

from itertools import permutations, combinations


def dellist(items, contents):
    items = items.copy()
    for rm in contents:
        # print(rm)
        items.remove(rm)
    return items


ans = []
L_temp = L.copy()

for n_g1 in range(1, N):
    for n_g2 in range(1, N - n_g1+1):
        for n_g3 in range(1, N - n_g1 - n_g2 + 1):
            # print(n_g1, n_g2, n_g3)
            L_temp = L.copy()
            for G1 in combinations(L_temp, n_g1):
                L_temp = L.copy()
                L_temp = dellist(L_temp, G1)
                # print('G1', L_temp)
                for G2 in combinations(L_temp, n_g2):
                    L_temp = L.copy()
                    L_temp = dellist(L_temp, G1)
                    L_temp = dellist(L_temp, G2)
                    # print('G2', L_temp)
                    for G3 in combinations(L_temp, n_g3):
                        # print('G3', L_temp)
                        s1, s2, s3 = sum(G1), sum(G2), sum(G3)
                        syn = len(G1) + len(G2) + len(G3) - 3
                        ans.append(abs(s1 - A) + abs(s2 - B) +
                                   abs(s3 - C) + syn * 10)

# print(ans)
print(min(ans))


Measured memory_bytes: 5040
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


int n, a, b, c, t[10];

int dfs(int co, int cnt, int la, int lb, int lc) {
	if (cnt == n) {
		if (la&&lb&&lc) {
			return abs(la - a) + abs(lb - b) + abs(lc - c) + co;
		}
		return inf;
	}
	return min({ dfs(co + 10,cnt + 1,la + t[cnt],lb,lc),dfs(co + 10,cnt + 1,la,lb + t[cnt],lc),dfs(co + 10,cnt + 1,la,lb,lc + t[cnt]),dfs(co,cnt + 1,la,lb,lc) });
}
signed main() {
	cin >> n >> a >> b >> c;
	rep(i, n)cin >> t[i];
	cout << dfs(0, 0, 0, 0, 0) - 30 << endl;
	endre;
}


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

int main(){
	int N,T,A; cin>>N>>T>>A;
	int mini = INT_MAX;
	int ans = 0;
	for(int i=0; i<N; ++i){
		int x; cin>>x;
		int d = abs((T-A)*1000 - x*6);
		if(mini > d){
			mini = d;
			ans = i + 1;
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
ans=[]
for i in range(0,n-k+1):
  l=x[i]
  r=x[i+k-1]
  ans.append(min(abs(l)+abs(l-r),abs(r)+abs(l-r)))
print(min(ans))

Measured memory_bytes: 15020
n = int(input())
b  = list(map(int, input().split()))

can = True
for i in range(1, n +1):
  if b[i - 1] > i:
    can = False
    break

if can:
  result = []
  while(len(b)):
    for i in range(len(b), 0, -1):
      if i == b[i - 1]:
        result.insert(0, i)
        b.pop(i - 1)
        break
  for a in result:
    print(a)
else:
  print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cmath>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(int i = a; i < b; i++)
#define repj(a,b)for(int j = a; j < b; j++)
#define pii pair<int,int>

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


int main() {
	int n, l; cin >> n >> l;
	int sum = 0;
	repi(0, n)sum += l + i;
	if (l >= 0)cout << sum - l << endl;
	else if (l + n < 1)cout << sum - (l + n - 1) << endl;
	else cout << sum << 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++)
typedef long long ll;
struct edge{ll to,cost;};
typedef pair<ll,ll> P;
int V;
vector<edge> G[200001];
ll d[200001],INF=1e18;
int dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost) d[e.to]=d[v]+e.cost,que.push(P(d[e.to],e.to));
        }
    }
}
int main(){
    ll n,m,s,t,u[200001],v[200001],a[200001],b[200001];
    cin>>n>>m>>s>>t;
    rep(i,m) cin>>u[i]>>v[i]>>a[i]>>b[i];
    ll dy[200001],ds[200001];
    rep(i,m) G[u[i]-1].push_back({v[i]-1,a[i]}),G[v[i]-1].push_back({u[i]-1,a[i]});
    V=n;
    dijkstra(s-1);
    rep(i,V) dy[i]=d[i];
    rep(i,V) G[i].clear();
    rep(i,m) G[u[i]-1].push_back({v[i]-1,b[i]}),G[v[i]-1].push_back({u[i]-1,b[i]});
    dijkstra(t-1);
    rep(i,V) ds[i]=d[i];
    ll D[200001];
    rep(i,V) D[i]=dy[i]+ds[i];
    vector<P> A(V);
    rep(i,V) A[i]=P(D[i],i+1);
    sort(A.begin(),A.end());
    int x=0;
    rep(i,V){
        while(x<A[i].second){
            cout<<ll(1e15)-A[i].first<<endl;
            x++;
        }
    }
}

Measured memory_bytes: 24960
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	int n;
	cin >> n;
	Vi H(n);
	rep(i, n)  cin >> H[i];
	Vi dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		chmin(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]));
		if (i > 1)  chmin(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]));
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }

c = a.map.with_index{|t, i| t - (i+1) }
c.sort!

if n.odd?
  med = c[n/2]
else
  med = ( c[n/2] + c[n/2-1] ) / 2.0
end

puts c.reduce(0){|s, t| s + (t - med).abs }.round

Measured memory_bytes: 19072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    String S = sc.next();
	    sc.close();
	    
	    
	    int MM1= 0;
	    int MM2=0;
	   
	    
	    while (true){
	    	if (S.charAt(0)=='1'){
	    		if (S.charAt(1)=='0' || S.charAt(1)=='1' || S.charAt(1)=='2')
	    			MM1++;
	    		
	    	}	
	    	else if (S.charAt(0)=='0'){
	    		if (S.charAt(1)!='0')
	    			MM1++;
	    		
	    	}
	    	break;
	    }
	
	
	    while (true){
	    	if (S.charAt(2)=='1'){
	    		if (S.charAt(3)=='0' || S.charAt(3)=='1' || S.charAt(3)=='2')
	    			MM2++;
	    		
	    	}
	    	else if (S.charAt(2)=='0'){
	    		if (S.charAt(3)!='0')
	    				MM2++;
	    	}
	
	    	break;
	    }
	    

	    
		if (MM1==1 && MM2==1){
			System.out.println("AMBIGUOUS");
		}
		else if (MM1==1)
			System.out.println("MMYY");
		else if (MM2==1)
			System.out.println("YYMM");
		
		else
			System.out.println("NA");
	    
	}

}


Measured memory_bytes: 23124
import math
A, B = map(int,input().split())

UE_8 = math.ceil((A+1)/0.08)-1
SHITA_8 = A/0.08
UE_10 = math.ceil((B+1)/0.10)-1
SHITA_10 = B/0.10

if UE_8 < math.ceil(SHITA_10) or UE_10 < math.ceil(SHITA_8):
    print(-1)
else:
    i = math.ceil(SHITA_8)
    j = math.floor(UE_8)
    for n in range(int(i),int(j+1),1):
        if i < UE_10 and i >= SHITA_10:
            print(i)
            break
        i+=1

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

int main() {
  vector<int>vec(3);
  cin>>vec[0]>>vec[1]>>vec[2];
  sort(vec.begin(),vec.end());
  if(vec[0]==5&&vec[1]==5&&vec[2]==7)cout<<"YES";
  else cout<<"NO";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
t = 0
h = 0
for i in range(0,n):
    tW,hW, = raw_input().split()
    if tW >hW:
        t += 3
    elif tW == hW:
        t += 1
        h += 1
    else:
        h +=3
print t,h

Measured memory_bytes: 4220
#![allow(non_snake_case, unused)]
use std::collections::*;
use std::cmp::{min, max};

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! debug {
	($($v: expr),*) => {
		$(eprint!("{} = {:?} ", stringify!($v), $v);)*
		eprintln!("@ {}:{}", file!(), line!());
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:ty),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let (ab, bc, ca) = read!(i64, i64, i64);
	println!("{}", ab * bc / 2)
}


Measured memory_bytes: 8572
def inpl(): return [int(i) for i in input().split()]
N, M = inpl()
mod = 10**9+7
fac = [1 for _ in range(N+3)]
for i in range(N+2):
    fac[i+1] = (i+1)*fac[i]%mod

if abs(N-M) > 1:
    print(0)
elif N == M:
    print(2*fac[N]*fac[M]%mod)
else:
    print(fac[N]*fac[M]%mod)

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

ll dfs(ll x, ll c) {
  c++;

  if (x <= 1)
    return c;

  ll t = dfs(x / 2, 0);
  return t + t + c;
}

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

  ll H;

  CIN(H);

  ll c = dfs(H, 0);

  COUT(c);

  return 0;
}


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

using namespace std;

using ll = long long;

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

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll sx, sy, gx, gy;
ll n;
vector<ll> x, y, r;

double f(ll i, ll j) {
  return max(0., hypot(x[i] - x[j], y[i] - y[j]) - r[i] - r[j]);
}

struct Value {
  ll i;
  double cost;
};

double bfs() {
  auto comp = [](Value v1, Value v2) {
    return v1.cost > v2.cost;
  };
  priority_queue<Value, vector<Value>, decltype(comp)> que(comp);
  vector<bool> fix(n, false);
  vector<Value> fix_value(n);
  que.push({0, 0});
  while (!que.empty()) {
    Value v = que.top();
    que.pop();

    if (fix[v.i]) continue;
    fix[v.i] = true;
    fix_value[v.i] = v;
    REP(j, n) {
      que.push({j, v.cost + f(v.i, j)});
    }
  }
  return fix_value[n - 1].cost;
}

int main() {
  cin >> sx >> sy >> gx >> gy;
  cin >> n;
  x = y = r = vector<ll>(n);
  REP(i, n) cin >> x[i] >> y[i] >> r[i];
  x.push_back(gx);
  y.push_back(gy);
  r.push_back(0);
  n++;
  x.insert(x.begin(), sx);
  y.insert(y.begin(), sy);
  r.insert(r.begin(), 0);
  n++;

  cout << setprecision(10) << bfs() << endl;
}


Measured memory_bytes: 19996
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0;
    int r = n - 1;
    int ans = 0;
    while(l < r){
        while(s[l] == 'R'){
            l++;
            if(l == r)break;
        }
        while(s[r] == 'W'){
            r--;
            if(l == r)break;
        }
        if(s[l] == 'W' && s[r] == 'R'){
            swap(s[l], s[r]);
            l++;
            r--;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#define L 2
#define U 3
#define R 0
#define D 1

using namespace std;
   
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
   
int cost[30][30];
bool wall[4][30][30];
bool visited[30][30];
int w, h;
   
int bfs(int sx, int sy, int gx, int gy) {
  fill(cost[0], cost[32], 0);
  fill(visited[0], visited[32], false);
  cost[0][0] = 1;
     
  queue<pair<int, int> > Q;
  Q.push(make_pair(0, 0));
  visited[0][0] = true;
  while(!Q.empty()) {
    pair<int, int> st = Q.front(); Q.pop();
       
    if(st.first == gx && st.second == gy) {
      return cost[gy][gx];
    }
       
    for(int i=0; i<4; i++) {
      int nx = st.first + dx[i];
	int ny = st.second + dy[i];
      if(0<= nx && nx < w && 0<= ny && ny < h) {
	if(!visited[ny][nx] && !wall[i][st.second][st.first]) {
	  visited[ny][nx] = true;
	  cost[ny][nx] = cost[st.second][st.first] + 1;
	  Q.push(make_pair(nx, ny));
	}
      }
    }
  }
  return 0;
}

int main(void) {
  while(cin >> w >> h && w+h) {
    fill(wall[0][0], wall[4][30], 0);
    
    for(int i=0; i<h; i++) {
      wall[R][i][0] = wall[L][i][w-1] = 1;
    }
    for(int i=0; i<w; i++) {
      wall[D][0][i] = wall[U][h-1][i] = 1;
    }
    
    for(int i=0; i<h; i++) {
      
      for(int j=0; j<w-1; j++) {
	cin >> wall[L][i][j];
	wall[R][i][j+1] = wall[L][i][j];
      }
      
      if(i < h-1) {
	for(int j=0; j<w; j++) {
	  cin >> wall[U][i][j];
	  wall[D][i+1][j] = wall[U][i][j];
	}
      }
    }
    cout << bfs(0, 0, w-1, h-1) << endl;
  }
   return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define MP make_pair
#define ull unsigned long long int
#define F first
#define S second
#define put insert
#define pb push_back
#define rsortV(arr) sort(arr.begin(),arr.end(),greater<int>())
#define sortV(arr) sort(arr.begin(),arr.end())
#define sortA(arr,n) sort(arr,arr+n)
#define rsortA(arr,n) sort(arr,arr+n,greater<int>())
#define arrInput(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define rev(arr) reverse(arr.begin(), arr.end())
#define all(x) (x).begin(), (x).end()
ll MOD = 1e9+7;
int main() {
    fastio
    // int t;
    // cin>>t;
    // while(t--) {
    int n,x,t;
    cin>>n>>x>>t;
    int upper = ceil((n*1.0)/x);
    cout<<upper*t;
    // }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;

using qul = queue<ll>;

int main() {
    ll H1, M1, H2, M2, K, ll, min1, min2;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    min1 = H1 * 60 + M1;
    min2 = H2 * 60 + M2;
    if(min2 > min1) {
        cout << min2 - min1 - K << endl;
    } else {
        if(3600 - min2 + min1 - K <= 0) {
            cout << 0 << endl;
        } else {
            cout << 3600 - min2 + min1 - K << endl;
        }
    }
}

Measured memory_bytes: 3624
#include<stdio.h>
int main() {
	int num, i;
	char number[1001];
	while (1) {
		num = 0;
		scanf("%s", number);
		if (number[0] == '0') {
			break;
		}
			for (i = 0;number[i]!='\0';i++) {
				num += number[i] - '0';
			}
			printf("%d\n", num);
	}
	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(b < 10)a = a * 10 + b;
    else if(b < 100)a = a * 100 + b;
    else  a = a * 1000 + b;
    if((int)sqrt(a) * (int)sqrt(a) == a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256