akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N;
int ma = 0;
int mi = 1000000001;
  cin >> N;
int A;
  
  for(int i = 0;i < N;i++){
  cin >> A;
    ma = max(ma, A);
    mi = min(mi, A); 
  }
 
  cout << ma - mi << endl;
  return 0;
 
}

Measured memory_bytes: 256
/*
B Frog2
刷表法 数轴模型 
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100200
int a[MAXN], dp[MAXN];
int n, k;
int main(){
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    memset(dp, 0x3F, sizeof dp);
    dp[1] = 0;
    for(int i = 1; i < n; i++)
        for(int j = 1; j <= k; j++)
            dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]));
    printf("%d\n", dp[n]);
} 

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  node *left,*right;
  node(){left=right=NULL;}
};
node* construct(string s,int l,int r){
  node* res=new node();
  int op=0,c=-1;
  for(int i=l+1;i<r-1;i++){
    if(s[i]=='(') op++;
    if(s[i]==')') op--;
    if(s[i]==','&&op==0){
      c=i;
      break;
    } 
  }
  if(l+1!=c)   res->left =construct(s,l+1,c);
  if(r-1!=c+1) res->right=construct(s,c+1,r-1);
  return res;
};
string inte(node* a,node* b){
  string l,r;
  if(a->left!=NULL&&b->left!=NULL)
    l=inte(a->left,b->left);
  if(a->right!=NULL&&b->right!=NULL)
    r=inte(a->right,b->right);
  return "("+l+","+r+")";
}
string unio(node* a,node* b){
  string l,r;
  if((a!=NULL&&a->left!=NULL)||(b!=NULL&&b->left!=NULL))
    l=unio((a!=NULL?a->left:a),(b!=NULL?b->left:b));
  if((a!=NULL&&a->right!=NULL)||(b!=NULL&&b->right!=NULL))
    r=unio((a!=NULL?a->right:a),(b!=NULL?b->right:b));
  return  "("+l+","+r+")";
}
signed main(){
  string c,s,t;
  while(cin>>c>>s>>t){
    node* a=construct(s,0,s.size());
    node* b=construct(t,0,t.size());
    if(c=="i") cout<<inte(a,b)<<endl;
    else if(c=="u") cout<<unio(a,b)<<endl;
    else assert(0);
  }
  return 0;
}

Measured memory_bytes: 3188
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let t: Vec<i64> = (0..n).map(|_| sc.read()).collect();
    let m: usize = sc.read();
    let px: Vec<(usize, i64)> = (0..m).map(|_| (sc.read(), sc.read())).collect();

    let sum: i64 = t.iter().sum();

    for &(p, x) in px.iter() {
        println!("{}", sum - t[p - 1] + x);
    }
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}


Measured memory_bytes: 4352
def inpl(): return list(map(int, input().split()))


H, W = inpl()

cost = [inpl() for _ in range(10)]

in_set = {1}
to_cost = [10**3 for i in range(10)]
to_cost[1] = 0
for _ in range(1, 10):
    bridge = {}
    for i in in_set:
        tmp_cost = 10 ** 4
        for j in range(10):
            if j in in_set or i == j:
                continue
            if cost[j][i] < tmp_cost:
                tmp_cost = cost[j][i]
                tmp_comer = j
        bridge[(i, tmp_comer)] = to_cost[i] + tmp_cost
    tt = min(bridge, key=bridge.get)
    to_cost[tt[1]] = bridge[tt]
    # print(tt, in_set, bridge)
    in_set.add(tt[1])

# print(to_cost)


ans = 0
for _ in range(H):
    ans += sum(to_cost[i] for i in inpl() if i != -1)
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int money = 100;
                for (int i = 0; i < n; i++){
                        double x = (double)money * 1.05;
                        money = (int)(Math.ceil(x));
                }
                System.out.println(money * 1000);
        }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for (auto& x : A) cin >> x;
	vector<pair<ll,int>> a;
	for (auto x : A) a.push_back({abs(x),x > 0 ? 0 : 1});
	sort(a.rbegin(), a.rend());
	int c = 0;
	{
		ll res = 1;
		for (int i = 0; i < K; ++ i) {
			if (a[i].second) ++ c;
			(res *= a[i].first) %= mod;
		}
		if (c % 2 == 0) {
			cout << res << endl;
			return 0;
		}
	}
	{
		vector<ll> a0, a1;
		for (int i = 0; i < K; ++ i) {
			if (a[i].second) {
				a1.push_back(a[i].first);
			} else {
				a0.push_back(a[i].first);
			}
		}
		ll v0 = -1, v1 = -1;
		for (int i = K; i < N; ++ i) {
			if (a[i].second) {
				if (v1 < 0) v1 = a[i].first;
			} else {
				if (v0 < 0) v0 = a[i].first;
			}
		}
		ll res0 = -1, res1 = -1;
		if (v0 >= 0 && a1.size() >= 1) {
			ll res = 1;
			for (auto x : a0) (res *= x) %= mod;
			for (unsigned i = 0; i+1 < a1.size(); ++ i) (res *= a1[i]) %= mod;
			(res *= v0) %= mod;
			res0 = res;
		}
		if (v1 >= 0 && a0.size() >= 1) {
			ll res = 1;
			for (auto x : a1) (res *= x) %= mod;
			for (unsigned i = 0; i+1 < a0.size(); ++ i) (res *= a0[i]) %= mod;
			(res *= v1) %= mod;
			res1 = res;
		}
		if (res0 >= 0 && res1 >= 0) {
			if (a0.back() * v0 >= a1.back() * v1) {
				cout << res0 << endl;
				return 0;
			} else {
				cout << res1 << endl;
				return 0;
			}
		} else if (res0 >= 0) {
			cout << res0 << endl;
			return 0;
		} else if (res1 >= 0) {
			cout << res1 << endl;
			return 0;
		}
	}
	reverse(a.begin(), a.end());
	{
		int c2 = 0;
		ll res = 1;
		for (int i = 0; i < K; ++ i) {
			if (a[i].second) ++ c2;
			(res *= a[i].first) %= mod;
		}
		if (c2 % 2 == 0) throw 1;
		cout << (mod-res) % mod << endl;
	}
}


Measured memory_bytes: 11396
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
typedef pair<int,int> P;

const ll INF=1e9;
const int MAX_N=1e5,MAX_X=1e9;

int N;
P Z[MAX_N*4];

vector<int> G[MAX_N*8],rG[MAX_N*8];

int st_size;
vector<int> vs;
int cmp[MAX_N*8];
bool used[MAX_N*8];

inline void add_edge(int from,int to){
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v){
	used[v]=true;
	REP(i,(int)G[v].size()){
		if (!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
	vs.push_back(v);
}

void rdfs(int v,int k){
	used[v]=true;
	cmp[v]=k;
	REP(i,(int)rG[v].size()){
		if (!used[rG[v][i]]){
			rdfs(rG[v][i],k);
		}
	}
}

inline int scc(){
	memset(used,0,sizeof(used));
	vs.clear();
	REP(i,st_size*3-1){
		if (!used[i]){
			dfs(i);
		}
	}
	memset(used,0,sizeof(used));
	int k=0;
	reverse(vs.begin(),vs.end());
	REP(i,(int)vs.size()){
		if (!used[vs[i]]){
			rdfs(vs[i],k++);
		}
	}
	return k;
}

void dfs(int lft,int rgh,int from,int a,int b,int k){
	if (b<=lft || rgh<=a){
		return;
	}
	if (lft<=a && b<=rgh){
		add_edge(from,k);
	}else{
		int m=(a+b)>>1;
		dfs(lft,rgh,from,a,m,k*2+1);
		dfs(lft,rgh,from,m,b,k*2+2);
	}
}

inline bool C(ll d){
	REP(v,st_size*3-1){
		G[v].clear();
		rG[v].clear();
	}
//	fprintf(stderr,"done\n");
	REP(v,st_size-1){
		add_edge(v,2*v+1);
		add_edge(v,2*v+2);
	}
	vector<int> vec(N,-1);
	REP(v,2*N){
		if (vec[Z[v].second]!=-1){
			add_edge(vec[Z[v].second]+st_size-1,v+st_size*2-1);
			add_edge(v+st_size-1,vec[Z[v].second]+st_size*2-1);
		}else{
			vec[Z[v].second]=v;
		}
	}
	REP(v,N*2){
		if (d>0){
			int lb,ub;
			lb=lower_bound(Z,Z+N*2,P(Z[v].first-d+1,-1))-Z;
			ub=lower_bound(Z,Z+N*2,P(Z[v].first+d,-1))-Z;
			dfs(lb,v,v+st_size*2-1,0,st_size,0);
			dfs(v+1,ub,v+st_size*2-1,0,st_size,0);
		}
	}
	scc();
	/*
	REP(v,st_size*3-1){
		if (d==10){
			fprintf(stderr,"vertex %d: ",v);
			REP(i,(int)G[v].size()){
				fprintf(stderr,"%d ",G[v][i]);
			}
			fprintf(stderr,"\n");
		}
	}
	*/
	REP(i,N*2){
		if (cmp[i+st_size-1]==cmp[i+st_size*2-1]){
			return false;
		}
	}
	return true;
}

int main(){
	scanf("%d",&N);
	REP(i,N){
		int x,y;
		scanf("%d %d",&x,&y);
		Z[i]=P(x,i);
		Z[i+N]=P(y,i);
	}
	sort(Z,Z+N*2);
	st_size=1;
	while(st_size<N*2){
		st_size<<=1;
	}
//	fprintf(stderr,"%d\n",st_size);
	FOR(i,N*2,st_size){
		Z[i]=P(INF,INF);
	}
	ll lb=0,ub=MAX_X;
	while(ub-lb>1){
		ll mid=(lb+ub)>>1;
		if (C(mid)){
			lb=mid;
		}else{
			ub=mid;
		}
	}
	printf("%lld\n",lb);
//	C(10);
	return 0;
}


Measured memory_bytes: 59768
package main

import "fmt"

func pow(b, n int) int {
	r := 1
	for n > 0 {
		r *= b
		n--
	}
	return r
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	// 確率Pで発生する事象が、発生するまでの回数の期待値は1/P
	// 全てのケースで正解する確率はP*M
	fmt.Println((M*1900 + (N-M)*100) * pow(2, M))

}


Measured memory_bytes: 512
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

a,b = inp
if(a<10 and b < 10)
  p a*b
else
  p -1
end

#!?

Measured memory_bytes: 3836
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b;
  char op;
  cin >> a >> op >> b;
  if(op=='+') cout << a+b<<endl;
  else cout << a-b<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
	class Program
	{
		static void Main(string[] args)
		{
			string n;

			n = Console.ReadLine();

			if (n[0] == '9' || n[1] == '9')
				Console.WriteLine("Yes");

			else
				Console.WriteLine("No");

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.Scanner;


//Verbal Arithmetic
public class Main{

	static int ans;
	static int[] assign;
	static char[][] s;
	static int n;
	static boolean[] used;
	
	static void dfs(int k, int m, int sum){
		if(k==s[n-1].length){
			if(sum==0){
				boolean f = true;
				for(int i=0;i<n;i++){
					if(assign[s[i][0]-'A']==0&&s[i].length > 1){
						f = false;
						break;
					}
				}
				if(f)ans++;
			}
			return;
		}
		int pos = s[m].length-1-k;
		if(pos < 0){
			dfs(k,m+1,sum);
			return;
		}
		int ch = s[m][pos]-'A';
		if(m==n-1){
			if(assign[ch]!=-1){
				if(assign[ch]==sum%10){
					dfs(k+1, 0, sum/10);
				}
			}
			else{
				int mod = sum%10;
				if(!used[mod]){
					if(mod==0&&pos==0&&s[m].length!=1)return;
					used[mod] = true;
					assign[ch] = mod;
					dfs(k+1, 0, sum/10);
					used[mod] = false;
					assign[ch] = -1;
				}
			}
			return;
		}
		if(assign[ch]!=-1){
			dfs(k, m+1, sum+assign[ch]);
			return;
		}
		for(int i=0;i<10;i++){
			if(!used[i]){
				if(i==0&&pos==0&&s[m].length!=1)continue;
				used[i] = true;
				assign[ch] = i;
				dfs(k, m+1, sum+i);
				used[i] = false;
				assign[ch] = -1;
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n==0)break;
			s = new char[n][];
			int upmax = 0;
			for(int i=0;i<n;i++){
				s[i]=sc.next().toCharArray();
				if(i<n-1)
					upmax = Math.max(upmax, s[i].length);
			}
			if(s[n-1].length < upmax){
				System.out.println(0);
				continue;
			}
			ans = 0;
			assign = new int[26];
			Arrays.fill(assign, -1);
			used = new boolean[10];
			dfs(0,0,0);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int n,k;
	ll s;
	cin>>n>>k>>s;
	for(int i=1; i<n; i++){
		if(i<=k)cout<<s<<" ";
		else if(s-1==0)cout<<s+1<<" ";
		else cout<<s-1<<" ";
	}
	if(n==k)cout<<s<<endl;
	else if(s-1==0)cout<<s+1<<endl;
	else cout<<s-1<<endl;
	return 0;
}


Measured memory_bytes: 1280
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        x: isize,
    }

    if x >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
    
    println!("", );
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2104
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        long[] a = r.ll();   
        println(xor(a[0], a[1]));
    }
    static long xor(long a, long b){
        long count;
        if(a%2 == 0){
            if(b%2 == 0){
                count = (b-a)/2;
                return count%2^b;                
            } else{
                count = (b-a+1)/2;
                return count%2;
            }
        } else{
            if(b%2 == 0){
                count = (b-a-1)/2;
                return count%2^a^b;
            } else{
                count = (b-a)/2;
                return count%2^a;
            }
        }
    }
    static void print(Object o){
        System.out.print(o.toString());   
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21076
using System;

namespace program
{
    class test
    {
        static void Main()
        {
            int sec = int.Parse(Console.ReadLine());
            int h = sec / 3600;
            int m = (sec - h * 3600) / 60;
            int s = sec  - m * 60 - h * 3600;
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}

Measured memory_bytes: 9236
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1], c = tmp[2], d = tmp[3];
    writeln(abs(a-c) <= d || max(abs(a-b), abs(b-c)) <= d ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,k;
    cin>>n>>k;
    set <lli> vis;
    lli x;
    vector <lli> arr;
    rep(i,n){
    	cin>>x;
    	arr.pb(x);
	}
	vis.insert(1);
	lli j=0;
	vector <lli> ans;
	ans.pb(1);
	while(vis.find(arr[j])==vis.end()){
		ans.pb(arr[j]);
		vis.insert(arr[j]);
		j=arr[j]-1;
	}
	lli len_c=0;
	lli len_p=0;
	rep(i,ans.size()){
		if(ans[i]==arr[j]){
			len_p=i;
			for(lli l=i;l<ans.size();l++){
				len_c++;
			}
			break;
		}
	}
	if(k<=len_p){
		cout<<ans[k];
	}
	else{
		k-=len_p;
		k%=len_c;
		cout<<ans[len_p+k];
	}
    return 0;
}


Measured memory_bytes: 15412
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main()
{
int n;
long long int a[200005];
long long int sum=0;
long long int ans=0;
int md=1000000007;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%lld",&a[i]);
sum+=a[i];
}
sum=sum%md;

for(int i=0;i<n-1;i++)
{
sum=sum-a[i];
sum=(sum+md)%md;
ans=ans+sum*a[i];
ans=ans%md;
}
printf("%lld",ans);

}

Measured memory_bytes: 5364
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int N;
void solve(int n, int a, string s){
	for(int i=0; i<=a; ++i){
		char ch='a'+i;
		if(n==N-1) cout << s+ch << endl;
		else solve(n+1, max(i+1, a), s+ch);
	}
}

int main() {
	cin >> N;
	solve(0, 0, "");
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=100000+10;
int n,a[maxn],b[maxn];
ll ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++){
		a[i]=lower_bound(b+1,b+n+1,a[i])-a;
		ans+=abs(a[i]-i)&1;
	}
	printf("%lld\n",ans>>1);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int N = 2000+10;
const int mod = 998244353;
int x[N],y[N];
ll f[N];
 
int cal(int i ,int j,int k)
{
    return (x[j] - x[i])*(y[k] - y[j]) == (y[j] - y[i])*(x[k] - x[j]);
}
int main()
{
    for(int i = 0;i < N;i++) f[i] = i == 0?1:(f[i-1]<<1)%mod;
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n ;i++)
        scanf("%d%d",&x[i],&y[i]);
    ll ans = f[n] - n - 1;
    for(int i = 1;i <= n;i++)
        for(int j = i+1;j <= n;j++)
        {
            int tot = 0;
            for(int k = j+1;k <= n;k++)
                if(cal(i,j,k))  tot++; // 共线
            ans = (ans - f[tot] + mod )%mod;
        }
    printf("%lld\n",ans);
    return 0;
}

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

int N, Q;
vector<int> edges[200000];
int64_t num[200000];

void dfs(int i, int p){
    for(int j : edges[i]) if(j != p){
        num[j] += num[i];
        dfs(j, i);
    }
}

int main(){
    cin >> N >> Q;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    for(int i=0; i<Q; i++){
        int p, x;
        cin >> p >> x;
        num[p-1] += x;
    }
    dfs(0, -1);
    for(int i=0; i<N; i++) cout << num[i] << " ";
    return 0;
}

Measured memory_bytes: 24320
N,K,*A=`dd`.split.map &:to_i
i=A.index(1)
puts (i-K+1..i).map{|j|
    L=[(j+(K-1)-1)/(K-1), 0].max
    R=[(N-(j+K)+(K-1)-1)/(K-1), 0].max
    L+R+1
}.min

Measured memory_bytes: 15296
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    ll w,h;
    IN w>>h;
    if(w==1 || h==1)
    {
        OUT 1<<endl
        return 0;
    }
    ll ans= (h*w)/2;
    if((h*w)%2)
    {
        ans++;
    }
    OUT ans<<endl
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool check(int a)
{
    for (int x = 1; 2 * (x * x + x) <= a; x++)
        if ((a - x) % (2 * x + 1) == 0) 
            return true;

    return false;
}

int main()
{
    int n, ans;

    cin >> n;
    ans = 0;
    while (n--) {
        int area;

        cin >> area;
        if (!check(area)) 
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1160
import sys
# sys.stdin = open('input.txt')

def print_board(board):
    for i in range(n):
        for j in range(n):
            if board[i][j] and row[i] != j:
                return
    for i in range(n):
        for j in range(n):
            if row[i] == j:
                print('Q', end='')
            else:
                print('.', end='')
        print('')

def set_queen(i, j):
    row[i] = j
    col[j] = NOT_FREE
    dpos[i+j] = NOT_FREE
    dneg[i-j+n-1] = NOT_FREE

def remove_queen(i, j):
    row[i] = FREE
    col[j] = FREE
    dpos[i+j] = FREE
    dneg[i-j+n-1] = FREE

def recursive(i):
    if i == n:
        print_board(board)
        return
    for j in range(n):
        if col[j] == NOT_FREE or dpos[i+j] == NOT_FREE or dneg[i-j+n-1] == NOT_FREE:
            continue
        set_queen(i, j)
        recursive(i+1)
        # 以下の行は、i+1 行目にクイーンを配置できなかったときのみ実行される
        remove_queen(i, j)
    # for を最後まで実行できた場合、クイーンの配置ができなかったことになる (i 行目についてすべての列 (j) を試したが NG)


n = 8
FREE = -1
NOT_FREE = 1

col = []
row = []
dpos = []
dneg = []
board = [[False] * n for i in range(n)]

for i in range(n):
    col.append(FREE)
    row.append(FREE)
for i in range(2 * n - 1):
    dpos.append(FREE)
    dneg.append(FREE)

k = int(input())
for i in range(k):
    r, c = map(int, input().split())
    board[r][c] = True

recursive(0)


Measured memory_bytes: 5624
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, char>> sc(m);
	for (int i = 0; i < m; i++) {
		int s_in;
		char c_in;
		cin >> s_in >> c_in;
		sc.at(i) = make_pair(s_in, c_in);
	}

	int ans = -1;
	for (int i = 0; i < 1000; i++) {
		string i_str = to_string(i);
		bool flag = true;
		if (i_str.size() != n) {
			flag = false;
			continue;
		}
		for (auto sc_ele : sc) {
			if (sc_ele.first > i_str.size()) {
				flag = false;
				break;
			}
			if (sc_ele.second != i_str[sc_ele.first - 1]) {
				flag = false;
				break;
			}
			flag = true;
		}
		if (flag == true) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;
}


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

int main() {
	string s;
	cin >> s;
	if(s=="A"){
		cout << "T" << endl;
	}else if(s=="T"){
		cout << "A" << endl;
	}else if(s=="G"){
		cout << "C"	<< endl;
	}else{
		cout << "G" << endl;
	}
	return 0;
}

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

using namespace std;

int main(void) {
    long long n;
    vector <long long> a;
    cin >> n;
    for (long long i = 0; i < 3 * n; i++) {
        long long ai;
        cin >> ai;
        a.push_back(ai);
    }

    priority_queue <long long> left;
    long long sleft = 0;
    long long sl[300000];
    for (long long i = 0; i < 3 * n; i++) {
        left.push(-a[i]);
        sleft += a[i];
        if (left.size() > unsigned(n)) {
            int j;
            j = left.top() * (-1);
            left.pop();
            sleft -= j;
        }
        sl[i] = sleft;
    }

    priority_queue <long long> right;
    long long sright = 0;
    long long sr[300000];
    for (long long i = 3 * n - 1; i >= 0; i--) {
        right.push(a[i]);
        sright += a[i];
        if (right.size() > unsigned(n)) {
            int j;
            j = right.top();
            right.pop();
            sright -= j;
        }
        sr[i] = sright;
    }

    long long res;
    res = -999999999999999;
    for (int i = n - 1; i < 2 * n; i++) {
        res = max(res, sl[i] - sr[i + 1]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11500
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long A[N+1],B[N];
  long long cnt=0;
  for (int i=0;i<N+1;i++){
    cin>>A[i];
  }
  for (int i=0;i<N;i++){
    cin>>B[i];
    cnt=cnt+min(A[i]+A[i+1],B[i]);
    if(A[i]<B[i]){
      A[i+1]=A[i+1]-(B[i]-A[i]);
    }
    if(A[i+1]<0){
      A[i+1]=0;
    }
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n,A1[110],A2[110];
  cin >> n;

  for(int i = 0; i < n; i++)
    cin >> A1[i];
  for(int i = 0; i < n; i++)
    cin >> A2[i];

  int ans = 0;
  for(int i = 0; i < n; i++) {
    int count = 0;
    for(int j = 0; j < n; j++) {
      if(i+j < n) count += A1[j];
      if(n-i-1+j < n) count += A2[n-i-1+j];
    }
    ans = max(ans,count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
/*
bool sg[5][5]={{0,0,1,1,1},
               {0,0,0,1,1},
               {1,0,0,0,1},
               {1,1,0,0,0},
               {1,1,1,0,0}};
      */
int main()
{
    long long x,y;
    cin>>x>>y;
    if(x>y)swap(x,y);
    if(y-x>1)cout<<"Alice"<<endl;
    else cout<<"Brown"<<endl;

}

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

int main()
{
  string s;
  cin >> s;
  if (0 < stoi(s.substr(0, 2)) && stoi(s.substr(0, 2)) <= 12 && 0 < stoi(s.substr(2, 2)) && stoi(s.substr(2, 2)) <= 12)
    cout << "AMBIGUOUS" << endl;
  else if (0 < stoi(s.substr(0, 2)) && stoi(s.substr(0, 2)) <= 12)
    cout << "MMYY" << endl;
  else if (0 < stoi(s.substr(2, 2)) && stoi(s.substr(2, 2)) <= 12)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
  return 0;
}


Measured memory_bytes: 256
/// hi_im_manh :D
#include <bits/stdc++.h>
#define reset(a,n) memset(a,0,(n+1)*sizeof(int))
#define endl "\n"
#define llmin LLONG_MIN
#define llmax LLONG_MAX
#define intmax INT_MAX
#define intmin INT_MIN
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define duckman "TASK"

#define input freopen(duckman".inp", "r", stdin);
#define output freopen(duckman".out", "w", stdout);

#define nmax 22000
using namespace std;


int main()
{
    fast;
//    input;
//    output;

    ll n, weight;
    cin >> n >> weight;
    ll w[n], v[n];
    for (ll i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    ll dp[n+1][weight+1];
    memset(dp, 0, sizeof(dp));

    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= weight; j++) {
            dp[i][j] = dp[i-1][j];
            if (w[i-1] <= j) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
            }
        }
    }
    cout << dp[n][weight];
}

/*

*/


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	v1 a(0);
	char s[100];
	while(scanf("%s", s) != EOF){
		int last = a.size()-1;
		if(s[0] == '+'){
			a.at(last-1) = a.at(last-1)+a.at(last);
			a.pop_back();
			continue;
		}
		if(s[0] == '-'){
			a.at(last-1) = a.at(last-1) - a.at(last);
			a.pop_back();
			continue;
		}
		if(s[0] == '*'){
			a.at(last-1) = a.at(last-1)*a.at(last);
			a.pop_back();
			continue;
		}
		a.push_back(atoi(s));
	}
	cout << a.at(0) << endl;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	cin >> n;
	V<P<int>> a(n);
	REP(i, n) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	upsort(a);
	REP(i, n) {
		cout << a[i].second << ' ';
	}
	cout << endl;
	return 0;
}

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

string field[256];

void rotate(int n){
	string tmp[256];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			tmp[i] += field[n - j - 1][i];
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) field[i][j] = tmp[i][j];
	}
}

int main(){
	int n;
	while(cin >> n,n){
		int ma = 0;
		for(int i = 0;i < n;i++) cin >> field[i];
		for(int i = 0;i < n;i++){
			int cnt = 0;
			for(int j = 0;j < n;j++){
				if(field[i][j] == '1') {
					cnt++;
					ma = max(ma,cnt);
				}else cnt = 0;
			}
			cnt = 0;
			for(int j = 0;j < n;j++){
				if(field[j][i] == '1') {
					cnt++;
					ma = max(ma,cnt);
				}else cnt = 0;
			}
		}
		for(int k = 0;k < 2;k++){
			if(k) rotate(n);
			for(int i = 0;i < 2 * n - 1;i++){
				int cnt = 0;
				for(int j = 0;j < n;j++){
					if(i - j >= n || i - j < 0) continue;
					if(field[j][i - j] == '1'){
							cnt++;
						ma = max(ma,cnt);
					}else cnt = 0;
				}
			}
		}
		cout << ma << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
	char str[1000], mark[1000];
	int i, count = 0;
	
	scanf("%s", mark);
	
	for(i = 0; ; i++)
	{
		if(mark[i] == '\0') break;
		mark[i] = toupper(mark[i]);
	}
	
	while(1)
	{
		scanf("%s", str);
		if(strcmp(str, "END_OF_TEXT") == 0) break;
		
		for(i = 0; ; i++)
		{
			if(str[i] == '\0') break;
			str[i] = toupper(str[i]);
		}
		if(strcmp(str, mark) == 0) count++;
	}
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 552
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using lb = long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}

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

#define MAX_E 2004
#define MAX_V 1004

// 頂点fromから頂点toへのコストcostの辺
struct edge {
    long long int from, to, cost;
};

edge es[MAX_E]; // 辺

long long int d[MAX_V]; // 最短距離
int V, E;     // Vは頂点数、Eは辺

// s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
    for (int j=0;j<V;++j) {
        bool update = false;
        for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (d[e.from] != LLONG_MAX && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if (!update)
            break;
    }
}

int main(){
    cin >> V >> E;
    for(int i=0;i<E;++i){
        int a, b, c;
        cin >> a >> b >> c;
        es[i] = (edge){a, b, -c};
    }

    for(int i=2;i<=V;++i)d[i] = LLONG_MAX;

    shortest_path(1);
    long long int ans = d[V];
    shortest_path(1);
    if(ans > d[V])cout << "inf" << endl;
    else cout << -ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
V = list(map(int, input().split()))
A = {}
B = {}
for i in range(n):
  if i % 2 == 0:#A
    A[V[i]] = A.get(V[i], 0) + 1
  else:#B
    B[V[i]] = B.get(V[i], 0) + 1

A = sorted(A.items(), key=lambda x:x[1], reverse=True)
B = sorted(B.items(), key=lambda x:x[1], reverse=True)
a1, b1 = A[0][1], B[0][1]
am, bm = A[0][0], B[0][0]
ans = n - a1 - b1
if ans == 0 and V[0]==V[1]:
  ans = n//2
elif am == bm and n > 4:
  a2,b2 = A[1][1], B[1][1]
  ans = min(n - a2 - b1, n - a1 - b2) 
print(ans)


Measured memory_bytes: 17688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl
#define REPEAT(i,n) for(int i=0;i<n;i++ )

using namespace std;

typedef unsigned long long int ull;


int main(void) {


	int N;
	INPUT(N);
	int mid = N/2;
	int ans;
	vector<int> d(N);
	REPEAT(i,N) INPUT(d[i]);

	std::sort(d.begin(),d.end());
//	REPEAT(i,N) OUTPUT(d[i]);
	d[mid]-d[mid-1] >= 0 ? ans = d[mid]-d[mid-1] : ans = 0;
	
	OUTPUT(ans);

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    cin >> S >> T;
    for(int i=0; i<S.size(); i++){
        if(S==T){
            cout << "Yes" << endl;
            return 0;
        }
        char t=S.at(S.size()-1);
        for(int j=S.size()-2; j>=0; j--){
            S.at(j+1)=S.at(j);
        }
        S.at(0)=t;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[0]*n
b=[0]*n
c=[0]*(n-1)
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(n):
  ans+=b[a[i]-1]
  if (i>0 and a[i]==a[i-1]+1):
    ans+=c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
//#define leng length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.se<b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //-----------------------------
    ll x;cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------














































Measured memory_bytes: 3632
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, m = LI()
    x = LI()
    d = defaultdict(int)
    l = [defaultdict(int) for _ in range(m)]
    for a in x: d[a % m] += 1; l[a % m][a] += 1
    ans = 0
    for a in range((m >> 1) + 1):
        if a == m - a or a == 0:
            ans += d[a] >> 1
        else:
            tmp = min(d[a], d[m - a])
            ans += tmp
            if d[a] < d[m - a]:
                tmp = d[m - a] - d[a]
                for value in l[m - a].values():
                    if tmp < 2:
                        break
                    if value >> 1:
                        t = min(tmp >> 1, value >> 1)
                        ans += t
                        tmp -= 2 * t
            else:
                tmp = d[a] - d[m - a]
                for value in l[a].values():
                    if tmp < 2:
                        break
                    if value >> 1:
                        t = min(tmp >> 1, value >> 1)
                        ans += t
                        tmp -= 2 * t
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 96864
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin >> n;
    int ans=7;
    if(n%2==0)
    {
        cout <<"-1\n";
    }
    else
    {
        int count=1;
        while(ans<n)
        {
            ans*=10;
            ans+=7;
            count ++;
        }
       // cout << count;
        //cout << ans;
        for(int i=count ;i<=1000000;i++)
        {
            ans%=n;
            if(ans==0)
            {
                cout << i;
                    
                    return 0;
            }
            ans*=10;
            ans+=7;
            
        }
        cout <<"-1";
        return 0;

    }
    
} 


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

fn main() {
    let n = get!(usize);
    let mut v = get!([i64]);
    v.sort();
    if n == 2 {
        println!("{} {}", v[1], v[0]);
        return;
    }
    let ai = v.iter().max().unwrap();
    let mut aj = i64::max_value();
    let mut tmp = i64::max_value();
    for i in 0..n {
        if (v[i] - (ai / 2)).abs() <= tmp {
            tmp = (v[i] - (ai / 2)).abs();
            aj = v[i];
        }
    }
    println!("{} {}", ai, aj);
}


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

int main()
{
	string a,b;
	int x;
	int zh(string s);
	
	cin>>a>>b;
	
	x=zh(a+b);
	
	if (int (sqrt(x))==sqrt(x))
	   cout<<"Yes"<<endl;
	else 
	   cout<<"No"<<endl;
	   
	   return 0;
}

   int zh(string s)
   {
   	   int tmp=0;
   	   
   	   for (int i=0;i<s.size();i++)
   	      tmp=tmp*10+(s[i]-'0');
   	      
   	      return tmp;
   }

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
#include <complex>
#include <cmath>
using namespace std;
signed main(void)
{
	int n;
	int x1,x2, y1,y2, t1, t2;
	cin >> n;
	t1 = 0; x1 = 0; y1 = 0;
	int judge = 0;
	for (int i = 0; i < n; i++) {
		cin >> t2 >> x2 >> y2;
		int time = abs(x2 - x1) + abs(y2 - y1);
		if (time <= t2 - t1 && (t2 - t1 - time) % 2 == 0);
		else judge = 1;
		t1 = t2; x1 = x2; y1 = y2;
	}
	if (judge == 0)cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  if(a+b==c||a+c==b||b+c==a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import math

def insertionSort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        A[j + g] = v
    return cnt


def shellSort(A, n):
    cnt = 0
    j = int(math.log(2 * n + 1, 3)) + 1
    G = list(reversed([(3 ** i - 1)// 2 for i in range(1, j)]))
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    return A, cnt, G, m

n = int(input())
A = [int(input()) for i in range(n)]
ans, count, G, m = shellSort(A, n)
print(m)
print(' '.join(map(str,G)))
print(count)
[print(i) for i in A]

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

using namespace std;

int main () {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  
  int ans = 0;
  
  for (int i = 0; i <= N / R; i++) {
    for (int j = 0; j <= N / G; j++) {
      int a = N - R * i - G * j;
      if (a % B == 0 && a >= 0) { ans++; }
    }
  }
  
  cout << ans;
}


Measured memory_bytes: 256
N = int(input())
c = list(input())

a=0
b=0

a = c.count("R")
ans = c.count("R")
for i in range(N):
    if c[i] == "R":
        a -= 1
    else:
        b += 1

    now = max(a,b)
    ans = min(ans, now)

print(ans)

Measured memory_bytes: 10748
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	string S=in<string>();
	int N=S.size();
	string T(N,'x');
	
	out(T);
	return 0;
}


Measured memory_bytes: 256